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

# Example: retries by outcome

> A complete `POST /v1/campaigns` request with expert logic: its own retry interval for busy, no answer, voicemail and short calls.

# Example: retries by outcome

Each call outcome can have its own pause before the next dial: an [expert logic](https://docs.hubtalk.ai/v4/web-api/campaign-fields.md#retry-configuration) rule with the `retry_in` action and the `params.interval_s` parameter. Below is a ready request and what each part of it does.

## The whole request

The campaign is created and launched with one `POST /v1/campaigns` request.

```bash theme={null}
BASE_URL="https://app.hubtalk.ai"   # the host your cabinet runs on

curl -X POST "$BASE_URL/v1/campaigns" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: campaign-2026-10-22-01" \
  -d '{
    "name": "Payment reminder — October",
    "agent_id": "payment_reminder",
    "calls_per_minute": 10,
    "timezone": "Asia/Almaty",
    "working_hours": [
      { "days": [0, 1, 2, 3, 4], "start": "09:00", "end": "19:00" }
    ],
    "classification": "debt_collection",
    "call_strategy": "expert",
    "retry_config": {
      "attempts": 6,
      "interval_s": 3600,
      "rules": [
        { "if": "busy",              "then": "retry_in",          "params": { "interval_s": 600,  "max_matches": 3 } },
        { "if": "no_answer",         "then": "retry_in",          "params": { "interval_s": 5400, "max_matches": 2 } },
        { "if": "voicemail_reached", "then": "retry_in",          "params": { "interval_s": 7200, "max_matches": 2 } },
        { "if": "short_call",        "then": "retry_in",          "params": { "max_duration_s": 15, "interval_s": 3600 } },
        { "if": "no_speech",         "then": "wait_for_pass_end", "params": { "max_matches": 1 } },
        { "if": "user_declined",     "then": "stop_calling" }
      ]
    },
    "attestation": { "confirmed": true },
    "planned_calls": [
      { "phone": "+77001234567", "name": "Aigerim", "variables": { "debt": "15000" } },
      { "phone": "+77007654321", "name": "Daniyar", "variables": { "debt": "8200" } }
    ]
  }'
```

The answer is `201` with `campaign_id`, `status`, `blockers` and `warnings`. `status: "running"` means dialing has started; `draft` means something blocks it, and the reason is in `blockers`. The full response is in [Creating a campaign](https://docs.hubtalk.ai/v4/web-api/campaign-create.md).

## What each rule does

Each rule is a pair "if outcome → then action". The interval counts from the end of the call and, for that contact, replaces the campaign interval.

| Outcome (`if`) | Action (`then`) | After | Times per contact |
| - | - | - | - |
| `busy` — line busy | `retry_in` — redial after a pause | 10 min (`600`) | 3 |
| `no_answer` — not picked up | `retry_in` | 1 h 30 min (`5400`) | 2 |
| `voicemail_reached` — voicemail | `retry_in` | 2 h (`7200`) | 2 |
| `short_call` — conversation under 15 s (`max_duration_s`) | `retry_in` | 1 h (`3600`) | no rule limit, only the campaign `attempts` |
| `no_speech` — connected, but the contact stayed silent | `wait_for_pass_end` — redial on the next pass | — | 1 |
| `user_declined` — the contact declined the call | `stop_calling` — do not call again | — | — |

The `voicemail_reached` rule also fires on `voicemail_suppressed` — voicemail was detected, but leaving a message was not allowed. Every `if` value is a `status_reason` code from [Call outcomes](https://docs.hubtalk.ai/v4/web-api/call-status.md), plus `short_call` and `goal_not_achieved`. An outcome that no rule matches is decided by the general outcome table, as in `standard`: voicemail without a rule of its own is redialed after the campaign `interval_s` ([Call outcomes](https://docs.hubtalk.ai/v4/web-api/call-status.md#what-a-campaign-does-with-the-number-after-a-call)). That is why the example has its own `voicemail_reached` rule; once its `max_matches` is used up, voicemail is redialed by the general table while dials are left. To stop calling voicemail, use `stop_calling`.

## Rules and limits

* **`attempts` is the overall cap on dials per contact, the first one included**, 1 to 30. Rules do not extend it: when the dials run out, the contact is closed even if a rule has matches left.
* **`interval_s` of `retry_in`** is whole seconds from `60` to `86400` (1 minute to 24 hours). It is required with `retry_in` and forbidden with the other actions, otherwise `422 campaign_spec_invalid`.
* **`max_matches`** is how many times the rule may fire for one contact, 1 to 30, default 1. **`short_call` has none** — sending it there is refused with `422 campaign_spec_invalid`.
* **`max_duration_s` of `short_call`** is required, at least `10` seconds.
* **No retry on a permanent reason.** For `invalid_destination` and `spam_blocked` on every market, and for `user_declined` and `screener_declined` under the US market package, only `stop_calling` is allowed. On other markets `user_declined` is temporary and a retry on it is allowed — the example sets `stop_calling` on purpose.
* **One "condition + action" pair — once.** A duplicate is refused.
* **Expert mode without a single rule** cannot be launched: the `rules_empty` blocker.
* **The calling window, the do-not-call registry and the frequency caps** apply to every retry. A retry that does not fit before the end of the campaign (`ends_at`) is not scheduled.
* **The `rule_interval_exceeds_end` warning** means a rule interval is not shorter than the campaign window left: that retry will not happen. It does not block the launch.
* **Do not send a rule `id`** — the server assigns it (`r-xxxxxxxx`) and returns it in the response.

## For dialing to start right away

* **`Idempotency-Key`** is required, a new one for every new campaign. Repeating the request with the same key after a timeout does not create a second campaign.
* **`attestation: {"confirmed": true}`** is the contacts' consent attestation. Without it the campaign is created as a draft with the `attestation_required` blocker. See [Consent, the registry and who is responsible](https://docs.hubtalk.ai/v4/web-api/rules.md).
* **The agent is published.** Otherwise — a draft with the `agent_not_published` blocker. `agent_id` is the agent's **name**.
* **The agent has [Detect answering machines](https://docs.hubtalk.ai/v4/platform/agent-settings/voicemail-detection.md) on.** Without it there is no `voicemail_reached` outcome, and the voicemail rule never fires.
* **Do not send `trunk_id`, `route_id` and `from_number`** — the platform finds the line from the agent ([Dialing binding](https://docs.hubtalk.ai/v4/web-api/campaign-fields.md#dialing-binding)).
* **`working_hours` only narrows** the organization's calling window; a wider row → `422 working_hours_wider_than_law`.

## See also

| What | Page |
| - | - |
| Headers, request fields, `call_strategy`, order of refusals, response example | [Creating a campaign](https://docs.hubtalk.ai/v4/web-api/campaign-create.md) |
| `retry_config` and rules: `if`, `then`, `params` | [Campaign fields → Retry configuration](https://docs.hubtalk.ai/v4/web-api/campaign-fields.md#retry-configuration) |
| Outcome codes for `if` | [Call outcomes](https://docs.hubtalk.ai/v4/web-api/call-status.md) |
| Launch blockers and warnings | [Campaign object](https://docs.hubtalk.ai/v4/web-api/campaign-object.md) |
| Expert logic in the cabinet | [Campaign launch](https://docs.hubtalk.ai/v4/platform/campaign-launch.md) |


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