Campaigns
Campaigns

Set a campaign's follow-up sequence

Replace a campaign's sequence: its call steps and the outcomes they end in. Read the current one with get_campaign, change it and pass the whole document back. A sequence is { steps, outcomes }. A step is a call: { id, kind: "call", delay: { amount, unit }, attempts: [{ after, voicemail }], doubleDial, brief, routes }, or an SMS: { id, kind: "sms", delay, body, routes }. Steps come in any order, an SMS first included, and at least one is a call. delay is how long after the step before it ends this one starts (the first step's counts from launch), up to 90 days; each retry's after is 5 minutes to 24 hours; each attempt has its own voicemail (null uses the agent's setting); brief is added to the campaign brief for that call. An SMS step sends body once, with {{name}}, {{first_name}} and recipient variables filled as in the opener, from the recipient's caller number when it is an Australian mobile, otherwise from a mobile among the caller numbers, inside the SMS hours (smsWindow). Every SMS gets the business name and "Reply STOP to opt out" on a new line, and the whole text must fit in two SMS segments (about 240 plain characters of body, fewer with emoji). An SMS step ends as sent (the carrier accepted it) or no_response (it was not delivered), and both go to the next step unless routed. A STOP reply puts the number on Do not call and ends every sequence for it in the workspace as do_not_call; any other reply ends the person's sequence as replied and emails the workspace's notification list. Every call step ends in one outcome. outcomes is the ordered list checked after a connected call; the first that fits wins. do_not_call comes first (it fits when the person asks not to be contacted again or the number is on Do not call, and it adds the number there), other comes last, and no_response is given when every attempt in a step goes unanswered. Any other outcome has when: { match: "any" | "all", rules }, where a rule is { kind: "result", results: [completed | transferred | abandoned | failed] } (the call analysis result) or { kind: "ai", prompt } (the post-call analysis answers it from the call, such as "They agreed a date for their service"). converted: true makes a person whose sequence ends on that outcome count as a conversion. routes maps an outcome id to "next", "end" or the id of a LATER step; routes only go forward. An outcome left out takes the default: no_response (and an SMS step's sent) goes to the next step and every other outcome ends the sequence. Limits: 8 steps, 10 outcomes, 10 call attempts across all steps. On a DRAFT the whole sequence can change. Once the campaign is SCHEDULED, RUNNING or PAUSED its steps, their attempt counts and routes, and its outcomes and their rules are fixed: only wording (step briefs, SMS messages, outcome names and AI prompts), voicemails, delays, retry gaps, double dial and converted can change, and any other change is refused as sequence_locked. A completed or cancelled campaign can change only which outcomes count as converted. A refused sequence returns invalid_sequence with the path of each problem, such as sequence.steps.1.routes.no_response.

PUT
/workspaces/{workspace}/campaigns/{campaign}/sequence

Authorization

bearerAuth
AuthorizationBearer <token>

A personal access token from Settings > API tokens.

In: header

Path Parameters

workspace*string

Workspace slug (GET /me lists yours).

campaign*string

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

application/problem+json

curl -X PUT "https://example.com/workspaces/string/campaigns/string/sequence" \  -H "Content-Type: application/json" \  -d '{    "sequence": {      "steps": [        {          "id": "string",          "kind": "call",          "attempts": [            {              "after": {                "amount": 0,                "unit": "minutes"              },              "voicemail": {                "action": "hang_up"              }            }          ],          "doubleDial": true        }      ],      "outcomes": [        {          "id": "string",          "label": "string"        }      ]    }  }'
{
  "campaign": {
    "id": "string",
    "name": "string",
    "status": "string",
    "agentId": "string",
    "property1": null,
    "property2": null
  },
  "property1": null,
  "property2": null
}
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "errors": [
    {
      "path": "string",
      "message": "string"
    }
  ],
  "estimate": {},
  "retryAfterSeconds": 0
}
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "errors": [
    {
      "path": "string",
      "message": "string"
    }
  ],
  "estimate": {},
  "retryAfterSeconds": 0
}
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "errors": [
    {
      "path": "string",
      "message": "string"
    }
  ],
  "estimate": {},
  "retryAfterSeconds": 0
}
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "errors": [
    {
      "path": "string",
      "message": "string"
    }
  ],
  "estimate": {},
  "retryAfterSeconds": 0
}
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "errors": [
    {
      "path": "string",
      "message": "string"
    }
  ],
  "estimate": {},
  "retryAfterSeconds": 0
}
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "errors": [
    {
      "path": "string",
      "message": "string"
    }
  ],
  "estimate": {},
  "retryAfterSeconds": 0
}
{
  "type": "http://example.com",
  "title": "string",
  "status": 0,
  "detail": "string",
  "code": "string",
  "errors": [
    {
      "path": "string",
      "message": "string"
    }
  ],
  "estimate": {},
  "retryAfterSeconds": 0
}