Connect
token query parameter (a WebSocket handshake can’t set headers), using
the same API key as the REST API.
Frames
The first frame acknowledges the connection:{ event, data }, where data carries the same fields as the
corresponding webhook payload:
message.received, message.delivered, message.bounced,
message.complained, message.rejected.
Realtime frames nest the payload under
data; webhooks deliver the same fields flat alongside
event. Read frame.data.* over the socket.Reconnecting
If the socket drops, reconnect and resume. The stream is live-only (it doesn’t replay missed events), so for guaranteed delivery pair it with a webhook or reconcile withGET /messages on reconnect.
Realtime vs webhooks
| Realtime (WebSocket) | Webhooks | |
|---|---|---|
| Latency | Instant push | Instant push |
| Needs a public URL | No | Yes |
| Guaranteed delivery / retries | No (live-only) | Yes (retried) |
| Best for | Interactive agents, live UIs | Reliable server-side processing |