From 21bb1f09c5ee0248d53e3c6dbd850c81139c712a Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 23 Nov 2026 09:29:30 +0000 Subject: [PATCH 1/5] Webhook docs: document session_id, started_at and ended_at on the session object Add the three fields to the call.ended, call.analyzed and phone_call.dial_finished examples, mark id, conversation_started_at, conversation_ended_at and branch_id as deprecated (still sent), and note that webhook times end in Z while the sessions API writes a numeric offset, so timestamps should be parsed before comparing. Dedupe guidance, code samples and the BYO SIP dial_finished example use the new names. Co-Authored-By: Claude Opus 5.5 --- agents/build/dynamic-variables.mdx | 2 +- agents/monitor/webhooks.mdx | 36 ++++++++++++++++++++++++------ agents/telephony/byo-sip.mdx | 2 +- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/agents/build/dynamic-variables.mdx b/agents/build/dynamic-variables.mdx index 95489b12..6c073eed 100644 --- a/agents/build/dynamic-variables.mdx +++ b/agents/build/dynamic-variables.mdx @@ -161,7 +161,7 @@ The platform fills a handful of `{{system.*}}` placeholders itself, on every ses | `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 diff --git a/agents/monitor/webhooks.mdx b/agents/monitor/webhooks.mdx index 059d12fa..78dca84b 100644 --- a/agents/monitor/webhooks.mdx +++ b/agents/monitor/webhooks.mdx @@ -93,7 +93,7 @@ The list is replaced as a whole on each update, so send every endpoint you want ## 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. @@ -103,6 +103,7 @@ Every payload carries the `event` name, a unique `event_id`, and a `session` obj "event_id": "evt_3f9c2a7b5d1e4f60a8b9c0d1e2f3a4b5", "session": { "id": "sess_5f3e…", + "session_id": "sess_5f3e…", "agent_id": "a1b2…", "branch_id": "b7d4…", "source": "phone", @@ -110,6 +111,8 @@ Every payload carries the `event` name, a unique `event_id`, and a `session` obj "end_reason": "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" }, @@ -127,12 +130,15 @@ Every payload carries the `event` name, a unique `event_id`, and a `session` obj "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" }, @@ -181,6 +187,7 @@ Every payload carries the `event` name, a unique `event_id`, and a `session` obj "answered_by": "human", "session": { "id": "sess_5f3e…", + "session_id": "sess_5f3e…", "agent_id": "a1b2…", "branch_id": "b7d4…", "source": "phone", @@ -196,6 +203,8 @@ Every payload carries the `event` name, a unique `event_id`, and a `session` obj "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" }, @@ -215,16 +224,29 @@ Every payload carries the `event` name, a unique `event_id`, and a `session` obj `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. -`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: @@ -339,7 +361,7 @@ Deliveries can arrive more than once, and a retry can arrive after a later event 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 @@ -404,7 +426,7 @@ The platform sends one `POST` with a JSON body: 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). @@ -492,7 +514,7 @@ app.post( 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}`, body: `Analysis ${payload.analysis.status}` + (payload.analysis.error ? `: ${payload.analysis.error}` : ""), @@ -507,7 +529,7 @@ app.post( if (!verdict || verdict.result === "success") return; openTicket({ - subject: `Unresolved call ${payload.session.id}`, + subject: `Unresolved call ${payload.session.session_id}`, body: `${payload.analysis.summary}\n\n` + `issue_resolved: ${verdict.result}. ${verdict.rationale}`, diff --git a/agents/telephony/byo-sip.mdx b/agents/telephony/byo-sip.mdx index 12536d70..d43f367e 100644 --- a/agents/telephony/byo-sip.mdx +++ b/agents/telephony/byo-sip.mdx @@ -213,7 +213,7 @@ A `phone_call.dial_finished` payload carries everything needed for the webhook-t "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", From 961a42ca201a6bbd0bcb6924f9056b6b8e2952b9 Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 23 Nov 2026 09:09:11 +0000 Subject: [PATCH 2/5] Sessions API examples: started_at and ended_at use the +00:00 offset the API returns Co-Authored-By: Claude Opus 5.5 --- agents/monitor/conversation-history.mdx | 4 ++-- agents/telephony/inbound-calls.mdx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/agents/monitor/conversation-history.mdx b/agents/monitor/conversation-history.mdx index f8d45f31..7423f7aa 100644 --- a/agents/monitor/conversation-history.mdx +++ b/agents/monitor/conversation-history.mdx @@ -63,8 +63,8 @@ Each row carries the session facts: "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" } } diff --git a/agents/telephony/inbound-calls.mdx b/agents/telephony/inbound-calls.mdx index abd28848..97b3f3aa 100644 --- a/agents/telephony/inbound-calls.mdx +++ b/agents/telephony/inbound-calls.mdx @@ -96,8 +96,8 @@ curl --request GET "https://api.fish.audio/v1/agent/sessions?agent_id=YOUR_AGENT "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", + "started_at": "2026-07-23T09:14:02+00:00", + "ended_at": "2026-07-23T09:16:45+00:00", "duration_seconds": 163, "metadata": {} } From 4232911895d8ba549375233c2ceb0397de867f01 Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 23 Nov 2026 09:22:48 +0000 Subject: [PATCH 3/5] Webhooks: the Python ticket example reads session_id Co-Authored-By: Claude Opus 5.5 --- agents/monitor/webhooks.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agents/monitor/webhooks.mdx b/agents/monitor/webhooks.mdx index 78dca84b..b91adfa7 100644 --- a/agents/monitor/webhooks.mdx +++ b/agents/monitor/webhooks.mdx @@ -572,7 +572,7 @@ async def fish_webhooks( # 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']['session_id']}", body=f"Analysis {analysis['status']}{detail}", customer=payload["session"]["end_user_id"], ) @@ -582,7 +582,7 @@ async def fish_webhooks( 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']['session_id']}", body=f"{analysis['summary']}\n\n" f"issue_resolved: {verdict['result']}. {verdict['rationale']}", customer=payload["session"]["end_user_id"], From 1bde47ed8c96f7bde22e95357c55c62b1780eefe Mon Sep 17 00:00:00 2001 From: Harold Date: Mon, 23 Nov 2026 10:08:56 +0000 Subject: [PATCH 4/5] Inbound calls: the sessions example's created_at uses the +00:00 offset the API returns Co-Authored-By: Claude Opus 5.5 --- agents/telephony/inbound-calls.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agents/telephony/inbound-calls.mdx b/agents/telephony/inbound-calls.mdx index 97b3f3aa..9ec07723 100644 --- a/agents/telephony/inbound-calls.mdx +++ b/agents/telephony/inbound-calls.mdx @@ -95,7 +95,7 @@ curl --request GET "https://api.fish.audio/v1/agent/sessions?agent_id=YOUR_AGENT "caller_number": "+15551234567", "caller_id_withheld": false, "dialed_number": "+14155550100", - "created_at": "2026-07-23T09:14:01Z", + "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, From 4607dc2967c3666772dc7723b7e76f628b74379b Mon Sep 17 00:00:00 2001 From: Harold Date: Tue, 24 Nov 2026 06:30:37 +0000 Subject: [PATCH 5/5] Webhooks: ticket examples fall back to session.id for events sent before session_id existed Retries resend the original body, so an event first sent before the session_id field shipped can arrive later without it. Co-Authored-By: Claude Opus 5.5 --- agents/monitor/webhooks.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/agents/monitor/webhooks.mdx b/agents/monitor/webhooks.mdx index b91adfa7..4c932763 100644 --- a/agents/monitor/webhooks.mdx +++ b/agents/monitor/webhooks.mdx @@ -514,7 +514,7 @@ app.post( if (payload.analysis.status !== "completed") { // skipped (the caller never spoke) or error: no verdict to trust. openTicket({ - subject: `Unjudged call ${payload.session.session_id}`, + subject: `Unjudged call ${payload.session.session_id ?? payload.session.id}`, body: `Analysis ${payload.analysis.status}` + (payload.analysis.error ? `: ${payload.analysis.error}` : ""), @@ -529,7 +529,7 @@ app.post( if (!verdict || verdict.result === "success") return; openTicket({ - subject: `Unresolved call ${payload.session.session_id}`, + subject: `Unresolved call ${payload.session.session_id ?? payload.session.id}`, body: `${payload.analysis.summary}\n\n` + `issue_resolved: ${verdict.result}. ${verdict.rationale}`, @@ -572,7 +572,7 @@ async def fish_webhooks( # 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']['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"], ) @@ -582,7 +582,7 @@ async def fish_webhooks( 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']['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"],