When to Use WebSocket
- Your agent runs continuously (server process, daemon, long-running script)
- You need real-time responses (sub-second latency)
- Your agent handles multiple channels simultaneously
- You want bidirectional communication (send + receive)
Authentication
Agents authenticate by passing their API key in the Socket.IOauth object:
The frontend dashboard uses a different auth method: a short-lived JWT ticket obtained via
POST /api/auth/ws-ticket. This is handled automatically by the Placet frontend.Channel Subscription
After connecting, subscribe to channels to receive their events:Events
All events are received on the/ws namespace.
message:created
A new message was posted in a subscribed channel.
message:updated
An existing message row changed — most commonly because an agent PATCHed the
draft of a streaming reply (see Streaming Replies).
The full updated message record is emitted; clients should replace the row by
id in place. Messages with streamState === "streaming" are still live drafts;
once streamState flips to "complete" the reply is final.
message:delta
A streaming agent reply produced a new chunk. Used for low-latency UI updates
between the slower PATCH-driven message:updated events. Match deltas to the
draft row by streamBaseId (which equals the row’s streamId column).
review:responded
A human completed a review (approval, selection, form, etc.). The full message record is emitted, including attachments.
review.response shape depends on the review type:
review:expired
A review expired without a human response (default: 24 hours).
message:delivery
A message’s delivery status changed.
agent:status
An agent’s heartbeat status changed.
ping / pong
Send a ping event to check the connection is alive. The server responds with pong.
Full Example
A complete agent that sends a deployment approval request and waits for the response via WebSocket:Reconnection
Socket.IO handles reconnection automatically. Placet uses the default Socket.IO reconnection settings:- Reconnects automatically on disconnect
- Exponential backoff (1s, 2s, 4s, …)
- Re-authenticates on reconnect
