Skip to Content

Asynchronous workflows

Some operations commit intent now and finish later — here's the one polling loop that handles all of them.

Provisioning a SIP trunk, placing an outbound call, running an eval: these commit durable intent immediately and finish in the background. The initial response identifies the resource to poll; a 2xx on the create is not workflow success.

The loop is always the same:

  1. POST with an Idempotency-Key; persist the returned ID/URL and the key.
  2. Wait — at least Retry-After seconds when present, otherwise bounded exponential backoff with jitter.
  3. GET the point resource (the Location header is the canonical poll target); record its status and any stable failure code.
  4. Stop on a terminal status.
WorkflowPollTerminal states
SIP trunk provisioningGET /sip-trunks/{id}active, error, archived
Phone-number connectionGET /phone-numbers/{id}active, error, archived
Outbound calling (202 job)GET /outbound-jobs/{id}completed, canceled, failed, expired
Live context injection (202)GET /calls/{id}, match the message ID in data_messagesmessage delivery state terminal
Webhook test/replayGET /webhook-deliveries/{id}terminal delivery status
Transfer cancellationGET /transfers/{id}transfer state is authoritative; provider ambiguity leaves it nonterminal (502/503/504)
Call purge (202)GET /calls/{id}, inspect purge_cleanupall cleanup counts terminal
Eval scenario generation (202)GET /eval-generation-jobs/{id}done, failed
Eval run (202)GET /eval-runs/{id}documented terminal status; cancel with POST /eval-runs/{id}/cancel

The rules that prevent duplicates

  • A client timeout does not cancel committed work. Retry the exact POST with the same idempotency key; if the API replays, continue from the returned resource. To actually stop a durable outbound job, use its cancel operation — dropping the connection is not cancellation.
  • Never create a second resource to recover an ambiguous first one. Replay the original create, read what it returns, proceed from there.
  • Repair, don't recreate. POST /sip-trunks/{id}/reconcile and POST /phone-numbers/{id}/reconcile re-sync provider state from committed configuration or retry eligible failed provisioning. They take no body, support idempotency, and can answer 409 + Retry-After while a recent operation is still active.

Failure information is sanitized

Async resources expose stable failure codes and safe messages — raw provider output (which can contain credentials, SIP headers, or phone numbers) is withheld unless a separately audited permission grants it. Branch on the stable code, never on a provider string.

On this page