MCPDocumentation
On this page

Voice agents

Call ends

call_end
Direct write
Permission required
agent:runtime (agent keys only)

When to use it

Called by the agent's code when the session closes. Replaces the post-call webhook: stores the full transcript, the tools used, the events, the usage and the audio key, marks the call as ended and queues the job that generates the summary, topics, language, score, outcome and quality. The agent no longer writes summaries. Repeating it with the same call_id writes nothing (duplicate = true).

Input

FieldTypeDescription
call_idRequiredstringThe call id: the LiveKit room name. With the key, it identifies the call
channel"voice"Channel (only voice for now)
ended_atRequiredstring (date-time)ISO end time
duration_sRequiredinteger
termination_reasonRequiredstringWhy it ended: user_hangup, agent_hangup, transfer, error…
transcriptRequiredobject[]The full transcript (authoritative: replaces call_log's)
transcript[].seqintegerTurn number (0, 1, 2…): never stored twice
transcript[].roleRequired"user" | "assistant" | "system"
transcript[].textRequiredstring
transcript[].tnumberSecond of the call
tool_callsobject[]
tool_calls[].idstring
tool_calls[].nameRequiredstring
tool_calls[].argumentsobject
tool_calls[].resultanyThe first 4 KB are stored
tool_calls[].okbooleanfalse = the tool failed (default true)
tool_calls[].errorstring
tool_calls[].tnumberSecond of the call
tool_calls[].duration_msinteger
usageobjectUsage of the call (for costs)
usage.llmobject[]
usage.llm[].modelRequiredstring
usage.llm[].inRequiredinteger
usage.llm[].outRequiredinteger
usage.stt_snumber
usage.tts_charsinteger
recordingobject
recording.egress_idstring
recording.keystringAudio object key in the bucket: recordings/{org}/{agent}/…
agent_outcomestringOutcome according to the agent (an outcome_options key). set_outcome does the same during the call

Every tool also accepts lang (es | en) for the language of the text answer.

Output

FieldTypeDescription
conversation_idRequirednumber
job_idRequirednumber | nullPost-call job (summary, topics, outcome, quality, escalation)
duplicateRequiredbooleantrue = already received: nothing was written again
messages_storedRequirednumber
tool_calls_storedRequirednumber
eventsRequiredstring[]Events detected by the organization's rules
agent_outcome_appliedRequiredboolean

Examples

Example 1: End of call

Call

JSON
{
  "name": "call_end",
  "arguments": {
    "call_id": "call-_+34600111222_abc123",
    "ended_at": "2026-11-25T09:34:10Z",
    "duration_s": 250,
    "termination_reason": "user_hangup",
    "transcript": [
      {
        "role": "assistant",
        "text": "Hola, soy Joana…",
        "t": 0.4
      },
      {
        "role": "user",
        "text": "Quería saber el horario de la piscina",
        "t": 4.1
      }
    ],
    "tool_calls": [
      {
        "name": "kb_search",
        "arguments": {
          "query": "horario piscina"
        },
        "ok": true,
        "t": 6.2,
        "duration_ms": 180
      }
    ],
    "usage": {
      "llm": [
        {
          "model": "gpt-4.1-mini",
          "in": 5200,
          "out": 640
        }
      ],
      "stt_s": 250,
      "tts_chars": 1800
    },
    "recording": {
      "egress_id": "EG_abc",
      "key": "recordings/39/joan-miro-voz/call-_+34600111222_abc123_1764063010.mp3"
    }
  }
}

Response

JSON
{
  "conversation_id": 81234,
  "job_id": 977,
  "duplicate": false,
  "messages_stored": 2,
  "tool_calls_stored": 1,
  "events": [],
  "agent_outcome_applied": false
}

Equivalent JSON-RPC call (POST /mcp)

JSON
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "call_end",
    "arguments": {
      "call_id": "call-_+34600111222_abc123",
      "ended_at": "2026-11-25T09:34:10Z",
      "duration_s": 250,
      "termination_reason": "user_hangup",
      "transcript": [
        {
          "role": "assistant",
          "text": "Hola, soy Joana…",
          "t": 0.4
        },
        {
          "role": "user",
          "text": "Quería saber el horario de la piscina",
          "t": 4.1
        }
      ],
      "tool_calls": [
        {
          "name": "kb_search",
          "arguments": {
            "query": "horario piscina"
          },
          "ok": true,
          "t": 6.2,
          "duration_ms": 180
        }
      ],
      "usage": {
        "llm": [
          {
            "model": "gpt-4.1-mini",
            "in": 5200,
            "out": 640
          }
        ],
        "stt_s": 250,
        "tts_chars": 1800
      },
      "recording": {
        "egress_id": "EG_abc",
        "key": "recordings/39/joan-miro-voz/call-_+34600111222_abc123_1764063010.mp3"
      }
    }
  }
}