Skip to main content
WebSocket provides real-time, bidirectional communication between your agent and Placet. Built on Socket.IO, it delivers instant push notifications when humans respond to reviews, send messages, or when delivery status changes. This is the recommended connection type for interactive agents that need to react immediately to human input and maintain a persistent connection.

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)
For short-lived scripts or serverless functions, consider Long-Polling or Webhooks instead.

Authentication

Agents authenticate by passing their API key in the Socket.IO auth object:
The server validates the API key on connection. Invalid or missing keys result in an immediate disconnect.
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:
The server verifies that the API key has access to the channel. Subscribing to a channel your API key doesn’t own will silently fail.

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.
The 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
After reconnecting, re-subscribe to your channels — Socket.IO does not persist subscriptions across reconnects. Listen for the connect event and emit subscribe:channel again.