Webhook Request Payload
Layercode sends different webhook event types to your backend. Each request body is JSON. All requests include:type
(string): One ofmessage
,session.start
,session.end
,session.update
.session_id
(string): Connection identifier for this session. Changes each reconnect.conversation_id
(string): Stable conversation identifier.
message
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.
session.start
Sent when a new session begins and your agent should optionally speak first.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 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.
session.update
Sent when asynchronous session data becomes available (e.g., after a recording completes).session_id
(string): A unique identifier for the current session.conversation_id
(string): A unique identifier for the conversation.recording_status
(string):completed
orfailed
.recording_url
(string, optional): API URL to download WAV whencompleted
.recording_duration
(number, optional): Duration in seconds.error_message
(string, optional): Error details whenfailed
.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.
session.end
Sent when the session finishes. Includes transcript and usage metrics.session_id
(string): A unique identifier for the current session.conversation_id
(string): A unique identifier for the conversation.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
ordisabled
(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.