CLI Reference

The sure-cli tool wraps the SurelyCrm JSON API so you can manage customers, leads, workflows, and support records from the terminal or shell scripts without writing HTTP calls by hand. This guide covers version 1.3.0.

Prerequisites: Node.js 18 or later is required. The CLI communicates with the same /Api/ endpoints as the raw HTTP API, so an API key is required.

Installation

The CLI is published to the npm registry. Install it globally:

npm install -g @surelycrm/cli

Or run it once without installing:

npx @surelycrm/cli --help

To develop locally, the CLI source also lives in the Sure.Cli folder of the repository. Install its dependencies and link the command:

cd Sure.Cli
npm install
npm link

After linking, the sure-cli command is available globally.

Configuration

Before running any command, initialise the CLI with the API base URL and your API key. Configuration is stored in ~/.surecli/config.json.

Init

PropertyValue
Commandsure-cli init
PurposeStore the API base URL and API key

Options

OptionRequiredDescription
--urlYesBase URL of the SurelyCrm site, e.g. https://app.surelycrm.co.uk/
--api-keyYesAPI key GUID from Settings > Application Settings

Example

sure-cli init \
  --url https://app.surelycrm.co.uk/ \
  --api-key 550e8400-e29b-41d4-a716-446655440000

Show Config

sure-cli config

Prints the currently stored configuration.

Customer Commands

All customer actions are grouped under sure-cli customer (alias sure-cli customers). Every command that needs a request body accepts --template, --data, or uses the bundled default template. Lead conversion is documented separately because it accepts no mapping payload.

Get Customer

Retrieves a single customer record by GUID, email address, or reference number. Only one lookup option can be used at a time.

PropertyValue
Commandsure-cli customer get
API endpointsGET /Api/customer/{id}, GET /Api/customer/byEmail/{emailAddress}, GET /Api/customer/reference/{referenceNumber}

Options

OptionRequiredDescription
--idOne of --id, --email, or --referenceCustomer GUID
--emailOne of --id, --email, or --referenceCustomer email address
--referenceOne of --id, --email, or --referenceCustomer reference number

Examples

sure-cli customer get --id 550e8400-e29b-41d4-a716-446655440000
sure-cli customer get --email john@example.com
sure-cli customer get --reference CUS-2025-00001

Add Customer

Creates a new customer. Uses the bundled template by default, or a custom JSON file or inline payload.

PropertyValue
Commandsure-cli customer add
API endpointPOST /Api/customer

Options

OptionRequiredDescription
--templateNoPath to a JSON customer template file
--dataNoInline JSON payload

Examples

# Use the default bundled template
sure-cli customer add

# Use a custom template
sure-cli customer add --template ./my-customer.json

# Inline JSON
sure-cli customer add --data '{"title":"Mrs","firstname":"Jane","surname":"Smith","emailAddress":"jane@example.com"}'

Update Customer

Updates an existing customer by GUID, reference, or email. The resolved identifier is injected into the payload automatically.

PropertyValue
Commandsure-cli customer update
API endpointPUT /Api/customer/{id}

Options

OptionRequiredDescription
--idOne of --id, --email, or --referenceCustomer GUID
--emailOne of --id, --email, or --referenceCustomer email address
--referenceOne of --id, --email, or --referenceCustomer reference number
--templateNoPath to a JSON customer template file
--dataNoInline JSON payload

Example

sure-cli customer update \
  --id 550e8400-e29b-41d4-a716-446655440000 \
  --data '{"title":"Mr","firstname":"Johnny","surname":"Davies","emailAddress":"johnny@example.com"}'

Change Customer Status

Changes the status of a customer identified by GUID, reference, or email.

PropertyValue
Commandsure-cli customer change-status
API endpointPOST /Api/customer/{id}/status

Options

OptionRequiredDescription
--idOne of --id, --email, or --referenceCustomer GUID
--emailOne of --id, --email, or --referenceCustomer email address
--referenceOne of --id, --email, or --referenceCustomer reference number
--status-idYes*Status GUID. *Required unless already present in --data or --template.
--templateNoPath to a JSON status change template file
--dataNoInline JSON payload

Example

sure-cli customer change-status \
  --reference CUS-2025-00001 \
  --status-id 550e8400-e29b-41d4-a716-446655440001

Start Customer Workflow

Starts a workflow instance for a customer identified by GUID, reference, or email. Either --workflow-id or --workflow-name is required.

PropertyValue
Commandsure-cli customer start-workflow
API endpointPOST /Api/customer/{id}/workflow

Options

OptionRequiredDescription
--idOne of --id, --email, or --referenceCustomer GUID
--emailOne of --id, --email, or --referenceCustomer email address
--referenceOne of --id, --email, or --referenceCustomer reference number
--workflow-idOne of --workflow-id or --workflow-nameWorkflow GUID
--workflow-nameOne of --workflow-id or --workflow-nameWorkflow name
--context-dataNoJSON context data. Defaults to "{}".
--templateNoPath to a JSON workflow start template file
--dataNoInline JSON payload

Examples

sure-cli customer start-workflow \
  --email john@example.com \
  --workflow-id 550e8400-e29b-41d4-a716-446655440001

sure-cli customer start-workflow \
  --reference CUS-2025-00001 \
  --workflow-name "Welcome Sequence"

Get Customers by Age

PropertyValue
Commandsure-cli get-customers-by-age
API endpointGET /Api/customers/byAge?age={age}&comparison={comparison}

Options

OptionRequiredDescription
--ageYesAge value to compare
--comparisonNoOne of equal, greater, less, greaterthanorequal, or lessthanorequal. Defaults to equal.

Campaign Commands

Campaigns are managed with sure-cli campaign (alias sure-cli campaigns). Campaigns can be looked up by GUID, reference code, or name. When a reference code is omitted on create, a unique code is generated automatically from the campaign name.

Get Campaign

Retrieves a single campaign by GUID, reference code, or name.

PropertyValue
Commandsure-cli campaign get
API endpointsGET /Api/campaign/{id}, GET /Api/campaign/reference/{referenceCode}, GET /Api/campaign/byName/{name}

Options

OptionRequiredDescription
--idOne of --id, --reference, or --nameCampaign GUID
--referenceOne of --id, --reference, or --nameCampaign reference code
--nameOne of --id, --reference, or --nameCampaign name

Examples

sure-cli campaign get --id 550e8400-e29b-41d4-a716-446655440000
sure-cli campaign get --reference CMP-2026-00001
sure-cli campaign get --name "Summer Campaign"

List Campaigns

PropertyValue
Commandsure-cli campaign list
API endpointGET /Api/campaigns

Add Campaign

Creates a new campaign. The reference code is optional; leave it blank or omit it to auto-generate a code such as CMP-2026-00001.

PropertyValue
Commandsure-cli campaign add
API endpointPOST /Api/campaign

Options

OptionRequiredDescription
--templateNoPath to a JSON campaign template file
--dataNoInline JSON payload

Examples

# Use the default bundled template
sure-cli campaign add

# Inline JSON with an explicit reference code
sure-cli campaign add --data '{"name":"Summer Campaign","referenceCode":"SUM-2026-001","campaignLocationId":"550e8400-e29b-41d4-a716-446655440010","status":"New"}'

# Auto-generate the reference code
sure-cli campaign add --data '{"name":"Summer Campaign","campaignLocationId":"550e8400-e29b-41d4-a716-446655440010"}'

Update Campaign

Updates an existing campaign by GUID, reference code, or name. The resolved identifier is injected into the payload automatically.

PropertyValue
Commandsure-cli campaign update
API endpointPUT /Api/campaign/{id}

Options

OptionRequiredDescription
--idOne of --id, --reference, or --nameCampaign GUID
--referenceOne of --id, --reference, or --nameCampaign reference code
--nameOne of --id, --reference, or --nameCampaign name
--templateNoPath to a JSON campaign template file
--dataNoInline JSON payload

Example

sure-cli campaign update \
  --reference CMP-2026-00001 \
  --data '{"status":"InProgress"}'

Campaign Location Commands

Campaign locations are managed with sure-cli location (alias sure-cli locations). Locations are looked up by GUID.

Get Campaign Location

PropertyValue
Commandsure-cli location get
API endpointGET /Api/campaign-location/{id}

Options

OptionRequiredDescription
--idYesCampaign location GUID

List Campaign Locations

PropertyValue
Commandsure-cli location list
API endpointGET /Api/campaign-locations

Add Campaign Location

PropertyValue
Commandsure-cli location add
API endpointPOST /Api/campaign-location

Options

OptionRequiredDescription
--templateNoPath to a JSON location template file
--dataNoInline JSON payload

Example

sure-cli location add --data '{"name":"Manchester","description":"North West region","isActive":true}'

Update Campaign Location

PropertyValue
Commandsure-cli location update
API endpointPUT /Api/campaign-location/{id}

Options

OptionRequiredDescription
--idYesCampaign location GUID
--templateNoPath to a JSON location template file
--dataNoInline JSON payload

Lead Commands

Leads are managed with sure-cli lead (alias sure-cli leads). Discover exact records by status and opaque external reference. External references are integration identities, separate from display/reference numbers and CRM IDs. When creating or updating a Lead, select its campaign by GUID, name or reference code.

