All communication over the WebSocket uses JSON events with a common structure.Documentation Index
Fetch the complete documentation index at: https://docs.poly.ai/llms.txt
Use this file to discover all available pages before exploring further.
Sending events (client → server)
When sending events, include onlytype and payload. The server assigns id, sequence, and timestamp — do not include them.
metadata field with custom key-value pairs. The server echoes these back, useful for correlating sent messages with their echoes:
Receiving events (server → client)
Events from the server include additional fields:| Field | Type | Description |
|---|---|---|
id | string | Unique identifier for this event (UUID). Use to deduplicate. |
sequence | integer or null | Monotonically increases with each event in the session. Use to order events. null for transient events (e.g. typing indicators) that are not part of the permanent history. |
timestamp | string | When the server processed this event (ISO 8601). |
type | string | The event type. |
payload | object | Event-specific data. |
metadata | object | Present when custom data was included. Contains your key-value pairs echoed back. |
Echo behavior
When you send certain events, the server echoes them back with the server-assignedid, sequence, and timestamp added. This confirms the server received and processed your event. The following events are echoed:
EVENT_TYPE_USER_MESSAGE— the echo includes a server-assignedmessage_idin the payloadEVENT_TYPE_USER_END_SESSIONEVENT_TYPE_HEARTBEATEVENT_TYPE_REQUEST_POLY_AGENT_JOIN
id field to deduplicate.
Using echoes as delivery receipts
Echoes act as server-side acknowledgements — when you receive the echo of a message you sent, the server has received and processed it. Use this to build delivery confirmation and retry logic. Add a uniqueclient_event_id to metadata.custom when sending. The server echoes this value back, letting you match the echo to the original message:

