> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# AI post-prompt callback

POST 

Sent to your [`ai.post_prompt_url`](/docs/swml/reference/calling/ai) when the AI session ends. It
carries the agent's answer to your [`post_prompt`](/docs/swml/reference/calling/ai)
alongside the full record of the call: the conversation, the tool calls, the timings, and the
token counts. This is the one report you get per call, so store the body verbatim and extract only
the fields you query. Nothing you return in the response is read.

Read `action` first. It is `post_conversation` on the end-of-call report described here. The same
URL also receives `fetch_conversation` when the agent starts with a stored conversation
([`save_conversation`](/docs/swml/reference/calling/ai/params#paramssave_conversation) with a
`conversation_id`), asking your endpoint to return that conversation; that request carries the
call and session fields but none of the summary fields. Answer it with the stored
`conversation_summary`.

The conversation appears three times. `call_log` is the filtered view, with interrupted segments
consolidated. `raw_call_log` is unfiltered and append-only, and is the only place barge-in detail
survives. `call_timeline` is a flat stream of typed events aligned to `raw_call_log`.

[`amazon_bedrock`](/docs/swml/reference/calling/amazon-bedrock) agents send a different report.
Write your handler against the
[Bedrock post-prompt callback](#tag/calls/webhook/bedrockPostPromptCallback) instead.

Reference: https://signalwire.com/docs/apis/rest/webhooks/ai-post-prompt-callback

## Request

### Payload

- `content_type` (string, required) — The content type of the request body. Always `text/json`.
- `content_disposition` (string, required) — How the body is delivered. `agent.summary` on the end-of-call report, `agent.load_conversation` on a request for a stored conversation.
- `conversation_type` (string, required) — The kind of conversation the agent ran. Always `voice`.
- `call_id` (string, required) — The ID of the call.
- `app_name` (string, required) — The name of your AI application.
- `ai_session_id` (string, required) — The ID of the AI session on the call.
- `action` (enum, required) — What the request is asking of you. `post_conversation` is the end-of-call report; `fetch_conversation` asks your endpoint to return a stored conversation.
  - Allowed values: `post_conversation`, `fetch_conversation`
- `project_id` (string, optional) — Your project ID, when available.
- `space_id` (string, optional) — Your Space ID, when available.
- `ai_id_tag` (string, optional) — A stable fingerprint of the model the agent ran. Two calls that used the same model share it, so you can group reports by model without recording the model name. Omitted when the session had no model.
- `conversation_id` (string, optional) — The conversation ID, when the agent was configured with one.
- `call_log` (list of object, optional) — The conversation, filtered: interrupted segments are consolidated and evicted entries dropped. Included when `action` is `post_conversation`.
  - `role` (string, required) — Who produced the entry: `system`, `user`, `assistant`, or `tool`.
  - `content` (string, required) — The text of the entry.
  - `timestamp` (long, optional) — When the entry was added, as a Unix timestamp in microseconds. Omitted on entries without one.
  - `tool_calls` (list of object, optional) — The tool calls the agent made on this turn. Present only on a turn that made any.
- `raw_call_log` (list of object, optional) — The conversation, unfiltered and append-only. Interruption detail appears here and nowhere else. Included when `action` is `post_conversation`.
  - `role` (string, required) — Who produced the entry: `system`, `user`, `assistant`, or `tool`.
  - `content` (string, required) — The text of the entry.
  - `timestamp` (long, optional) — When the entry was added, as a Unix timestamp in microseconds. Omitted on entries without one.
  - `tool_calls` (list of object, optional) — The tool calls the agent made on this turn. Present only on a turn that made any.
- `call_timeline` (list of object, optional) — A flat stream of typed events aligned to `raw_call_log`, for replaying the call in order. Included when the session produced any.
  - `type` (string, required) — What happened. `user_input`, `ai_response`, and `tool_result` cover the conversation; `pronounce` and `text_normalize` record text rewrites; anything else is the name of a logged action.
  - `ts` (double, optional) — When it happened, as a Unix timestamp in microseconds. Omitted when the source entry had no timestamp.
- `previous_contexts` (list of list of object, optional) — Conversations from before each context switch, oldest first, one array of messages per switch. Included only when the agent switched context during the call.
- `hard_timeout` (boolean, optional) — Always `true` when present, meaning the session ended because it hit its configured time limit rather than finishing on its own. Omitted otherwise.
- `call_start_date` (long, optional) — When the call was created, as a Unix timestamp in microseconds.
- `call_answer_date` (long, optional) — When the call was answered, as a Unix timestamp in microseconds. `0` when it never was.
- `call_end_date` (long, optional) — When the call ended, as a Unix timestamp in microseconds.
- `ai_start_date` (long, optional) — When the AI session started, as a Unix timestamp in microseconds.
- `call_ended_by` (string, optional) — Who or what ended the call. Included when the session recorded it.
- `ai_end_date` (long, optional) — When the AI session ended, as a Unix timestamp in microseconds. Omitted when the session was still running.
- `caller_id_name` (string, optional) — The caller's name, when available.
- `caller_id_number` (string, optional) — The caller's number, when available.
- `times` (list of object, optional) — Per-response performance metrics, one entry per generated reply. Included once the session has any.
  - `response` (string, required) — The reply text. Redacted when you enable `redact_prompt`.
  - `response_word_count` (integer, required) — How many words the reply contained.
  - `answer_time` (double, required) — How long the reply took to produce, in seconds.
  - `token_time` (double, required) — How long the model spent generating, in seconds. For an [`ai`](/docs/swml/reference/calling/ai) agent this is the span from the first token to the last; for an [`amazon_bedrock`](/docs/swml/reference/calling/amazon-bedrock) agent it is `answer_time` less a fixed startup estimate, so treat it as approximate there.
  - `tokens` (integer, required) — How many tokens the reply used.
  - `avg_tps` (double, required) — Average tokens per second across the reply.
  - `tps` (double, required) — Tokens per second for this reply.
- `SWMLVars` (object, optional) — SWML variables for the call. Included when the call carries SWML state.
- `SWMLCall` (object, optional) — SWML call state. Included when the call carries SWML state.
- `post_prompt_data` (object, optional) — The agent's answer to your `post_prompt`. Included when `action` is `post_conversation`.
  - `parsed` (list of object, required) — Every JSON object found in the answer, parsed. An empty array when the agent answered in prose. Ask the post-prompt for named JSON keys when you want to count outcomes.
  - `raw` (string, required) — The answer exactly as the agent produced it.
  - `substituted` (string, optional) — The answer with the JSON removed, leaving only the surrounding prose. Omitted when the answer was JSON and nothing followed it.
- `global_data` (object, optional) — The session's final `global_data`. Alongside anything you seeded, the session adds `caller_id_name` and `caller_id_number` when the call carries them. Included when `action` is `post_conversation`.
- `swaig_log` (list of object, optional) — Every tool call the agent made, in order. Included when `action` is `post_conversation`.
  - `command_name` (string, required) — The name of the function the agent called.
  - `command_arg` (string, required) — The arguments it passed, as the raw string the model produced.
  - `epoch_time` (integer, required) — When the call was made, as a Unix timestamp in seconds.
  - `native` (boolean, optional) — Always `true` when present, meaning the function ran inside the platform rather than on your server.
  - `active_count` (integer or string, optional) — How many times the function may still be called, or `endless` when it has no limit. Present only on a function you limited.
  - `url` (string, optional) — The URL the function was served from. Present when the call reached your server.
  - `post_data` (object, optional) — The body sent to your server. Present when the call reached it.
  - `post_response` (object, optional) — The response your server returned. Present when the call reached it and got a reply.
  - `delayed_post_response` (object, optional) — A response that arrived after the agent had already moved on. Present only when that happened.
  - `mcp_url` (string, optional) — The MCP server the tool was served from. Present only for an MCP-backed tool.
  - `mcp_tool` (string, optional) — The tool name on that MCP server. Present only for an MCP-backed tool.
  - `mcp_response` (string, optional) — What the MCP server returned. Present only for an MCP-backed tool.
  - `mcp_error` (boolean, optional) — Always `true` when present, meaning the MCP call failed.
- `total_minutes` (integer, optional) — The number of billable minutes, rounded up to at least one. Included when you enable [`enable_accounting`](/docs/swml/reference/calling/ai/params#paramsenable_accounting).
- `total_input_tokens` (integer, optional) — Input tokens the session consumed. Included when you enable `enable_accounting`.
- `total_output_tokens` (integer, optional) — Output tokens the session produced. Included when you enable `enable_accounting`.
- `total_wire_input_tokens` (integer, optional) — Input tokens counted against the model, which differs from `total_input_tokens` when the conversation was trimmed. Included when you enable `enable_accounting`.
- `total_wire_input_tokens_per_minute` (double, optional) — `total_wire_input_tokens` divided by `total_minutes`. Included when you enable `enable_accounting`.
- `total_wire_output_tokens` (integer, optional) — Output tokens counted against the model. Included when you enable `enable_accounting`.
- `total_wire_output_tokens_per_minute` (double, optional) — `total_wire_output_tokens` divided by `total_minutes`. Included when you enable `enable_accounting`.
- `total_tts_chars` (integer, optional) — Characters sent to text-to-speech. Included when you enable `enable_accounting`.
- `total_tts_chars_per_min` (double, optional) — `total_tts_chars` divided by `total_minutes`. Included when you enable `enable_accounting`.
- `total_asr_minutes` (double, optional) — Minutes of audio sent to speech recognition. Included when you enable `enable_accounting`.
- `total_asr_cost_factor` (double, optional) — `total_asr_minutes` divided by `total_minutes`. Included when you enable `enable_accounting`.
- `conversation_summary` (string, optional) — A plain-language summary of the conversation, for storing against `conversation_id` and handing back on the next `fetch_conversation`. Included when you enable [`save_conversation`](/docs/swml/reference/calling/ai/params#paramssave_conversation) and set a `conversation_id`.