Webhook SSE API
type
(string): One of message
, session.start
, session.end
, session.update
.session_id
(string): Connection identifier for this session. Changes each reconnect.conversation_id
(string): Stable conversation identifier.text
(string): Transcribed user text.
| session_id
(string): A unique identifier for the current session |
| conversation_id
(string): A unique identifier for the conversation |turn_id
(string): Unique ID for this turn.from_phone_number
(string, optional): Caller phone number if Twilio is used.to_phone_number
(string, optional): Agent phone number if Twilio is used.turn_id
(string): Unique ID for the assistant welcome turn.from_phone_number
(string, optional): Caller phone number if Twilio is used.to_phone_number
(string, optional): Agent phone number if Twilio is used.recording_status
(string): completed
or failed
.recording_url
(string, optional): API URL to download WAV when completed
.recording_duration
(number, optional): Duration in seconds.error_message
(string, optional): Error details when failed
.metadata
(object): Session metadata originally provided during authorization (if any).from_phone_number
(string, optional): Caller phone number if Twilio is used.to_phone_number
(string, optional): Agent phone number if Twilio is used.agent_id
(string): Agent ID.started_at
/ ended_at
(string): ISO timestamps.duration
(number|null): Total milliseconds (if available).transcription_duration_seconds
(number|null)tts_duration_seconds
(number|null)latency
(number|null)ip_address
(string|null)country_code
(string|null)recording_status
(string): enabled
or disabled
(org setting for session recording).transcript
(array): Items of { role: 'user' | 'assistant', text: string, timestamp: number }
.from_phone_number
(string, optional): Caller phone number if Twilio is used.to_phone_number
(string, optional): Agent phone number if Twilio is used.data:
field, followed by a stringified JSON object and two newlines (\n\n
).
response.tts
type events to the client containing text, which the Layercode voice agent will convert to speech and send to the client as response.audio
events. The text will be processed in sentence chunks for natural speech delivery.
{ "delta": "text delta..." }
and accumulate and render the delta in the client browser.
response.tts
and response.data
messages can be sent over a single SSE response (e.g. so the agent can say “I’m just getting your results”, do a tool call, return the results in response.data, and then speak a summary of the results).
Ending the SSE response
Once the webhook SSE response is ready to be closed, you must send the following final event: