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

# Cadence draft

> Saves the cadence's filter, bands and contacts in the draft, or discards the draft

# Cadence draft

Writes the whole draft of a cadence: name, filter, delinquency bands and the contacts of each band. The draft always saves, even incomplete; full validation happens when you [publish](https://docs.talkover.ai/en/api-reference/portfolio/cadence-lifecycle.md). Editing a published cadence opens a draft from the version in force.

## Endpoints

```
PUT    /api/v1/cadences/{id}/draft
DELETE /api/v1/cadences/{id}/draft
```

`DELETE` discards the draft; the version in force keeps running.

## Concurrent edits

Always send the `lock_version` you read (from the get or the last save). If the get returned `draft: null`, send `0`: the save opens a draft from the version in force. If someone saved after that, the response is `409` and nothing changes: get the cadence again and reapply your change.

## Request body

**lock\_version** `integer` *required*

The `lock_version` of the draft you read.

**name** `string` *required*

Cadence name, up to 120 characters.

**description** `string`

Description, up to 2,000 characters.

**filter** `object` *required*

Who enters the cadence. See [Filter](#filter). `{}` or no groups = every debt.

**agreement** `object`

Agreement in force: `pauses` (the agreement pauses the cadence), `pause_days` (for how many days, 1 to 365) and `broken_returns` (a broken agreement returns to the cadence).

**reply\_pause\_days** `integer`

Pause after the person replies in any channel, 0 to 30 days. `0` = never pauses.

**steps** `array` *required*

The delinquency bands, up to 20. See [Bands](#bands).

### Filter

```json theme={null}
{ "root": "and", "groups": [ { "op": "and", "conditions": [ { "field": "creditor", "operator": "eq", "value": "Loja Centro" }, { "field": "custom.product", "operator": "in", "value": ["card", "booklet"] } ] } ] }
```

* `root` and each group's `op`: `and` or `or`. Up to 20 groups, 30 conditions per group.
* `field`: a fixed contract field (`creditor`, `amount_due`, `overdue_amount`, `installment_amount`, `collection_phase`, `risk_class`, `overdue_installments`, `installments_total`, `credit_limit`, `payment_deadline`, `campaign_id`, `debt_key_source`, `provenance`) or a free field (`custom.<key>`). Your workspace's list comes in `filter_fields` on the get.
* `operator`: `eq`, `neq`, `in`, `not_in`, `gt`, `gte`, `lt`, `lte`, `contains`, `empty`, `not_empty`.
* Delinquency is not a filter field: it defines the band.

### Bands

Each band is a range of days overdue, with the contacts of that band.

| Field | Format |
| - | - |
| `key` | band uuid (optional; send back the one from the get to keep the same band) |
| `name` | name, up to 80 characters |
| `min` | first day overdue, -60 to 3650 (negative = before the due date) |
| `max` | last day, or `null` for "and beyond" (last band only) |
| `actions` | the band's contacts, up to 50 |

Bands cannot overlap; a gap between bands is allowed.

### Contacts

| Field | Format |
| - | - |
| `key` | contact uuid (optional; send back the one from the get to keep the same contact) |
| `day_offset` | the contact's day overdue (D+N), inside the band |
| `channel` | `voice`, `whatsapp`, `webhook` or `enrich` (the ones available in your workspace are in [Channels](https://docs.talkover.ai/en/api-reference/portfolio/cadence-settings.md)) |
| `channel_config` | the channel's configuration (below) |
| `timing` | `asap` (as soon as the hours allow), `at_time` (with `at_time` `HH:MM`) or `after_previous_hours` (with `after_hours`, 1 to 12, after the previous contact of the same day) |
| `condition` | `always`, `no_reply_any_channel` (the person did not reply since the previous contact), `previous_not_answered` (the previous contact was not answered) or `previous_failed` (the previous contact did not happen or failed). A band's first contact is always `always` |
| `repeat` | optional: repeat the contact over several days and several times a day (below) |

**`channel_config` by channel:**

* **`voice`**: `{"agent_id": "…"}` (calls directly through the agent) **or** `{"campaign_id": "…"}` (puts the attempt into a campaign). Never both.
* **`whatsapp`**: `{"messaging_account_id": "…", "template_id": "…", "variables": {"body:1": "name", "body:2": "amount_due"}}`. Each template variable points to a fixed field (`name`, `document`, `debt_key`, `creditor`, `currency`, `amount_due`, `overdue_amount`, `installment_amount`, `credit_limit`, `due_date`, `payment_deadline`, `days_overdue`, `overdue_installments`, `installments_total`, `collection_phase`, `risk_class`, `payment_slip`) or to a free field (`custom.<key>`). Approved Utility templates only.
* **`webhook`**: `{"url": "https://…", "http_method": "POST", "auth_scheme": "bearer", "auth_token": "…", "headers": [{"key": "X-Tenant", "value": "…"}], "payload_template": "", "timeout": 10, "max_retries": 3}`.
* **`enrich`**: `{"min_unanswered_calls": null}` or 1 to 10.

**Repetition (`repeat`):** `mode` (`single`, `daily`, `every_n` with `every` 2 to 30, `weekdays` with `weekdays` from 1 = Monday to 7 = Sunday), `to` (last day overdue), `attempts` (1 to 6 a day), `attempt_mode` (`interval` with `start_time` and `interval_minutes`, or `times` with a list of `HH:MM` times) and `stop_when` (`answered`, `replied`, `agreement`).

> [!WARNING]
>
> The webhook token and header values **never come back** in a response: they show as `{"set": true}`. To keep the stored secret, send `{"set": true}` back (or omit the field). To change it, send the new value. To remove it, send `null`.

## Examples

```bash theme={null}
curl -X PUT "https://app.talkover.ai/api/v1/cadences/01a2…/draft" \
  -H "Authorization: Bearer talq_your_environment_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "lock_version": 1,
    "name": "Card · up to 90 days",
    "filter": { "root": "and", "groups": [] },
    "agreement": { "pauses": true, "pause_days": 30, "broken_returns": true },
    "reply_pause_days": 1,
    "steps": [
      { "name": "Early", "min": 1, "max": 15, "actions": [
        { "day_offset": 1, "channel": "whatsapp", "channel_config": { "messaging_account_id": "01a1…", "template_id": "01a1…", "variables": { "body:1": "name" } }, "timing": "at_time", "at_time": "10:00", "condition": "always" },
        { "day_offset": 3, "channel": "voice", "channel_config": { "agent_id": "01a1…" }, "timing": "asap", "condition": "no_reply_any_channel" }
      ] },
      { "name": "Recovery", "min": 16, "max": null, "actions": [
        { "day_offset": 16, "channel": "voice", "channel_config": { "campaign_id": "01a1…" }, "timing": "asap", "condition": "always" }
      ] }
    ]
  }'
```

## Response

```json theme={null}
{
  "success": true,
  "message": "Draft saved.",
  "data": { "lock_version": 2, "draft": { "id": "01a2…", "number": null, "lock_version": 2, "steps": [ … ] } }
}
```

Each contact of the returned draft carries `summary`, the one-line summary the screen shows.

## Error responses

| Status | When |
| - | - |
| `404` | a cadence from another workspace |
| `409` | the draft changed after you read it (old `lock_version`) |
| `422` | invalid format (`errors` says which field) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.