Call Event Stream API

Subscribe to real-time call events via the voicetyped REST API.

The Call Event Stream API allows you to subscribe to real-time events from all active calls in your voicetyped deployment. This is the primary observability and integration API — use it to build dashboards, log call activity, trigger external workflows, or implement custom call handling logic.

Endpoints

MethodPathDescription
GET/v1/calls/eventsServer-Sent Events stream for real-time call events
GET/v1/calls/{id}Get a specific call’s status
GET/v1/callsList active calls

Subscribe to Call Events

GET /v1/calls/events

Opens a Server-Sent Events (SSE) stream that delivers call events in real-time.

Query Parameters

ParameterTypeDescription
event_typesstringComma-separated list of event types to filter (empty = all events)
session_idstringFilter events by call session ID (empty = all calls)
dialog_namestringFilter events by dialog name (empty = all dialogs)
include_historyboolInclude historical events from active calls (default false)

Response

The response is a text/event-stream with event and data fields. Each data field contains a JSON object.

event: call_started
data: {"event_id":"evt-001","session_id":"call-abc-123","type":"call_started","timestamp":"2025-06-14T18:30:00Z","caller_id":"+15551234567","called_number":"+18001234567","dialog_name":"helpdesk","sip_headers":{}}

event: speech_final
data: {"event_id":"evt-002","session_id":"call-abc-123","type":"speech_final","timestamp":"2025-06-14T18:30:04Z","transcript":"I need a password reset","confidence":0.94,"language":"en","duration_ms":2100,"segments":[{"text":"I","start_ms":0,"end_ms":180,"confidence":0.97},{"text":"need","start_ms":200,"end_ms":420,"confidence":0.96},{"text":"a","start_ms":440,"end_ms":520,"confidence":0.99},{"text":"password","start_ms":540,"end_ms":900,"confidence":0.93},{"text":"reset","start_ms":920,"end_ms":1200,"confidence":0.91}]}

event: call_terminated
data: {"event_id":"evt-003","session_id":"call-abc-123","type":"call_terminated","timestamp":"2025-06-14T18:32:15Z","reason":"normal","duration_seconds":135,"state_transitions":4,"final_state":"goodbye"}

Event Types

Event TypeDescription
call_startedA new call has connected
call_terminatedA call has ended
speech_partialInterim (non-final) transcript available
speech_finalFinal transcript available
dtmf_receivedA DTMF digit was received
state_transitionThe dialog FSM changed states
action_executedA dialog action was executed
hook_resultA dialog hook returned a result
hook_errorA dialog hook returned an error
tts_startedText-to-speech playback began
tts_completedText-to-speech playback finished
errorA system error occurred

Event Payloads

call_started

Emitted when a new call is connected:

{
  "event_id": "evt-001",
  "session_id": "call-abc-123",
  "type": "call_started",
  "timestamp": "2025-06-14T18:30:00Z",
  "caller_id": "+15551234567",
  "called_number": "+18001234567",
  "dialog_name": "helpdesk",
  "sip_headers": {
    "X-Custom-Header": "value"
  }
}
FieldTypeDescription
event_idstringUnique event identifier
session_idstringCall session ID
typestring"call_started"
timestampstringISO 8601 timestamp
caller_idstringCaller phone number
called_numberstringDialed number
dialog_namestringMatched dialog
sip_headersobjectCustom SIP headers (key-value pairs)

call_terminated

Emitted when a call ends:

{
  "event_id": "evt-003",
  "session_id": "call-abc-123",
  "type": "call_terminated",
  "timestamp": "2025-06-14T18:32:15Z",
  "reason": "normal",
  "duration_seconds": 135,
  "state_transitions": 4,
  "final_state": "goodbye"
}
FieldTypeDescription
event_idstringUnique event identifier
session_idstringCall session ID
typestring"call_terminated"
timestampstringISO 8601 timestamp
reasonstringTermination reason (see below)
duration_secondsintegerCall duration
state_transitionsintegerNumber of FSM transitions
final_statestringLast state before termination

Termination reasons:

ReasonDescription
normalNormal hangup
caller_hangupCaller hung up
system_hangupDialog reached hangup action
transferCall was transferred
errorSystem error
timeoutMax duration exceeded

speech_final / speech_partial

Emitted for final and partial transcripts:

{
  "event_id": "evt-002",
  "session_id": "call-abc-123",
  "type": "speech_final",
  "timestamp": "2025-06-14T18:30:04Z",
  "transcript": "I need a password reset",
  "confidence": 0.94,
  "language": "en",
  "duration_ms": 2100,
  "segments": [
    { "text": "I", "start_ms": 0, "end_ms": 180, "confidence": 0.97 },
    { "text": "need", "start_ms": 200, "end_ms": 420, "confidence": 0.96 },
    { "text": "a", "start_ms": 440, "end_ms": 520, "confidence": 0.99 },
    { "text": "password", "start_ms": 540, "end_ms": 900, "confidence": 0.93 },
    { "text": "reset", "start_ms": 920, "end_ms": 1200, "confidence": 0.91 }
  ]
}
FieldTypeDescription
event_idstringUnique event identifier
session_idstringCall session ID
typestring"speech_final" or "speech_partial"
timestampstringISO 8601 timestamp
transcriptstringTranscript text
confidencefloatConfidence score (0.0–1.0)
languagestringDetected language code
duration_msintegerSpeech duration in milliseconds
segmentsarrayWord-level timing (final only)

Each segment object:

FieldTypeDescription
textstringWord text
start_msintegerStart time in milliseconds
end_msintegerEnd time in milliseconds
confidencefloatWord-level confidence score

dtmf_received

{
  "event_id": "evt-010",
  "session_id": "call-abc-123",
  "type": "dtmf_received",
  "timestamp": "2025-06-14T18:30:10Z",
  "digit": "5",
  "duration_ms": 120
}
FieldTypeDescription
digitstring"0""9", "*", "#"
duration_msintegerTone duration in milliseconds

state_transition

{
  "event_id": "evt-015",
  "session_id": "call-abc-123",
  "type": "state_transition",
  "timestamp": "2025-06-14T18:30:12Z",
  "from_state": "greeting",
  "to_state": "collect_info",
  "trigger_event": "speech_final",
  "dialog_name": "helpdesk"
}
FieldTypeDescription
from_statestringPrevious state
to_statestringNew state
trigger_eventstringWhat caused the transition
dialog_namestringDialog name

Usage Examples

curl

# Subscribe to real-time call events (SSE)
curl -N "http://localhost:8080/v1/calls/events?event_types=call_started,speech_final,call_terminated"

# Filter events for a specific session
curl -N "http://localhost:8080/v1/calls/events?session_id=call-abc-123"

# Filter events for a specific dialog
curl -N "http://localhost:8080/v1/calls/events?dialog_name=helpdesk&include_history=true"

# Get a specific call
curl "http://localhost:8080/v1/calls/call-abc-123"

# List active calls
curl "http://localhost:8080/v1/calls?page_size=50"

# List active calls filtered by dialog
curl "http://localhost:8080/v1/calls?dialog_name=helpdesk&page_size=25"

JavaScript (EventSource)

const params = new URLSearchParams({
  event_types: "call_started,speech_final,call_terminated",
});

const source = new EventSource(`http://localhost:8080/v1/calls/events?${params}`);

source.addEventListener("call_started", (e) => {
  const data = JSON.parse(e.data);
  console.log(`Call started: ${data.session_id} from ${data.caller_id}`);
});

source.addEventListener("speech_final", (e) => {
  const data = JSON.parse(e.data);
  console.log(`[${data.session_id}] ${data.transcript} (${Math.round(data.confidence * 100)}%)`);
});

source.addEventListener("call_terminated", (e) => {
  const data = JSON.parse(e.data);
  console.log(`Call ended: ${data.session_id} (${data.reason}, ${data.duration_seconds}s)`);
});

source.onerror = (err) => {
  console.error("SSE connection error:", err);
  source.close();
};

Get Call

GET /v1/calls/{id}

Retrieve the current status of a specific call.

Response

{
  "session_id": "call-abc-123",
  "caller_id": "+15551234567",
  "called_number": "+18001234567",
  "dialog_name": "helpdesk",
  "current_state": "collect_info",
  "start_time": "2025-06-14T18:30:00Z",
  "duration_seconds": 45,
  "status": "active",
  "variables": {
    "customer_name": "Jane",
    "intent": "password_reset"
  }
}
FieldTypeDescription
session_idstringCall session ID
caller_idstringCaller phone number
called_numberstringDialed number
dialog_namestringMatched dialog
current_statestringCurrent FSM state
start_timestringISO 8601 call start time
duration_secondsintegerElapsed time since call start
statusstringCall status (see below)
variablesobjectDialog variables (key-value pairs)

Call status values:

StatusDescription
activeCall is in progress
on_holdCall is on hold
transferringCall is being transferred
terminatedCall has ended

Error Responses

Status CodeDescription
404 Not FoundCall with the given ID does not exist
401 UnauthorizedMissing or invalid authentication
500 Internal Server ErrorServer error

List Calls

GET /v1/calls

List all active calls.

Query Parameters

ParameterTypeDefaultDescription
dialog_namestringFilter by dialog name
page_sizeinteger50Maximum number of results
page_tokenstringPagination token from a previous response

Response

{
  "calls": [
    {
      "session_id": "call-abc-123",
      "caller_id": "+15551234567",
      "called_number": "+18001234567",
      "dialog_name": "helpdesk",
      "current_state": "collect_info",
      "start_time": "2025-06-14T18:30:00Z",
      "duration_seconds": 45,
      "status": "active",
      "variables": {}
    }
  ],
  "next_page_token": "eyJvZmZzZXQiOjUwfQ==",
  "total_count": 127
}
FieldTypeDescription
callsarrayList of call objects (same schema as Get Call)
next_page_tokenstringToken for the next page (empty if no more results)
total_countintegerTotal number of matching calls

Error Responses

Status CodeDescription
400 Bad RequestInvalid query parameter value
401 UnauthorizedMissing or invalid authentication
500 Internal Server ErrorServer error

Connection Details

ParameterDefaultDescription
HostlocalhostAPI server host
Port8080REST API port
TLSfalseEnable HTTPS (recommended for production)
AuthNonemTLS or API key (see Security)

Next Steps