Skip to main content

Live log tail API

The live log tail API is planned for a future release. The endpoints described on this page are not yet available. This page documents the intended specification for reference.
Stream agent gateway logs directly to the browser using Server-Sent Events (SSE). No SSH access needed — see what your agent is doing in real-time from the dashboard.

Stream Logs

GET /api/logs/:agentId/stream
Opens an SSE connection that streams log output from the agent’s gateway container.

Response

event: line
data: {"type":"connected","agentId":"user_123"}

event: line
data: {"type":"line","text":"[Gateway] Starting OpenClaw..."}

event: line
data: {"type":"line","text":"[Gateway] Listening on port 18789"}

event: line
data: {"type":"exit","code":0}

Event Types

TypeDescription
connectedSSE connection established
lineNew log line from the gateway
exitGateway process exited

Client Example

const eventSource = new EventSource('/api/logs/user_123/stream');

eventSource.onmessage = (event) => {
  const data = JSON.parse(event.data);
  if (data.type === 'line') {
    console.log(data.text);
  } else if (data.type === 'exit') {
    console.log(`Gateway exited with code ${data.code}`);
    eventSource.close();
  }
};

eventSource.onerror = () => {
  console.log('Connection lost, reconnecting...');
};

Get Log History

GET /api/logs/:agentId/history
Returns recent log lines without opening a streaming connection.

Response

{
  "agentId": "user_123",
  "lines": [
    "[Gateway] Starting OpenClaw...",
    "[Gateway] Listening on port 18789"
  ],
  "streaming": true,
  "clients": 2
}

Stop Log Stream

POST /api/logs/:agentId/stop
Stops the log stream and disconnects all clients.

Response

{
  "success": true
}

List Active Streams

GET /api/logs/active
Returns all currently active log streams.

Response

{
  "streams": [
    {
      "agentId": "user_123",
      "clients": 2,
      "lines": 150
    }
  ]
}

Behavior

  • Buffer: Last 500 lines kept in memory
  • Grace period: 30 seconds after last client disconnects before stopping the stream
  • Auto-reconnect: Clients can reconnect and receive buffered lines
  • No auth required for SSE connections (authentication is handled at the dashboard level)