Discover Leads by Status

sure-cli lead list --status BuildFailed
sure-cli lead list --status "Needs Review" --page-size 5 --cursor '<nextCursor>'
sure-cli lead list --status BuildFailed --all
sure-cli lead get --external-reference 'lead_opaque_reference'

--status is required and trimmed. It accepts a tenant-local Lead status name or Lead status GUID; invalid status fails without an unfiltered retry. Default output is one JSON page, with only these fields per Lead:

{
  "leads": [
    {
      "externalReference": "lead_opaque_reference",
      "status": "BuildFailed",
      "createdAt": "2026-01-01T00:00:00Z"
    }
  ],
  "nextCursor": null
}

A valid status with no matches succeeds with {"leads":[],"nextCursor":null}. The default page size is 20; --page-size accepts decimal integers 1–20. Pass the previous nextCursor unchanged with --cursor for continuation; tokens must be nonblank and at most 2,048 characters.

--all walks remaining pages sequentially, optionally from --cursor, until the cursor is null. Limits are 1,000 requests and 10 MiB cumulative response bytes. If they prevent completion, use manual pagination. Repeated cursors, duplicate references, malformed responses and later-page errors fail without partial stdout. Each request has a 30-second timeout, 1 MiB success-body limit and 8 KiB error-body limit. There are no automatic retries or redirects. Concurrent writes can change page membership or remove later detail; traversal is not a database snapshot.

The configured host selects the tenant and its apiKey authenticates both reads. Listing requires AutomatedSampleSiteClaim; exact reference detail independently requires SalesBrief. Failures exit nonzero with bounded stderr and no raw error body: 400 means invalid input, 401 authentication failed, and 404 unavailable, missing or disabled access.

Reference detail returns exactly externalReference, businessName, salesBrief, contactEmail, contactPhone, preferredSite and customFields. Nullable strings stay null. Custom fields contain stored string values for active Lead definitions by name, or an empty object. This explicit detail may contain private data. See the list API and reference detail API.

Edit and Read Lead Fields

Use exactly one --id or --email. Updates require a local UTF-8 JSON file, so private values need not appear in arguments.

sure-cli lead update-fields --id {guid} --file ./lead-fields.json
sure-cli lead get-fields --id {guid}
sure-cli lead update-fields --email lead@example.test --file ./lead-fields.json
sure-cli lead get-fields --email lead@example.test

The file accepts salesBrief and/or customFields:

{
  "salesBrief": "Prepared sales brief",
  "customFields": { "Domain": "example.test", "Approved": "false", "OldValue": null }
}

Omitted fields and omitted custom keys preserve stored values. Brief text is limited to 8,000 raw characters. Strings are trimmed by the server; null or blank text clears the brief or deletes only the named custom value. Custom keys are exact active Lead definition Names; values are strings or null. Use "false" for an unchecked checkbox, not a JSON boolean.

An empty operation, unknown property, duplicate key, null custom object or wrong JSON value shape fails. The CLI validates file shape before email lookup; the server validates names and types and rejects a whole mixed edit if any entry is invalid. No defaults or omitted required values are filled.

Both commands require Leads and the configured tenant API key. Brief edits require SalesBrief; custom edits require LeadTagsAndCustomFields. Readback includes only enabled groups: nullable salesBrief and stored active values in customFields, or an empty object. Disabled groups are omitted. Updates print {"success":true}. Keep private readback out of shared logs; failure output does not print API error bodies.

See the Lead Fields API for validation and status codes. Existing lead update remains a full standard-field update and cannot write SalesBrief.

Get Lead

Use exactly one selector: --external-reference for the seven-field detail described above, or --id/--email for legacy sensitive full-record output. Email can select only one of several same-email Leads; use discovery and an exact reference to distinguish them.

PropertyValue
Commandsure-cli lead get
API endpointsGET /Api/lead/{id}, GET /Api/lead/byEmail/{emailAddress}, GET /api/external/leads/{externalReference}

Options

OptionRequiredDescription
--idExactly one selectorLead GUID
--emailExactly one selectorLead email address
--external-referenceExactly one selector Opaque reference returned by discovery

Examples

sure-cli lead get --id 550e8400-e29b-41d4-a716-446655440000
sure-cli lead get --email lead@example.test
sure-cli lead get --external-reference lead_opaque_reference

Add Lead

Creates a new lead with the tenant's Lead status named New. This status is tenant data seeded for compatibility; if it is missing, creation fails until the status is restored.

PropertyValue
Commandsure-cli lead add
API endpointPOST /Api/lead

Options

