> ## Documentation Index
> Fetch the complete documentation index at: https://docs.recoverbiz.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Sequences

> Create automated follow-up campaigns with fixed and AI-generated messages.

Sequences are automated follow-up campaigns. Each sequence has ordered steps that execute on a schedule. Steps can be **fixed** (pre-written message templates) or **AI** (the AI generates the message based on conversation context).

## List Sequences

`GET /accounts/:id/sequences`

<ParamField query="limit" type="integer" default="50">
  Max results (1-250)
</ParamField>

<ParamField query="offset" type="integer" default="0">
  Pagination offset
</ParamField>

```bash theme={null}
curl https://api.recoverbiz.com/v1/accounts/acc_8f3a1b2c/sequences \
  -H "X-Partner-Key: pk_live_abc123def456..."
```

**Response: `200 OK`**

```json theme={null}
{
  "sequences": [
    {
      "id": "seq_001",
      "name": "Application Recovery",
      "description": "Follow up with applicants who stalled at document collection",
      "is_active": true,
      "is_default": true,
      "steps": [
        {
          "order": 0,
          "type": "fixed",
          "message": "Hi {{first_name}}, this is {{company}}. We noticed your application is almost complete. Can I help with the remaining steps?",
          "delay_hours": 0,
          "skip_if_replied": false
        },
        {
          "order": 1,
          "type": "ai",
          "instructions": "Follow up warmly. Reference their application and ask about any blockers.",
          "delay_hours": 24,
          "skip_if_replied": true
        },
        {
          "order": 2,
          "type": "fixed",
          "message": "Just checking in, {{first_name}}. Your application is still open and we'd love to help you get approved. Any questions I can answer?",
          "delay_hours": 72,
          "skip_if_replied": true
        }
      ],
      "enrolled_count": 45,
      "completed_count": 12
    }
  ],
  "total": 3,
  "limit": 50,
  "offset": 0
}
```

## Create Sequence

`POST /accounts/:id/sequences`

<ParamField body="name" type="string" required>
  Sequence name
</ParamField>

<ParamField body="description" type="string">
  Description of the sequence purpose
</ParamField>

<ParamField body="is_active" type="boolean" default="true">
  Whether the sequence is active
</ParamField>

<ParamField body="is_default" type="boolean" default="false">
  Whether this is the default sequence for auto-enrollment
</ParamField>

<ParamField body="steps" type="array" required>
  Ordered array of sequence steps
</ParamField>

### Step Object

| Field             | Type    | Required    | Description                                              |
| ----------------- | ------- | ----------- | -------------------------------------------------------- |
| `type`            | string  | Yes         | `fixed` or `ai`                                          |
| `message`         | string  | For `fixed` | Message template with variable support                   |
| `instructions`    | string  | For `ai`    | Instructions for the AI on what to say                   |
| `delay_hours`     | integer | No          | Hours to wait before sending. Default: `0`.              |
| `skip_if_replied` | boolean | No          | Skip this step if the lead has replied. Default: `true`. |

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.recoverbiz.com/v1/accounts/acc_8f3a1b2c/sequences \
    -H "X-Partner-Key: pk_live_abc123def456..." \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Collections Follow-up",
      "description": "Automated outreach for overdue accounts",
      "is_active": true,
      "is_default": false,
      "steps": [
        {
          "type": "fixed",
          "message": "Hi {{first_name}}, this is {{company}}. We wanted to reach out about your account. When would be a good time to discuss your payment options?",
          "delay_hours": 0,
          "skip_if_replied": false
        },
        {
          "type": "ai",
          "instructions": "Follow up on payment. Be empathetic and offer flexible payment arrangements. Do not be aggressive.",
          "delay_hours": 48,
          "skip_if_replied": true
        }
      ]
    }'
  ```

  ```typescript JavaScript theme={null}
  const res = await fetch(`https://api.recoverbiz.com/v1/accounts/${accountId}/sequences`, {
    method: 'POST',
    headers: {
      'X-Partner-Key': 'pk_live_abc123def456...',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Collections Follow-up',
      description: 'Automated outreach for overdue accounts',
      is_active: true,
      is_default: false,
      steps: [
        { type: 'fixed', message: 'Hi {{first_name}}, this is {{company}}...', delay_hours: 0 },
        { type: 'ai', instructions: 'Follow up on payment. Be empathetic.', delay_hours: 48, skip_if_replied: true },
      ],
    }),
  });
  const sequence = await res.json();
  ```
</CodeGroup>

**Response: `201 Created`**

```json theme={null}
{
  "id": "seq_002",
  "name": "Collections Follow-up",
  "description": "Automated outreach for overdue accounts",
  "is_active": true,
  "is_default": false,
  "steps": [
    { "order": 0, "type": "fixed", "message": "Hi {{first_name}}, this is {{company}}...", "delay_hours": 0, "skip_if_replied": false },
    { "order": 1, "type": "ai", "instructions": "Follow up on payment. Be empathetic...", "delay_hours": 48, "skip_if_replied": true }
  ],
  "enrolled_count": 0,
  "completed_count": 0,
  "created_at": "2026-02-15T10:30:00Z"
}
```

## Template Variables

Fixed-type steps support these variables:

| Variable               | Description            |
| ---------------------- | ---------------------- |
| `{{first_name}}`       | Lead's first name      |
| `{{last_name}}`        | Lead's last name       |
| `{{name}}`             | Full name              |
| `{{company}}`          | Account's company name |
| `{{email}}`            | Lead's email           |
| `{{property_address}}` | Property address       |

## Enroll a Lead

`POST /accounts/:id/sequences/:sequence_id/enroll`

<ParamField body="phone" type="string" required>
  Phone number of the lead to enroll (E.164)
</ParamField>

```bash theme={null}
curl -X POST https://api.recoverbiz.com/v1/accounts/acc_8f3a1b2c/sequences/seq_001/enroll \
  -H "X-Partner-Key: pk_live_abc123def456..." \
  -H "Content-Type: application/json" \
  -d '{ "phone": "+14155551234" }'
```

**Response: `200 OK`**

```json theme={null}
{
  "success": true,
  "action": "enrolled",
  "message_sent": true,
  "next_step_at": "2026-02-16T10:00:00Z"
}
```

<Note>
  If the lead is already enrolled and active, the response `action` will be `"already_enrolled"`. If previously cancelled, it will be `"reactivated"`.
</Note>

## Update Sequence

`PATCH /accounts/:id/sequences/:sequence_id`

Update a sequence's name, description, active status, or steps. Leads already enrolled continue on the existing steps — changes only apply to new enrollments.

```bash theme={null}
curl -X PATCH https://api.recoverbiz.com/v1/accounts/acc_8f3a1b2c/sequences/seq_001 \
  -H "X-Partner-Key: pk_live_abc123def456..." \
  -H "Content-Type: application/json" \
  -d '{
    "is_active": false
  }'
```

## Delete Sequence

`DELETE /accounts/:id/sequences/:sequence_id`

Removes a sequence. Leads currently enrolled are automatically cancelled.

```bash theme={null}
curl -X DELETE https://api.recoverbiz.com/v1/accounts/acc_8f3a1b2c/sequences/seq_001 \
  -H "X-Partner-Key: pk_live_abc123def456..."
```

**Response: `200 OK`**

```json theme={null}
{
  "success": true,
  "cancelled_enrollments": 3
}
```
