Skip to content

Calls & Recordings

← Back to API Reference


Contents


GET /api/calls

Paginated call history.

Query parameters:

ParameterTypeDefaultDescription
pageint1Page number (1-based)
page_sizeint20Results per page (max 100)
statusstringringing · in_progress · completed · failed · no_answer

Response:

json
{
  "calls": [ /* array of Call objects */ ],
  "total": 1250
}

GET /api/calls/{call_id}

Get a single call with full details: transcript, call context, per-call usage stats, and end reason.


GET /api/calls/{call_id}/events

Time-ordered trace of everything that happened during a call. Useful for debugging agent behaviour, latency, and tool calls.

Response:

json
[
  {
    "id": 1,
    "call_id": "550e8400-e29b-41d4-a716-446655440000",
    "event_type": "user_spoke",
    "timestamp": "2026-03-18T10:23:46.123456",
    "data": { "text": "Hello, I have a question about my order" }
  },
  {
    "id": 2,
    "event_type": "tool_called",
    "timestamp": "2026-03-18T10:23:51.456789",
    "data": { "function": "lookup_order", "args": { "order_id": "ORD-12345" } }
  }
]

POST /api/calls/outbound

Initiate an outbound call.

Request:

json
{
  "phone_number": "+919876543210",
  "agent_name": "sales-agent",
  "caller_id": "+15551234567",
  "provider": "twilio",
  "custom_parameters": {
    "customer_name": "Ravi Kumar",
    "invoice_amount": "4500"
  }
}
FieldRequiredDescription
phone_numberYesDestination in E.164 format
agent_nameYesName of the agent to handle the call
caller_idNoCaller ID to display. Falls back to provider default.
providerNoOverride telephony provider. Falls back to DB settings.
custom_parametersNoKey-value pairs injected as call context

Response:

json
{
  "status": "initiated",
  "call_id": "550e8400-e29b-41d4-a716-446655440000",
  "provider_response": {
    "sid": "CA...",
    "status": "queued"
  }
}

custom_parameters usage:

  • substitution in the agent greeting and flow node prompts
  • Injected into the LLM system prompt as call context at call start
  • Passed as arguments to pre_call_tool_ids tools

Manual Start / End

These are for testing or non-standard telephony integrations where you manage the call lifecycle yourself.

POST /api/calls/start

Manually register a new call record.

json
{
  "phone_number": "+919876543210",
  "agent_name": "sales-agent",
  "direction": "inbound",
  "metadata": {}
}

POST /api/calls/end

Manually mark a call as complete.

json
{ "call_id": "550e8400-e29b-41d4-a716-446655440000" }

Recordings

GET /api/recordings/{call_id}

Stream the WAV recording for a completed call. Returns 404 if no recording exists for this call.

The response is a streaming audio/wav file — use this URL directly in an <audio> element or for download.


Call Field Reference

FieldDescription
idCall UUID
phone_numberCaller/callee number in E.164 format
agent_nameAgent that handled the call
directioninbound or outbound
statusringing · in_progress · completed · failed · no_answer
start_timeISO 8601 when the call connected
end_timeISO 8601 when the call ended
durationDuration in seconds
recording_pathPath to WAV recording, if available
transcriptFull conversation with timestamps
end_reasonWhy the call ended: agent_ended · user_ended · idle_timeout · error
llm_prompt_tokensTotal LLM input tokens across all turns
llm_completion_tokensTotal LLM output tokens across all turns
tts_charactersTotal characters sent to TTS
metadataArbitrary metadata attached to the call

Event Type Reference

Event TypeDescription
call_startedCall connected
call_endedCall completed
user_spokeUser speech transcription (data.text)
agent_spokeAgent response text (data.text)
tool_calledLLM invoked a tool (data.function, data.args)
tool_resultTool returned a result (data.result)
node_enteredFlow engine entered a node (data.node_key)
node_transitionFlow engine transitioned between nodes
context_injectedPre-call or pre-action context added to LLM
tts_startedTTS audio playback began
tts_stoppedTTS audio playback ended (includes duration)
interruptionUser interrupted the agent mid-speech
ttfb_metricTime-to-first-byte latency measurement (data.ms)
llm_usageToken count for a single LLM turn
tts_usageCharacter count for a single TTS call
call_statusTelephony provider status update
errorPipeline error (data.message, data.context)