OptionRequiredDescription
--campaign-idNo*Campaign GUID. *Required unless campaignId is supplied in --data/--template, or another campaign selector is used.
--campaign-nameNo*Campaign name. Resolved to a GUID before the request is sent.
--campaign-referenceNo*Campaign reference code. Resolved to a GUID before the request is sent.
--templateNoPath to a JSON lead template file
--dataNoInline JSON payload

Examples

# Assign to a campaign by GUID
sure-cli lead add --campaign-id 550e8400-e29b-41d4-a716-446655440000 --data '{"businessName":"Example Business","contactPerson":"Jane Smith","contactEmail":"jane@example.com","contactPhone":"07700900456"}'

# Assign to a campaign by name
sure-cli lead add --campaign-name "Summer Campaign" --data '{"businessName":"Example Business","contactPerson":"Jane Smith","contactEmail":"jane@example.com","contactPhone":"07700900456"}'

# Assign to a campaign by reference code
sure-cli lead add --campaign-reference CMP-2026-00001 --data '{"businessName":"Example Business","contactPerson":"Jane Smith","contactEmail":"jane@example.com","contactPhone":"07700900456"}'

# Provide campaignId directly in the payload
sure-cli lead add --data '{"campaignId":"550e8400-e29b-41d4-a716-446655440000","businessName":"Example Business","contactPerson":"Jane Smith","contactEmail":"jane@example.com","contactPhone":"07700900456"}'

Update Lead

Updates an existing lead by GUID or email. The campaign can be changed using --campaign-id, --campaign-name, or --campaign-reference.

PropertyValue
Commandsure-cli lead update
API endpointPUT /Api/lead/{id}

Options

OptionRequiredDescription
--idOne of --id or --emailLead GUID
--emailOne of --id or --emailLead email address
--campaign-idNoNew campaign GUID
--campaign-nameNoNew campaign name. Resolved to a GUID before the request is sent.
--campaign-referenceNoNew campaign reference code. Resolved to a GUID before the request is sent.
--templateNoPath to a JSON lead template file
--dataNoInline JSON payload

Example

sure-cli lead update --email jane@example.com --campaign-reference CMP-2026-00001 --data '{"businessName":"Example Business Ltd"}'

Change Lead Status

Changes the status of a lead. Provide a Lead status name or the matching status GUID (for example the tenant's Processing status).

PropertyValue
Commandsure-cli lead change-status
API endpointPOST /Api/lead/{id}/status

Options

OptionRequiredDescription
--idOne of --id or --emailLead GUID
--emailOne of --id or --emailLead email address
--status Yes* New Lead status name or matching Lead status GUID. *Required unless already present in --data or --template.
--notesNoOptional notes for the activity log
--template No Path to a JSON lead status change template file; the default still uses Processing.
--dataNoInline JSON payload

Example

sure-cli lead change-status --email lead@example.com --status Processing --notes "Called and left voicemail"

Start Lead Workflow

Starts a workflow instance for a lead. Either --workflow-id or --workflow-name is required.

PropertyValue
Commandsure-cli lead start-workflow
API endpointPOST /Api/lead/{id}/workflow

Options

OptionRequiredDescription
--idOne of --id or --emailLead GUID
--emailOne of --id or --emailLead email address
--workflow-idOne of --workflow-id or --workflow-nameWorkflow GUID
--workflow-nameOne of --workflow-id or --workflow-nameWorkflow name
--context-dataNoJSON context data. Defaults to "{}".
--templateNoPath to a JSON workflow start template file
--dataNoInline JSON payload

Convert Lead

Converts a lead to a customer using the tenant's saved Lead Conversion Configuration. The mapping is loaded and applied silently. You can optionally assign a Customer status after conversion.

PropertyValue
Commandsure-cli lead convert
API endpointPOST /Api/lead/{id}/convert

Options

OptionRequiredDescription
--idOne of --id or --emailLead GUID
--emailOne of --id or --emailLead email address
--new-status-idNoCustomer status GUID to assign after conversion

Use exactly one selector. With --email, the CLI resolves the Lead first and then calls POST /Api/lead/{id}/convert. No mapping JSON, template, or confirmation is sent. The API and MVC conversion paths use the same server-side apply operation, so they persist equivalent results.

Example

sure-cli lead convert --email lead@example.com --new-status-id 550e8400-e29b-41d4-a716-446655440002

Opportunity Commands

Manage the sales pipeline with sure-cli opportunity (alias sure-cli opportunities). Opportunities are linked to leads and track deal value, stage, probability, and expected close date.

List Opportunities

PropertyValue
Commandsure-cli opportunity list
API endpointGET /Api/opportunities

Options

OptionRequiredDescription
--lead-idNoFilter by lead GUID
--lead-emailNoFilter by lead email address
--stageNoFilter by opportunity stage
--statusNoFilter by opportunity status
--searchNoSearch term
--pageNoPage number (default 1)

Examples

sure-cli opportunity list
sure-cli opportunity list --lead-email lead@example.com
sure-cli opportunity list --stage Proposal --status Open

Get Opportunity

PropertyValue
Commandsure-cli opportunity get
API endpointGET /Api/opportunities/{id}

Example

sure-cli opportunity get --id 550e8400-e29b-41d4-a716-446655440000

Add Opportunity

PropertyValue
Commandsure-cli opportunity add
API endpointPOST /Api/opportunities

Options

OptionRequiredDescription
--lead-id or --lead-emailYesLead identifier
--titleYes*Opportunity title (*or include in --data/--template)
--valueNoDeal value
--stageNoStage (default Prospecting)
--statusNoStatus (default Open)
--expected-closeNoExpected close date (yyyy-mm-dd)
--templateNoPath to a JSON opportunity template file
--dataNoInline JSON payload

Examples

sure-cli opportunity add --lead-email lead@example.com --title "Website redesign" --value 5000
sure-cli opportunity add --lead-id 550e8400-e29b-41d4-a716-446655440000 --data '{"title":"Website redesign","value":5000,"probability":50}'

Update Opportunity

PropertyValue
Commandsure-cli opportunity update
API endpointPUT /Api/opportunities/{id}

Example

sure-cli opportunity update --id 550e8400-e29b-41d4-a716-446655440000 --stage Proposal --value 7500

Change Opportunity Stage

PropertyValue
Commandsure-cli opportunity change-stage
API endpointPOST /Api/opportunities/{id}/stage

Example

sure-cli opportunity change-stage --id 550e8400-e29b-41d4-a716-446655440000 --stage ClosedWon --notes "Verbal agreement received"

Lead Task Commands

Manage tasks linked to leads with sure-cli task (alias sure-cli tasks). Tasks support assignment, due dates, priorities, and status tracking.

List Lead Tasks

PropertyValue
Commandsure-cli task list
API endpointGET /Api/lead-tasks

Options

OptionRequiredDescription
--lead-idNoFilter by lead GUID
--lead-emailNoFilter by lead email address
--assigned-toNoFilter by assigned user GUID
--statusNoFilter by task status
--priorityNoFilter by task priority
--searchNoSearch term
--pageNoPage number (default 1)

Examples

sure-cli task list
sure-cli task list --lead-email lead@example.com --status NotStarted
sure-cli task list --assigned-to 550e8400-e29b-41d4-a716-446655440001

Get Lead Task

PropertyValue
Commandsure-cli task get
API endpointGET /Api/lead-tasks/{id}

Example

sure-cli task get --id 550e8400-e29b-41d4-a716-446655440000

Add Lead Task

PropertyValue
Commandsure-cli task add
API endpointPOST /Api/lead-tasks

Options

OptionRequiredDescription
--lead-id or --lead-emailYesLead identifier
--titleYes*Task title (*or include in --data/--template)
--assigned-toNoAssigned user GUID
--statusNoStatus (default NotStarted)
--priorityNoPriority (default Normal)
--due-dateNoDue date (yyyy-mm-dd)
--templateNoPath to a JSON task template file
--dataNoInline JSON payload

Examples

sure-cli task add --lead-email lead@example.com --title "Follow up call" --priority High --due-date 2026-08-10
sure-cli task add --lead-id 550e8400-e29b-41d4-a716-446655440000 --data '{"title":"Follow up call","priority":"High","dueDate":"2026-08-10"}'

Update Lead Task

PropertyValue
Commandsure-cli task update
API endpointPUT /Api/lead-tasks/{id}

Example

sure-cli task update --id 550e8400-e29b-41d4-a716-446655440000 --status InProgress

Change Lead Task Status

PropertyValue
Commandsure-cli task change-status
API endpointPOST /Api/lead-tasks/{id}/status

Example

sure-cli task change-status --id 550e8400-e29b-41d4-a716-446655440000 --status Completed

Workflow Commands

Inspect, replace, and change the lifecycle of the configured tenant's workflow definitions. These commands use the tenant API key and print machine-readable JSON on stdout. They never start an instance. The Supplier record type is reported as the canonical Company value. The configured host selects the tenant; its administrative API key is required, and a browser session is insufficient. Key-only writes use the tenant-local non-login audit actor; no interactive tenant user is required. There is no workflow delete command.

Deploy and verify the Workflow Definition API on the server before publishing or using the matching CLI. Older servers return bounded HTTP failures; the CLI never falls back to browser actions or database access. Existing Customer/Lead instance-start commands remain separate.

List Workflows

Lists workflow definitions for the configured tenant, including inactive ones. Output is { items, page, pageSize, hasMore }, ordered by name then id. No automatic paging is performed. An empty page succeeds with items: []. The CLI clamps a positive page size above 100 to 100; the API rejects sizes above 100. The page offset must fit 2,147,483,647. Separate pages can shift if definitions change between requests.

PropertyValue
Commandsure-cli workflow list
API endpointGET /api/workflows

Options

OptionDefaultDescription
--page1 Page number (1 or greater)
--page-size50 Page size, capped at 100

Examples

sure-cli workflow list
sure-cli workflow list --page 2 --page-size 10

Get Workflow

Returns one complete definition, including every stage, its type and action configuration, conditions and modes, branch rules and fallback, waits, next/otherwise/failure routes, and layout positions, plus the trigger and its conditions. Redirect the output to a file to keep a private export.

PropertyValue
Commandsure-cli workflow get
API endpointGET /api/workflows/{id}

Options

OptionRequiredDescription
--idYesWorkflow GUID

Examples

sure-cli workflow get --id 550e8400-e29b-41d4-a716-446655440000
sure-cli workflow get --id 550e8400-e29b-41d4-a716-446655440000 > definition.json

Apply Workflow

Creates or updates a workflow from a JSON definition. Supply exactly one of --file or --data. The payload is the same shape returned by workflow get: an absent, null, or all-zero GUID id creates a new Draft, inactive workflow, while a non-zero GUID id updates that tenant's workflow and preserves its lifecycle state. Include both stages and trigger (use [] and null to clear them), and remember read-only activation fields are ignored. Apply is a full replacement, so an edited export re-applied with its id converges the definition. A retained trigger keeps its identity even when edited; its conditions are replaced. Removing a trigger referenced by any queue row (including completed/failed rows), or a stage with execution history, fails with a bounded conflict. The definition must be a JSON object of at most 1 MiB; a malformed or oversized definition fails before any request is sent.

PropertyValue
Commandsure-cli workflow apply
API endpoint POST /api/workflows/apply

Options

OptionRequiredDescription
--file One of --file or --data Path to a JSON definition file
--data One of --file or --data Inline JSON definition

Examples

sure-cli workflow apply --data \
  '{"name":"Welcome","stages":[],"trigger":null}'
sure-cli workflow get --id 550e8400-e29b-41d4-a716-446655440000 > definition.json
sure-cli workflow apply --file definition.json

The inline example creates; applying an export that still contains its id updates the same workflow. Remove the id to copy the definition into a new workflow, choose fresh stage IDs and update all graph references consistently. Removing only the workflow ID conflicts when its stage IDs already belong to another workflow. For another tenant, also reconcile templates, typed statuses, custom fields, and child workflows; nothing is automatically matched by name.

Include the exported record type on update. A workflow with stages or active state keeps its stored type; an empty inactive workflow can change type and defaults an omitted type to Customer. Apply requires no new update licence check; creation requires Workflow Builder licensing. Unknown IDs return 404, never create. Concurrent updates serialize, with the last successful write winning; there is no stale-edit detection, merge, or version precondition.

Activate or Deactivate Workflow

Lifecycle changes are explicit commands. Activation validates the stored definition and applies the Workflow Builder license and capacity rules. A definition with no stages cannot be activated and returns the definition conflict. Repeating a requested state succeeds without consuming another activation slot. Actual activation yields Active/true; deactivation yields Paused/false without a licence check. Deactivation preserves queue rows and running instances, but a worker attempting a pending start while inactive marks it Failed. Reactivation does not retry failed queue items.

CommandAPI endpointOption
sure-cli workflow activate POST /api/workflows/{id}/activate --id <guid>
sure-cli workflow deactivate POST /api/workflows/{id}/deactivate --id <guid>
sure-cli workflow activate --id 550e8400-e29b-41d4-a716-446655440000
sure-cli workflow deactivate --id 550e8400-e29b-41d4-a716-446655440000

Each successful command prints { id, status, isActive } as JSON. Existing instances use the current definition rather than a versioned snapshot, so changing later stages can affect their next processing. Lifecycle requests are never retried automatically.

Errors

Successful output is valid JSON on stdout with no banners. Failures exit non-zero with a short message on stderr; error bodies are bounded at 8 KiB and a successful response over 1 MiB fails without printing a truncated definition. A server error message is limited to 300 characters on stderr. Requests use a 30-second default deadline and never follow redirects, so the API key is never forwarded to another host. Workflow writes, including lifecycle changes, are never retried automatically. A deadline or connection failure does not prove rollback. After an uncertain create, inspect list/get before submitting again: creation without an ID can create duplicates. For an uncertain update or lifecycle call, get the current state before deciding whether to reapply. Server errors and bounds are documented in the Workflow Definition API.

Exports can contain sensitive action settings. Keep files private and avoid inline secrets in shell history. Transport tests can override the deadline with a positive integer SURE_CLI_REQUEST_TIMEOUT_MS value in milliseconds. The operator journey covers inspect, create, edit/reapply, activate, and deactivate for all three record types.

Support Commands

Get Support Tickets

Gets support tickets in one of three modes. Pass a ticket --id to fetch a single ticket with its messages. Pass a customer identifier (--customer-id or --customer-email) to list all tickets for that customer. Or use the global list filters --new or --recently-replied. Only one mode can be used at a time.

PropertyValue
Commandsure-cli get-support-tickets
API endpointsGET /Api/support/tickets/{id}, GET /Api/support/tickets

Options

OptionRequiredDescription
--idOne mode selector onlySupport ticket GUID
--customer-idOne mode selector onlyCustomer GUID
--customer-emailOne mode selector onlyCustomer email address
--newOne mode selector onlyReturn open tickets ordered by creation date
--recently-repliedOne mode selector onlyReturn tickets with messages in the recent period
--hoursNoNumber of hours to look back for recently replied tickets. Defaults to 24.
--pageNoPage number. Defaults to 1.
--page-sizeNoPage size. Defaults to 25.

Examples

# Get a single ticket by support ticket id
sure-cli get-support-tickets --id 550e8400-e29b-41d4-a716-446655440000

# Get all tickets for a customer by customer id
sure-cli get-support-tickets --customer-id 550e8400-e29b-41d4-a716-446655440001

# Get all tickets for a customer by email
sure-cli get-support-tickets --customer-email john@example.com

# Global list filters
sure-cli get-support-tickets --new
sure-cli get-support-tickets --recently-replied
sure-cli get-support-tickets --recently-replied --hours 48 --page 1 --page-size 10

Reply to Support Ticket

Adds a staff reply to an existing support ticket. The message can be supplied inline, from the bundled template, or from a custom JSON file.

PropertyValue
Commandsure-cli reply-to-ticket
API endpointPOST /Api/support/tickets/{id}/reply

Options

OptionRequiredDescription
--idYesSupport ticket GUID
--messageOne of --message, --template, or --dataReply message text
--templateOne of --message, --template, or --dataPath to a JSON reply template file
--dataOne of --message, --template, or --dataInline JSON reply payload
--internalNoMark the reply as internal-only
--closeNoClose the ticket after replying

Examples

sure-cli reply-to-ticket --id 550e8400-e29b-41d4-a716-446655440000 --message "We are looking into this."
sure-cli reply-to-ticket --id 550e8400-e29b-41d4-a716-446655440000 --message "Resolved." --close
sure-cli reply-to-ticket --id 550e8400-e29b-41d4-a716-446655440000 --template ./my-reply.json

JSON Templates

The CLI ships with reusable JSON templates in the Sure.Cli/templates directory. You can copy and edit them for your own use, or pass inline JSON with --data.

customer.json

Default template used by sure-cli customer add and sure-cli customer update when no --data or --template option is supplied.

{
  "title": "Mr",
  "firstname": "John",
  "surname": "Davies",
  "referenceNumber": "",
  "address1": "123 High Street",
  "address2": "",
  "address3": "",
  "address4": "",
  "town": "Manchester",
  "city": "Greater Manchester",
  "postcode": "M1 1AA",
  "homePhone": "",
  "mobilePhone": "07700900123",
  "emailAddress": "john.davies@example.com",
  "notificationsEnabled": true,
  "importantDate": null,
  "dateOfBirth": null,
  "website": "",
  "statusId": null,
  "ownerId": null,
  "referredBy": "",
  "customFields": {}
}

campaign.json

Default template used by sure-cli campaign add and sure-cli campaign update when no --data or --template option is supplied. Leave referenceCode blank to let the API generate one.

{
  "name": "Summer Campaign",
  "referenceCode": "",
  "campaignLocationId": "00000000-0000-0000-0000-000000000000",
  "status": "New"
}

campaign-location.json

Default template used by sure-cli location add and sure-cli location update when no --data or --template option is supplied.

{
  "name": "Manchester",
  "description": "North West region",
  "isActive": true
}

lead.json

Default template used by sure-cli lead add and sure-cli lead update when no --data or --template option is supplied.

{
  "campaignId": "00000000-0000-0000-0000-000000000000",
  "businessName": "Example Business Ltd",
  "contactPerson": "Jane Smith",
  "contactEmail": "jane.smith@example.com",
  "contactPhone": "07700900456",
  "websiteUrl": "https://www.example.com",
  "preferredSite": "",
  "sampleSiteUrls": ""
}

status-change.json

Template for the sure-cli customer change-status payload.

{
  "statusId": "00000000-0000-0000-0000-000000000000"
}

lead-status-change.json

Template for the sure-cli lead change-status payload.

{
  "status": "Processing",
  "notes": ""
}

workflow-start.json

Template for the sure-cli customer start-workflow and sure-cli lead start-workflow payloads.

{
  "workflowId": "00000000-0000-0000-0000-000000000000",
  "workflowName": "",
  "contextData": "{}"
}

opportunity.json

Default template used by sure-cli opportunity add and sure-cli opportunity update when no --data or --template option is supplied.

{
  "title": "",
  "description": "",
  "value": 0,
  "currency": "GBP",
  "probability": 0,
  "stage": "Prospecting",
  "status": "Open",
  "expectedCloseDate": null,
  "actualCloseDate": null,
  "ownerId": null
}

task.json

Default template used by sure-cli task add and sure-cli task update when no --data or --template option is supplied.

{
  "title": "",
  "description": "",
  "assignedToUserId": null,
  "status": "NotStarted",
  "priority": "Normal",
  "dueDate": null
}

support-reply.json

Template for the reply-to-ticket command payload.

{
  "message": "",
  "isInternal": false,
  "closeAfterReply": false
}

Exit Codes

CodeMeaning
0Success
1Configuration missing, validation error, or non-2xx HTTP response

Example Session

# 1. Configure the CLI
sure-cli init --url https://app.surelycrm.co.uk/ --api-key 550e8400-e29b-41d4-a716-446655440000

# 2. Create a customer
sure-cli customer add --template ./templates/customer.json

# 3. Fetch the customer
sure-cli customer get --id 550e8400-e29b-41d4-a716-446655440000
sure-cli customer get --email john@example.com
sure-cli customer get --reference CUS-2025-00001

# 4. Change the customer's status
sure-cli customer change-status \
  --id 550e8400-e29b-41d4-a716-446655440000 \
  --status-id 550e8400-e29b-41d4-a716-446655440002

# 5. Start a workflow for the customer
sure-cli customer start-workflow \
  --reference CUS-2025-00001 \
  --workflow-name "Welcome Sequence"

# 6. Add a campaign location
sure-cli location add --data '{"name":"Manchester","description":"North West region","isActive":true}'

# 7. Add a campaign (reference code auto-generated)
sure-cli campaign add --data '{"name":"Summer Campaign","campaignLocationId":"550e8400-e29b-41d4-a716-446655440020","status":"New"}'

# 8. Fetch the campaign by reference code
sure-cli campaign get --reference CMP-2026-00001

# 9. Add and manage a lead using the campaign reference code
sure-cli lead add --campaign-reference CMP-2026-00001 --data '{"businessName":"Acme Ltd","contactPerson":"Jane Smith","contactEmail":"jane@example.com","contactPhone":"07700900456"}'
sure-cli lead get --email jane@example.com
sure-cli lead change-status --email jane@example.com --status Processing
sure-cli lead convert --email jane@example.com --new-status-id 550e8400-e29b-41d4-a716-446655440002

# 10. Manage opportunities for the lead
sure-cli opportunity add --lead-email jane@example.com --title "Website redesign" --value 5000 --stage Prospecting
sure-cli opportunity list --lead-email jane@example.com
sure-cli opportunity change-stage --id 550e8400-e29b-41d4-a716-446655440030 --stage ClosedWon --notes "Verbal agreement received"

# 11. Manage tasks for the lead
sure-cli task add --lead-email jane@example.com --title "Follow up call" --priority High --due-date 2026-08-10
sure-cli task list --lead-email jane@example.com --status NotStarted
sure-cli task change-status --id 550e8400-e29b-41d4-a716-446655440031 --status Completed

# 12. Find customers older than 30
sure-cli get-customers-by-age --age 30 --comparison greater

# 13. List and reply to support tickets
sure-cli get-support-tickets --id 550e8400-e29b-41d4-a716-446655440003
sure-cli get-support-tickets --customer-id 550e8400-e29b-41d4-a716-446655440000
sure-cli get-support-tickets --customer-email john@example.com
sure-cli get-support-tickets --new
sure-cli reply-to-ticket --id 550e8400-e29b-41d4-a716-446655440003 --message "We are looking into this."

Need help? Run any command with --help for usage details, or contact SurelyCrm Support.