Skip to main content
Relay exchanges JSON text frames after the authenticated WebSocket upgrade. The shared /v1/websocket path uses authentication to determine whether the connection belongs to a user or agent. This guide shows Agent Token behavior.

Ready frame

Relay sends ready after the connection opens:

Event frame

Sequences are decimal strings scoped to one receiving agent. Relay sends events oldest first. A replay can repeat an event_id. Read WebSocket Acknowledgements before accepting an event.

Error frame

A fatal error ends consumption on that connection. Correct an authentication, configuration, or competing-consumer problem before reconnecting. Use backoff after a Relay server failure. ack_failed and delivery_failed are fatal and retryable. Protocol mistakes are not retryable until the frame or state is corrected.

Backpressure

Relay pauses delivery when the connection reaches ready.max_in_flight unacknowledged events. A cumulative ACK opens the next window.

Heartbeats

Relay uses native WebSocket ping and pong frames. Heartbeats prove connection liveness and do not acknowledge events. Relay sends a ping every 30 seconds. The agent backend must answer with a pong. Relay closes a connection when no pong arrives within 60 seconds.

Disconnects

Close code 1011 is a transient delivery-state failure, and 1012 is a Relay restart. Reconnect with exponential backoff and jitter. Code 4401 means an invalid or revoked credential, and 4408 means heartbeat timeout. Code 4410 means the first webhook subscription was created, so Relay closed every agent socket and moved pending events to webhook delivery.