Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion agents/build/dynamic-variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
and they are on the {{plan}} plan. Greet them by name.
```

Pass values as a flat object of strings, numbers, or booleans. Variable names must match `[A-Za-z][A-Za-z0-9_]*` (no hyphens or dots; the dotted `system.*` names are reserved for [system variables](#system-variables)), string values are capped at 100,000 characters, and a request can carry at most 500 variables totaling 1 MiB as UTF-8 JSON. Violations reject session creation with `422`:

Check warning on line 38 in agents/build/dynamic-variables.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/build/dynamic-variables.mdx#L38

Did you really mean 'booleans'?

<CodeGroup>
```bash API (curl)
Expand Down Expand Up @@ -127,7 +127,7 @@
```

<Tip>
In `agentId` mode, values arrive from the end user's browser. Treat them as untrusted input, and use `sessionToken` mode when personalization must come from data only your backend knows.

Check warning on line 130 in agents/build/dynamic-variables.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/build/dynamic-variables.mdx#L130

Did you really mean 'untrusted'?
</Tip>

### Custom variables in webhook tools
Expand All @@ -138,18 +138,18 @@
https://ehr.example.com/patients/{{patient_id}}/appointments?clinic={{clinic_id}}
```

- In the URL the value is URL-encoded, like argument values. In header values it is inserted as is. Numbers render as written, booleans as `true` or `false`.

Check warning on line 141 in agents/build/dynamic-variables.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/build/dynamic-variables.mdx#L141

Did you really mean 'booleans'?
- In a JSON body, a value inside a string is JSON-escaped, like argument values. See [Values in a JSON body](/agents/build/webhook-tools#values-in-a-json-body).
- When the tool declares an argument with the same name as a custom variable, the argument wins: that placeholder is filled from what the agent supplies.
- A placeholder with no value renders as an empty string in the request, unlike in the prompt, where it stays visible.

<Warning>
On a [public agent](/agents/deploy/public-agents) the browser supplies custom values, so anyone can start a session with any `patient_id`. When a templated value identifies a person, don't let it authorize access to their data on its own: create sessions from your backend (`sessionToken` mode), or let the inbound call webhook supply it on phone calls.

Check warning on line 147 in agents/build/dynamic-variables.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/build/dynamic-variables.mdx#L147

Did you really mean 'templated'?
</Warning>

## System variables

The platform fills a handful of `{{system.*}}` placeholders itself, on every session. You cannot supply or override them: the names you pass in `dynamic_variables` cannot contain a dot, so the two namespaces never collide.

Check warning on line 152 in agents/build/dynamic-variables.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/build/dynamic-variables.mdx#L152

Did you really mean 'namespaces'?

| Variable | Value | Notes |
|---|---|---|
Expand All @@ -157,11 +157,11 @@
| `system.timezone` | The session's resolved IANA timezone, for example `Asia/Tokyo` | `UTC` when nothing resolves. Always equals the session's `timezone` field; see [which timezone a session uses](/agents/build/time-timezone#which-timezone-a-session-uses). |
| `system.today` | Today's date in that timezone, ISO 8601 `YYYY-MM-DD` | The calendar date at session creation. There is no `system.now`; see [Current date and time](#current-date-and-time). |
| `system.language` | The session language code, one of the [52 supported languages](/agents/build/voice-language#speaking-language) | The `language` [override](/agents/deploy/authenticated-sessions#overrides) when the request carries one, otherwise the agent's [speaking language](/agents/build/voice-language#speaking-language). |
| `system.caller_number` | The human party's number, E.164 | Inbound: the caller (empty if the carrier withheld the number, for example `anonymous` or one of Twilio's placeholder numbers, or it is not a valid E.164 number). Outbound: the number you dialed. Empty on non-phone sessions. |

Check warning on line 160 in agents/build/dynamic-variables.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/build/dynamic-variables.mdx#L160

Did you really mean 'Twilio's'?
| `system.caller_id_withheld` | `"true"` or `"false"` (text, like every system variable) | `"true"` when an inbound caller's number was withheld, `"false"` for an inbound call with a number, an outbound call, and a WhatsApp call. Empty on non-phone sessions. See [Phone numbers](#phone-numbers). |
| `system.caller_number_spoken` | The same number written for speech, for example `+1; 4 1 5; 5 5 5; 0 1 2 3` | Use it wherever the agent should say the number out loud; see [Reading a number out loud](#reading-a-number-out-loud). Empty whenever `system.caller_number` is empty. |
| `system.dialed_number` | Your workspace number, E.164 | Inbound: the number that was called. Outbound: the number the call was placed from. Empty on non-phone sessions. |
| `system.session_id` | The session's id, for example `sess_5f3e…` | Send it from a [webhook tool](#in-webhook-tools) to tie each tool call to its session. Outside the agent, the same id is in the `POST /v1/agent/sessions` [response](/agents/deploy/authenticated-sessions), the SDK's `connect` event, and `session.id` in [post-call webhooks](/agents/monitor/webhooks), and [`GET /v1/agent/sessions/{session_id}`](/agents/monitor/conversation-history#get-a-session) accepts it. |
| `system.session_id` | The session's id, for example `sess_5f3e…` | Send it from a [webhook tool](#in-webhook-tools) to tie each tool call to its session. Outside the agent, the same id is in the `POST /v1/agent/sessions` [response](/agents/deploy/authenticated-sessions), the SDK's `connect` event, and `session.session_id` in [post-call webhooks](/agents/monitor/webhooks), and [`GET /v1/agent/sessions/{session_id}`](/agents/monitor/conversation-history#get-a-session) accepts it. |

### Reading a number out loud

Expand Down Expand Up @@ -191,7 +191,7 @@

#### Withheld caller ID

A caller can hide their number. The carrier then sends no digits (`anonymous`, `restricted`, an empty value) or one of the placeholder numbers Twilio sends in place of a hidden one. All of these count as withheld: `system.caller_number` and `system.caller_number_spoken` are empty, and `system.caller_id_withheld` is `"true"`. An empty `system.caller_number` alone does not tell you why, since it is also empty on non-phone sessions; `system.caller_id_withheld` does, because it is `"true"` only when a caller on a phone call hid their number.

Check warning on line 194 in agents/build/dynamic-variables.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/build/dynamic-variables.mdx#L194

Did you really mean 'Twilio'?

When the number is withheld, the agent cannot match the caller to a customer record by number, so have it ask who is calling:

Expand Down Expand Up @@ -231,7 +231,7 @@

## Current date and time

With the agent's `context.current_time` switch on, the agent knows the current date and time without any variable: the platform states the date and the session's timezone at the start of every session and refreshes the time on every turn, so "tomorrow morning" or "next Tuesday" resolve correctly even in a long conversation. You don't need a custom `{{today}}` or `{{now}}`, and there is no `system.now`: variables render once, when the session is created, so a templated time would be stale from the first reply onward. When you want the date or timezone as text in a template, for example in a webhook tool URL, use the [`system.today` and `system.timezone`](#system-variables) system variables, which work whether the switch is on or off.

Check warning on line 234 in agents/build/dynamic-variables.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/build/dynamic-variables.mdx#L234

Did you really mean 'templated'?

See [Time & timezone](/agents/build/time-timezone) for how the timezone is resolved and how the switch works per agent and per session.

Expand Down
4 changes: 2 additions & 2 deletions agents/monitor/conversation-history.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
icon: "clock-rotate-left"
---

Every production session your agents handle (from the API, the console, [public agents](/agents/deploy/public-agents), or [phone calls](/agents/telephony/inbound-calls)) is queryable over REST: a lightweight list for browsing, a merged timeline of messages and tool activity per session, and per-speaker recordings when the agent [records audio](#what-gets-stored). You can query a session while the call is still in progress.

Check warning on line 8 in agents/monitor/conversation-history.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/conversation-history.mdx#L8

Did you really mean 'queryable'?

This is a server-side API: authenticate with your API key. The client SDKs deliberately expose no history interface; fetch history from your backend and pass it to your frontend as needed.

Check warning on line 10 in agents/monitor/conversation-history.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/conversation-history.mdx#L10

Did you really mean 'SDKs'?

## What gets stored

Expand Down Expand Up @@ -63,14 +63,14 @@
"dialed_number": "+14155550100",
"sip_call_id": "7f3a9c@sbc.example.com",
"call_sid": "CA5d3a…",
"started_at": "2026-07-22T09:14:02Z",
"ended_at": "2026-07-22T09:16:05Z",
"started_at": "2026-07-22T09:14:02+00:00",
"ended_at": "2026-07-22T09:16:05+00:00",
"duration_seconds": 123,
"metadata": { "crm_ticket": "T-4821" }
}
],
"has_more": true,

Check warning on line 72 in agents/monitor/conversation-history.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/conversation-history.mdx#L72

Did you really mean 'has_more'?
"next_cursor": "…"

Check warning on line 73 in agents/monitor/conversation-history.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/conversation-history.mdx#L73

Did you really mean 'next_cursor'?
}
```

Expand Down Expand Up @@ -200,7 +200,7 @@

Details worth knowing:

- **Role vocabulary**: the history API's `assistant` is the same speaker the [SDK's live events](/agents/deploy/web-sdk) call `agent`.

Check warning on line 203 in agents/monitor/conversation-history.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/conversation-history.mdx#L203

Did you really mean 'API's'?
- **Order**: items are sorted by `created_at` ascending; a `tool_result`'s timestamp is its completion time, so long-running tools appear where they actually finished, with messages in between. Items sharing a timestamp order `message`, then `tool_call`, then `tool_result`.
- **`tool_source`**: where the tool ran, one of `client`, `webhook`, `builtin` (platform tools such as call transfer and hang-up), `mcp` (tools from a connected MCP server), `background` (work the agent delegated to a background task), or `unknown` (calls recorded before source attribution). Treat it as an open set. See [Tools](/agents/build/tools).
- **Payloads**: `input` and `output` are JSON strings, symmetric with the live SDK events, so one parser covers both. `output` and `error` are stored up to 256 KB; beyond that the text is cut and `output_truncated` is `true`.
Expand Down
40 changes: 31 additions & 9 deletions agents/monitor/webhooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
| Field | Rules |
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `post_call` | Up to 5 entries, and their `url` values must be unique. A longer list or a repeated URL is rejected with `422` |
| `url` | Required on every entry. Up to 4000 characters. Must resolve to a public address. Localhost, private-network hosts and hostnames that only a private network could resolve (single-label names, names under `.local`, `.internal`, `.svc` or `.arpa`) are rejected with `422`, and the check is repeated at every delivery |

Check warning on line 85 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L85

Did you really mean 'hostnames'?
| `secret` | Optional signing key, up to 256 characters, set per entry. **Write-only**: reads return `has_secret: true`, never the value. Omit it (or send `null`) to keep the stored secret for the same `url`; send `""` to remove it |

<Note>
Expand All @@ -93,7 +93,7 @@

## Payload

Every payload carries the `event` name, a unique `event_id`, and a `session` object with the session facts. Note the field names differ from the [sessions API](/agents/monitor/conversation-history), which uses `session_id` / `started_at` / `ended_at` for the same facts. `call.ended` adds `ended_reason` and `llm_endpoint_errors`. `call.analyzed` adds the `analysis` entity and the transcript `items`. `phone_call.dial_finished` adds top-level `dial_status` and `answered_by`. The `session` object is the same on every event. The `phone_call.dial_finished` example shows it in full, the others are shortened.
Every payload carries the `event` name, a unique `event_id`, and a `session` object with the session facts. `session_id`, `started_at` and `ended_at` use the same names and carry the same values as the [sessions API](/agents/monitor/conversation-history), apart from the time format described [below](#session-fields-and-the-sessions-api). `call.ended` adds `ended_reason` and `llm_endpoint_errors`. `call.analyzed` adds the `analysis` entity and the transcript `items`. `phone_call.dial_finished` adds top-level `dial_status` and `answered_by`. The `session` object is the same on every event. The `phone_call.dial_finished` example shows it in full, the others are shortened.

<CodeGroup>

Expand All @@ -103,21 +103,24 @@
"event_id": "evt_3f9c2a7b5d1e4f60a8b9c0d1e2f3a4b5",
"session": {
"id": "sess_5f3e…",
"session_id": "sess_5f3e…",
"agent_id": "a1b2…",
"branch_id": "b7d4…",
"source": "phone",
"status": "completed",
"end_reason": "user_hangup",

Check warning on line 111 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L111

Did you really mean 'user_hangup'?
"conversation_started_at": "2026-07-23T12:01:12Z",
"conversation_ended_at": "2026-07-23T12:04:16Z",
"started_at": "2026-07-23T12:01:12Z",
"ended_at": "2026-07-23T12:04:16Z",
"duration_seconds": 184,
"end_user_id": "customer-42",
"metadata": { "order_ref": "SO-1042" },
"agent_name": "Support agent",

Check warning on line 119 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L119

Did you really mean 'agent_name'?
"config_hash": "sha256:9c41…"

Check warning on line 120 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L120

Did you really mean 'config_hash'?
},
"ended_reason": "user_hangup",

Check warning on line 122 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L122

Did you really mean 'ended_reason'?
"llm_endpoint_errors": []

Check warning on line 123 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L123

Did you really mean 'llm_endpoint_errors'?
}
```

Expand All @@ -127,12 +130,15 @@
"event_id": "evt_8a41d0c97e2b4f13b6c5a9d8e7f60123",
"session": {
"id": "sess_5f3e…",
"session_id": "sess_5f3e…",
"agent_id": "a1b2…",
"branch_id": "b7d4…",
"source": "phone",
"status": "completed",
"conversation_started_at": "2026-07-23T12:01:12Z",
"conversation_ended_at": "2026-07-23T12:04:16Z",
"started_at": "2026-07-23T12:01:12Z",
"ended_at": "2026-07-23T12:04:16Z",
"duration_seconds": 184,
"end_user_id": "customer-42",
"metadata": { "order_ref": "SO-1042" },
Expand Down Expand Up @@ -181,6 +187,7 @@
"answered_by": "human",
"session": {
"id": "sess_5f3e…",
"session_id": "sess_5f3e…",
"agent_id": "a1b2…",
"branch_id": "b7d4…",
"source": "phone",
Expand All @@ -196,6 +203,8 @@
"batch_call_id": null,
"conversation_started_at": "2026-07-23T12:01:12Z",
"conversation_ended_at": null,
"started_at": "2026-07-23T12:01:12Z",
"ended_at": null,
"duration_seconds": null,
"end_user_id": "",
"metadata": { "lead_ref": "L-2041" },
Expand All @@ -215,16 +224,29 @@

`call.ended` also carries `llm_endpoint_errors`. It lists the failures of your [custom LLM](/agents/build/custom-llm#see-what-your-endpoint-returned) endpoint during the session, in the same shape as the [sessions API](/agents/monitor/conversation-history#llm-endpoint-errors). It is empty on platform models. It is `null` in the rare case the list could not be read at delivery time.

`dial_status` is `answered`, `busy`, `no_answer`, or `failed`. `answered_by` is deprecated: answering-machine detection has been removed, so it is `unknown` once the call is answered and `null` before (older events may carry `human` or `voicemail`). Both facts also appear on the session, alongside `direction` (`inbound` or `outbound`) and `batch_call_id` (reserved, always `null` today); these session fields are present in every webhook payload, with the dial fields `null` on inbound sessions. The `phone_call.dial_finished` snapshot is taken when the dial resolves, so on an answered call `conversation_ended_at` and `duration_seconds` are still `null`. The final numbers arrive with `call.ended`.
`dial_status` is `answered`, `busy`, `no_answer`, or `failed`. `answered_by` is deprecated: answering-machine detection has been removed, so it is `unknown` once the call is answered and `null` before (older events may carry `human` or `voicemail`). Both facts also appear on the session, alongside `direction` (`inbound` or `outbound`) and `batch_call_id` (reserved, always `null` today); these session fields are present in every webhook payload, with the dial fields `null` on inbound sessions. The `phone_call.dial_finished` snapshot is taken when the dial resolves, so on an answered call `ended_at` and `duration_seconds` are still `null`. The final numbers arrive with `call.ended`.

`caller_number`, `dialed_number` and `sip_call_id` carry the same values as on the [sessions API](/agents/monitor/conversation-history): the E.164 numbers of the call (person-centric on outbound calls, so `caller_number` is the party you dialed) and the SIP `Call-ID` of the call's INVITE. All three are empty strings on web sessions, and `sip_call_id` is also empty on an unanswered outbound dial. `caller_id_withheld` is `true` when the carrier hid the caller's number; `caller_number` is then an empty string. It is `false` on phone and WhatsApp sessions whose number was shown, on outbound calls, and on calls made before the field existed, and `null` on web and other non-call sessions. It is in every `call.ended`, `call.analyzed` and `phone_call.dial_finished` payload, even where the shortened examples leave it out. How to use it against your carrier's records: [Match calls with your SIP records](/agents/telephony/byo-sip#match-calls-with-your-sip-records).

`call_sid` is the carrier's id of the call. Today that is Twilio's CallSid on an inbound call through a Twilio number. It is the same value the [inbound call webhook](#inbound-call-webhook) request carries, so you can join that request to the session. It is an empty string on web sessions, outbound calls, and calls through your own SIP trunk.

Check warning on line 231 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L231

Did you really mean 'Twilio's'?

Check warning on line 231 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L231

Did you really mean 'Twilio'?

`end_user_id` and `metadata` are echoed exactly as you set them when creating the session. Use them to correlate the event with records in your own system. `branch_id` is an internal configuration-lineage identifier and is safe to ignore. What lands in `summary`, `data`, and `criteria_results` is defined by your [analysis configuration](/agents/monitor/post-call-analysis).
`end_user_id` and `metadata` are echoed exactly as you set them when creating the session. Use them to correlate the event with records in your own system. `branch_id` is deprecated. It is an internal configuration-lineage identifier and is safe to ignore, and it is still sent. What lands in `summary`, `data`, and `criteria_results` is defined by your [analysis configuration](/agents/monitor/post-call-analysis).

The example shows a `completed` analysis. `analysis.status` can also be `skipped` (nothing to analyze: the caller never spoke, or analysis is disabled) or `error` (the run failed, with the cause in `analysis.error`); both arrive with `summary: null` and empty `data` / `criteria_results`. Check the status before reading results.

### Session fields and the sessions API

`session_id`, `started_at` and `ended_at` are the same facts under the same names as in the [sessions API](/agents/monitor/conversation-history). The three older names are deprecated. They carry the same values and are still sent:

| Deprecated field | Use instead | Notes |
| ------------------------- | ------------ | ------------------------------------------------------------ |
| `id` | `session_id` | Same value as `session_id`, still sent. |
| `conversation_started_at` | `started_at` | Same value as `started_at`, still sent. |
| `conversation_ended_at` | `ended_at` | Same value as `ended_at`, still sent. |
| `branch_id` | None | Internal identifier, safe to ignore. Deprecated, still sent. |

The times are the same instants as in the sessions API but are written differently. A webhook writes UTC with a `Z` suffix, for example `2026-07-23T12:01:12Z`. The sessions API writes the same instant with a numeric offset, for example `2026-07-23T12:01:12+00:00`. Parse both into timestamps before you compare them, because comparing the strings will not match. Like `conversation_ended_at`, `ended_at` is `null` until the end time is known.

## Verify the signature

When an entry has a `secret`, every request to that endpoint carries a signature header with the send time and an HMAC-SHA256 of `{timestamp}.{raw_body}`, keyed with that entry's own secret:
Expand Down Expand Up @@ -335,11 +357,11 @@
published agent.
</Note>

### Idempotency

Check warning on line 360 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L360

Did you really mean 'Idempotency'?

At-least-once delivery means the same event can arrive more than once. Retries of one event carry an identical body, so store each `event_id` you process and drop any event whose `event_id` you have already seen.

A skipped or failed analysis can be re-run from the console. The recovered result arrives as a new `call.analyzed` with a new `event_id` and a newer `analysis.finished_at`. It supersedes the earlier one, so keep the `call.analyzed` with the latest `finished_at` for each `session.id`.
A skipped or failed analysis can be re-run from the console. The recovered result arrives as a new `call.analyzed` with a new `event_id` and a newer `analysis.finished_at`. It supersedes the earlier one, so keep the `call.analyzed` with the latest `finished_at` for each `session.session_id`.

### Forward compatibility

Expand Down Expand Up @@ -399,19 +421,19 @@
}
```

`caller_number` and `dialed_number` are E.164. `caller_number` is an empty string when the carrier withholds the caller's number, and `caller_id_withheld` is a boolean that says so: `true` when the number is withheld, `false` otherwise. Withheld means the carrier sent no digits (`anonymous`, `restricted`, an empty value) or one of the placeholder numbers Twilio uses when it has none, so a placeholder never reaches you as a number. When it is `true`, skip the lookup by number in your endpoint; the agent can ask who is calling instead, see [Withheld caller ID](/agents/build/dynamic-variables#withheld-caller-id). `call_sid` is empty when the call did not come through a Twilio number.

Check warning on line 424 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L424

Did you really mean 'Twilio'?

Check warning on line 424 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L424

Did you really mean 'Twilio'?

To match this request with the call, keep `session_id`. It is the id the call's session gets once the call connects, the same value you see elsewhere:

- `session_id` in the [sessions API](/agents/monitor/conversation-history)
- `session.id` in post-call webhooks
- `session.session_id` in post-call webhooks (`session.id` carries the same value and is deprecated)
- `{{system.session_id}}` in [webhook tools](/agents/build/webhook-tools)

For calls through a Twilio number, `call_sid` works too: `GET /v1/agent/sessions?call_sid=…` returns the session. New fields can be added to this request, see [Forward compatibility](#forward-compatibility).

Check warning on line 432 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L432

Did you really mean 'Twilio'?

### Response

Respond with a `2xx` status and a JSON object whose `dynamic_variables` follow the same rules as on session creation: names match `[A-Za-z][A-Za-z0-9_]*`, values are strings (up to 100,000 characters), numbers, or booleans, and at most 500 entries totaling 1 MiB are read.

Check warning on line 436 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L436

Did you really mean 'booleans'?

```json Response
{
Expand Down Expand Up @@ -450,7 +472,7 @@

## Auto-ticket unresolved calls

`call.analyzed` closes the loop on conversations the agent couldn't: judge every call with a success criterion, and open a ticket in your helpdesk whenever the verdict isn't `success`.

Check warning on line 475 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L475

Did you really mean 'helpdesk'?

First give the agent's [analysis configuration](/agents/monitor/post-call-analysis) a criterion that captures resolution:

Expand Down Expand Up @@ -492,7 +514,7 @@
if (payload.analysis.status !== "completed") {
// skipped (the caller never spoke) or error: no verdict to trust.
openTicket({
subject: `Unjudged call ${payload.session.id}`,
subject: `Unjudged call ${payload.session.session_id ?? payload.session.id}`,
body:
`Analysis ${payload.analysis.status}` +
(payload.analysis.error ? `: ${payload.analysis.error}` : ""),
Expand All @@ -507,7 +529,7 @@
if (!verdict || verdict.result === "success") return;

openTicket({
subject: `Unresolved call ${payload.session.id}`,
subject: `Unresolved call ${payload.session.session_id ?? payload.session.id}`,
body:
`${payload.analysis.summary}\n\n` +
`issue_resolved: ${verdict.result}. ${verdict.rationale}`,
Expand Down Expand Up @@ -550,7 +572,7 @@
# skipped (the caller never spoke) or error: no verdict to trust.
detail = f": {analysis['error']}" if analysis.get("error") else ""
open_ticket(
subject=f"Unjudged call {payload['session']['id']}",
subject=f"Unjudged call {payload['session'].get('session_id') or payload['session']['id']}",
body=f"Analysis {analysis['status']}{detail}",
customer=payload["session"]["end_user_id"],
)
Expand All @@ -560,7 +582,7 @@
verdict = next((c for c in results if c["name"] == "issue_resolved"), None)
if verdict and verdict["result"] != "success":
open_ticket(
subject=f"Unresolved call {payload['session']['id']}",
subject=f"Unresolved call {payload['session'].get('session_id') or payload['session']['id']}",
body=f"{analysis['summary']}\n\n"
f"issue_resolved: {verdict['result']}. {verdict['rationale']}",
customer=payload["session"]["end_user_id"],
Expand All @@ -570,11 +592,11 @@

</CodeGroup>

`verifyWebhook` is the function from [Verify the signature](#verify-the-signature); `openTicket` stands in for your helpdesk's API. Escalating on anything but `success` includes `unknown` verdicts: the model couldn't judge the call, which usually deserves human eyes too. Tighten the check to `failure` only if unknowns prove noisy.

Check warning on line 595 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L595

Did you really mean 'helpdesk's'?

Edges worth handling:

- Calls with nothing to analyze arrive with `analysis.status: "skipped"`. The handler above tickets them as unjudged, so every call reaches the helpdesk without also watching `call.ended`. Drop that branch if silent calls don't belong in your queue.

Check warning on line 599 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L599

Did you really mean 'unjudged'?

Check warning on line 599 in agents/monitor/webhooks.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/monitor/webhooks.mdx#L599

Did you really mean 'helpdesk'?
- To include the transcript in the ticket, read it from `payload.items`. When `items` is `null`, fetch `GET /v1/agent/sessions/{session_id}` from your handler instead. See [conversation history](/agents/monitor/conversation-history).
- Set `end_user_id` and `metadata` when creating sessions so tickets attach to the right customer record without a lookup.

Expand Down
2 changes: 1 addition & 1 deletion agents/telephony/byo-sip.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

If your numbers already live at a carrier, you can connect them to your agents without porting anything. Point the carrier's SIP trunk at Fish Audio and import the number: it stays with your carrier, who keeps billing you for the telephone-network legs, and on Fish Audio the calls bill as ordinary agent sessions. Imported numbers carry no monthly rental and no telephony charges of any kind: no phone surcharge, no transfer fees; the call bills like a web session.

This works with any carrier or PBX that speaks SIP trunking: Twilio Elastic SIP Trunking, Asterisk or FreePBX, and most SIP providers. It is also the only way to use non-US/CA numbers, which the purchasable inventory does not cover.

Check warning on line 10 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L10

Did you really mean 'Twilio'?

## How it works

A SIP trunk has two directions, and carriers name them from the carrier's point of view. **Origination** is traffic your carrier originates towards Fish Audio: an inbound call. **Termination** is traffic your carrier terminates for Fish Audio: an outbound call the platform hands to your carrier or PBX to complete. Twilio's trunk configuration uses the same two words, and so do the fields below.

Check warning on line 14 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L14

Did you really mean 'Twilio's'?

- **Inbound (origination)**: your carrier routes calls for the number over its trunk to Fish Audio's SIP endpoint. The platform matches the dialed number and hands the call to the agent bound to it. From there it is a normal [inbound call](/agents/telephony/inbound-calls).
- **Outbound (termination)**, optional: give the import a termination host and the platform can also place calls from the number. Outbound calls and warm-transfer consult legs dial out through your trunk, with the imported number as the caller ID. You can also attach custom SIP headers that every call through the termination carries, for routing hints or tenant identification on your PBX.
Expand Down Expand Up @@ -90,30 +90,30 @@
The SIP endpoint is shared, so an import must prove that calls really come from your trunk:

- **Digest credentials**: the platform challenges your trunk and verifies the username and password. Use this whenever your carrier or PBX answers digest challenges (Asterisk, FreePBX, most SIP providers).
- **Allowed source addresses**: calls are only accepted from the listed IPs or CIDR ranges. Use this for carriers that do not authenticate their origination traffic; Twilio Elastic SIP Trunking is one, so for Twilio this is the required factor.

Check warning on line 93 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L93

Did you really mean 'IPs'?

Check warning on line 93 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L93

Did you really mean 'Twilio'?

Check warning on line 93 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L93

Did you really mean 'Twilio'?

Set both when your carrier supports it.

## Carrier walkthroughs

Check warning on line 97 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L97

Did you really mean 'walkthroughs'?

### Twilio Elastic SIP Trunking

Check warning on line 99 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L99

Did you really mean 'Twilio'?

<Steps>
<Step title="Create a trunk">
In the Twilio console, under **Elastic SIP Trunking**, create a trunk (or

Check warning on line 103 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L103

Did you really mean 'Twilio'?
reuse an existing one).
</Step>
<Step title="Point origination at Fish Audio">
Add an origination URI: `sip:1pv316az391.sip.livekit.cloud;transport=tcp`.
</Step>
<Step title="Attach your number">
On the trunk's **Numbers** tab, add the phone number. Twilio routes its

Check warning on line 110 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L110

Did you really mean 'Twilio'?
calls through the trunk from then on.
</Step>
<Step title="Import on Fish Audio">
Twilio's origination does not answer digest challenges, so authenticate by

Check warning on line 114 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L114

Did you really mean 'Twilio's'?
source address: allow Twilio's published signaling IP ranges for the regions

Check warning on line 115 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L115

Did you really mean 'Twilio's'?
you use (see [Twilio's IP address

Check warning on line 116 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L116

Did you really mean 'Twilio's'?
list](https://www.twilio.com/docs/sip-trunking/ip-addresses)). In the
console, the **Twilio Elastic SIP Trunking preset** button fills the ranges
and sets the transport for you.
Expand All @@ -123,13 +123,13 @@
(`yourprefix.pstn.twilio.com`) and attach a **Credential List**. Pass the
host as `termination_uri` and the credentials as `termination_auth_username`
and `termination_auth_password`. Credentials are required here: Fish Audio's
outbound traffic does not come from fixed IPs, so Twilio IP access control

Check warning on line 126 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L126

Did you really mean 'IPs'?

Check warning on line 126 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L126

Did you really mean 'Twilio'?
lists cannot authorize it.
</Step>
<Step title="Allow transfers (optional)" id="twilio-allow-transfers">
For [cold transfers](/agents/telephony/transfers), enable **Call Transfer
(SIP REFER)** in the trunk's settings and also allow transfers to the PSTN.
If transfers are limited to SIP destinations, Twilio rejects every transfer

Check warning on line 132 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L132

Did you really mean 'Twilio'?
to a phone number, so transfers to phone numbers won't work. To choose the
caller ID your team sees on a cold transfer, set **Caller ID for Transfer
Target**: **Transferee** shows the caller's number, **Transferor** shows
Expand All @@ -140,7 +140,7 @@
### Asterisk, FreePBX, and other SIP platforms

- Route the number's inbound calls to `sip:1pv316az391.sip.livekit.cloud;transport=tcp`.
- Configure digest credentials on the trunk and pass the same pair as `inbound_auth_username` and `inbound_auth_password`; add your PBX's public IPs to `inbound_allowed_addresses` for defense in depth.

Check warning on line 143 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L143

Did you really mean 'PBX's'?

Check warning on line 143 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L143

Did you really mean 'IPs'?
- For outbound, expose a termination host reachable from the internet and pass it as `termination_uri`, with digest credentials if your PBX requires registration or authentication.

## Outbound calls and transfers
Expand All @@ -160,7 +160,7 @@

Imported numbers don't have the [caller ID choice](/agents/telephony/transfers#caller-id-on-transfers) that bought numbers have. Instead:

- **Cold transfers** show whatever your carrier sends. On Twilio, you set this on the trunk with **Caller ID for Transfer Target** (see [Allow transfers](#twilio-allow-transfers) in the Twilio steps above).

Check warning on line 163 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L163

Did you really mean 'Twilio'?

Check warning on line 163 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L163

Did you really mean 'Twilio'?
- **Warm transfers** always show your imported number.

### Custom SIP headers
Expand Down Expand Up @@ -213,7 +213,7 @@
"event": "phone_call.dial_finished",
"dial_status": "answered",
"session": {
"id": "5f3e…",
"session_id": "sess_5f3e…",
"caller_number": "+15551234567",
"dialed_number": "+14155550100",
"sip_call_id": "7f3a9c@sbc.example.com",
Expand Down Expand Up @@ -242,7 +242,7 @@
}'
```

The body is the import payload without `phone_number`, `label`, and `agent_id`, and it replaces the whole configuration. Three things to know:

Check warning on line 245 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L245

Did you really mean 'phone_number'?

Check warning on line 245 in agents/telephony/byo-sip.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/byo-sip.mdx#L245

Did you really mean 'agent_id'?

- An empty password next to a set username keeps the stored password, so you can edit other fields without re-entering secrets. Setting a username for the first time requires a password.
- An empty `termination_uri` removes the termination and makes the number inbound-only again.
Expand Down
6 changes: 3 additions & 3 deletions agents/telephony/inbound-calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@
| Field | Description |
| --------------- | --------------------------------------------------------------------------- |
| `caller_number` | The caller's number, E.164. `null` for non-phone sessions, and when the caller's number was withheld. |
| `caller_id_withheld` | `true` when the carrier hid the caller's number (`anonymous`, no digits, or one of Twilio's placeholder numbers), `false` when a number was shown, `null` for non-phone sessions. See [Withheld caller ID](/agents/build/dynamic-variables#withheld-caller-id). |

Check warning on line 74 in agents/telephony/inbound-calls.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/inbound-calls.mdx#L74

Did you really mean 'Twilio's'?
| `dialed_number` | The workspace number that was called, E.164. `null` for non-phone sessions. |
| `sip_call_id` | The SIP `Call-ID` of the carrier's INVITE, for [matching your SIP records](/agents/telephony/byo-sip#match-calls-with-your-sip-records). |
| `call_sid` | Twilio's CallSid on a call through a Twilio number, the same value the [inbound call webhook](/agents/monitor/webhooks#inbound-call-webhook) sends. `null` on other calls. |

Check warning on line 77 in agents/telephony/inbound-calls.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/inbound-calls.mdx#L77

Did you really mean 'Twilio's'?

Check warning on line 77 in agents/telephony/inbound-calls.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/inbound-calls.mdx#L77

Did you really mean 'Twilio'?

List calls with the standard sessions endpoint. The `caller_number` filter is an exact match; bare numbers are automatically prefixed with `+`, so `15551234567` matches `+15551234567`:

Expand All @@ -95,15 +95,15 @@
"caller_number": "+15551234567",
"caller_id_withheld": false,
"dialed_number": "+14155550100",
"created_at": "2026-07-23T09:14:01Z",
"started_at": "2026-07-23T09:14:02Z",
"ended_at": "2026-07-23T09:16:45Z",
"created_at": "2026-07-23T09:14:01+00:00",
"started_at": "2026-07-23T09:14:02+00:00",
"ended_at": "2026-07-23T09:16:45+00:00",
"duration_seconds": 163,
"metadata": {}
}
],
"has_more": false,

Check warning on line 105 in agents/telephony/inbound-calls.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/inbound-calls.mdx#L105

Did you really mean 'has_more'?
"next_cursor": null

Check warning on line 106 in agents/telephony/inbound-calls.mdx

View check run for this annotation

Mintlify / Mintlify Validation (hanabiaiinc) - vale-spellcheck

agents/telephony/inbound-calls.mdx#L106

Did you really mean 'next_cursor'?
}
```

Expand Down
Loading