Skip to main content

Events API

The OpenClaw Gateway broadcasts real-time events to connected WebSocket clients for agent responses, system health, device pairing, and more.

Event Format

All events follow this structure:
event
string
Event type identifier
payload
object
Event-specific data

Agent Events

Event: agent

Agent response chunks during execution. Assistant text stream:
Tool invocation:
Lifecycle:
See Agent Protocol for details.

Chat Events

Event: chat

WebChat session updates.

System Events

Event: presence

System presence changes (nodes connecting/disconnecting).
nodes
array
Array of node presence objects
version
number
Presence version for change tracking

Event: health

Gateway health status updates.
status
string
Overall health: "healthy", "degraded", "unhealthy"
channels
array
Channel health status
version
number
Health version for change tracking

Event: tick

Periodic heartbeat to keep connections alive.

Event: heartbeat

Client heartbeat acknowledgment.

Event: shutdown

Gateway is shutting down.
Clients should close connections and attempt reconnection.

Device Pairing Events

Event: node.pair.requested

New device pairing request.
nodeId
string
Unique node identifier
name
string
Device name
platform
string
Platform: "ios", "android", "macos", "linux", "windows"

Event: node.pair.resolved

Device pairing resolved (approved/rejected).
approved
boolean
Whether pairing was approved
token
string
Device token (when approved)

Event: device.pair.requested

Device pairing request (alternative format).

Event: device.pair.resolved

Device pairing resolved.

Voice Events

Event: talk.mode

Voice mode changed.
mode
string
Voice mode: "push-to-talk", "voice-wake", "always-on"
enabled
boolean
Whether voice is enabled

Event: voicewake.changed

Voice wake triggers updated.

Execution Approval Events

Event: exec.approval.requested

Execution approval requested for sensitive commands.
requestId
string
Unique approval request ID
command
string
Command requiring approval

Event: exec.approval.resolved

Execution approval resolved.

Cron Events

Event: cron

Cron job status update.
id
string
Cron job identifier
status
string
Status: "running", "completed", "failed"

Update Events

Event: update.available

Software update available.

Connection Challenge

Event: connect.challenge

Sent during device pairing to display challenge code.
challenge
string
6-digit challenge code to display to user
expiresAt
number
Expiration timestamp (milliseconds)

Event Subscriptions

Most events are automatically broadcast to all connected clients. For session-specific events, use subscriptions:

Subscribe to Session

Unsubscribe from Session

Example: Event Listener

Event Filtering

Clients receive all events by default. To filter events client-side:

Event Ordering

Events are delivered in the order they occur, but:
  • Agent events for the same runId are strictly ordered
  • System events may be interleaved with agent events
  • Network delays may affect perceived ordering
Use event timestamps and version numbers for ordering guarantees.

Best Practices

Always handle start, end, and error phases for agent runs:
Buffer assistant text chunks to display complete responses:
Gracefully close connections and attempt reconnection:
Use version numbers to detect missed updates:

Next Steps

WebSocket Protocol

Learn WebSocket connection details

Agent Protocol

Invoke agents and handle responses

Device Pairing

Pair mobile and desktop devices