Real-time events
Real-time events
Polling GET /calls/{callId} every second tells you a call ended about a second late and costs you a request a second per call. The event stream tells you the moment it happens, and gives you what polling can’t: the transcript as it’s spoken, each function call and agent transition as it occurs. It’s the same feed the dashboard runs on, exposed over a WebSocket you authenticate with an API key.
What you can subscribe to
Account-wide: call lifecycle
Every call in the account, as it’s created, changes status, and ends. Three event types:
This is the subscription for “update my CRM when a call finishes” and “how many calls are live right now”.
Per call: the conversation
Subscribe to a callId and receive its stream:
interim, tts and tts_word are high-frequency and droppable: if your consumer falls behind, the server skips them rather than buffering forever. transcript, status, turn, node_transition and call.* are never dropped.
Connecting
Open a WebSocket to wss://api.talkif.ai/api/v1/ws/events with your API key as a Bearer token in the Authorization header. The key needs the calls scope. Then send subscribe frames — one with no call_id for the account stream, one per call for conversation streams.
Every server frame is an envelope:
seqis per connection and monotonic. A gap means this connection dropped droppable frames under backpressure — not that something happened out of order globally.- Control frames use the same envelope:
subscribed/unsubscribed(with thecall_id, if any) confirm your subscribe frames;ponganswersping.
Joining late: replay
Subscribing to a call with "replay": true streams the call’s history first — every event so far, in order — then continues live. A consumer that connects halfway through a call, or restarts, still gets the whole transcript. Live events that arrive during the replay may appear twice; if that matters, de-duplicate on the event’s own identity (turn number, timestamp) rather than on seq.
Keeping the connection healthy
Design for reconnection from the start: one long-lived connection per service instance, subscribe on open, re-subscribe after any close. Don’t open a connection per call.
A voice call running in a web page through the browser SDK gets the same per-call events on a session-scoped endpoint, authenticated by the session token rather than an API key — so the page can render its own live transcript without holding your API key. See Web calls.