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: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:

