# Webhooks

Set `webhook_url` when creating a Call. Delivery includes the final result
snapshot, not just the moment the phone first ends.
A rejected creation request does not produce a terminal webhook.

Terminal delivery occurs once `result_status` is no longer `pending`;
an unavailable result can have both `result` and `error` null, and ordinary
no-answer, busy or declined outcomes use `call.completed`.

## Payload and events

The envelope contains `id`, `type`, `created_at` and `data`. `data` matches the
ready Call returned by GET and has `object: "call"`.

`data.transcript` is always an array with the same recorded turns as GET.
Business result errors do not remove it; no available transcript is represented
by `[]`.

| Event | Interpretation |
| --- | --- |
| `call.completed` | Telephone execution completed; inspect `data.call_outcome`, `data.result_status`, `data.result` and `data.error`. |
| `call.failed` | Execution failed. |
| `call.canceled` | The Call was canceled before provider submission. |

A completed call with a result-processing error still uses `call.completed`.
The current call contract does not use `call.result_validation_failed`; inspect
`error.code`, such as `result_invalid`.

Response envelope, with an abbreviated `data` object:

```json
{
  "id": "evt_example",
  "type": "call.completed",
  "created_at": "2026-09-21T02:00:00Z",
  "data": {
    "id": "call_example",
    "call_id": "0123456789abcdef0123456789abcdef",
    "object": "call",
    "status": "completed",
    "call_outcome": "completed",
    "result_status": "available",
    "transcript": [{"speaker": "bot", "offset_seconds": 0, "text": "Hello."}],
    "result": {"greeting_delivered": true},
    "error": null
  }
}
```

## Receiver behavior

Return a `2xx` response after durably accepting the event. Delivery can repeat;
the sender makes up to six attempts with the same event ID. Use the event ID
for deduplication, not the timestamp or phone number.

The webhook event ID is separate from your create request's `Idempotency-Key`.
Process repeated deliveries once; do not create another Call in response to a
delivery retry. ASR and speech updates are read from
[Call events](/calls#read-events-and-cancellation), not pushed to this terminal webhook.

`CALL-E-Event-Id` must match the envelope `id`. This is a consistency check,
not a cryptographic signature. The current delivery path does not supply
`CALL-E-Signature` or a webhook signing secret. Before a sensitive side effect,
fetch the original Call with your API key and compare its ready snapshot.

## Existing receivers

When migrating, use separate receiver paths or dispatch on `data.object`:

```ts
if (event.data.object === "call") {
  handleCallResult(event.data.call_outcome, event.data.result_status, event.data.result, event.data.error);
} else if (event.data.object === "call_task") {
  handleLegacyResult(event.data.structured_result);
}
```

`handleCallResult` and `handleLegacyResult` are application handlers, not SDK
exports. Both interfaces can send `call.completed`, so event type alone cannot
identify the payload format. Keep the [legacy receiver](/legacy-webhooks) available for
call tasks accepted before the cutover. Switching new requests does not rewrite
old webhook payloads or call records.
