Skip to main content

Gateway HTTP API

PicoClaw exposes two HTTP servers:

  • The Gateway (default 127.0.0.1:18790, configured via gateway.host/gateway.port): health endpoints, webhook handlers for HTTP-based channels, and the Pico WebSocket endpoint.
  • The Launcher (default 127.0.0.1:18800, see the Web UI & Launcher Guide): the dashboard's REST API and the authenticated Pico proxy.

There are no generic REST chat endpoints — chat traffic uses the Pico protocol described below.

Gateway Endpoints​

MethodPathPurposeAuth
GET/healthLiveness check; JSON {status:"ok", uptime, pid}None
GET/readyReadiness check; returns 503 until the Gateway reports readyNone
POST/reloadSchedule an asynchronous config reload; returns 202 {"status":"reload scheduled",...} (503 when reload is unavailable, 405 for other methods)Bearer token
GET/reload/statusLatest reload state: {generation, in_progress, last_error, started_at, finished_at} (405 for other methods)Bearer token
GET/pico/wsPico channel WebSocket (only when the pico channel is enabled)Pico token
GET/HEAD/pico/media/{id}Attachment download (content-disposition: inline for images)Pico token
POST/webhook/lineLINE channel webhook; path configurable via LINE.webhook_pathLINE signature

Notes:

  • /reload auth: the Gateway generates a token at startup and stores it in the PID file (.picoclaw.pid). Send it as Authorization: Bearer <token>. An empty token disables the check. /reload/status uses the same token.
  • Reload status: generation increases when a reload starts. Callers that triggered a reload can poll /reload/status until generation advances and in_progress is false; a non-empty last_error means the reload failed and the previous configuration is still active.
  • Channel handlers: HTTP-based channels register their own routes on the same server (for example the LINE webhook above). A channel that is not enabled does not expose its routes.
  • Docker: the gateway compose profile exposes only webhooks and health endpoints; use the launcher profile (or PICOCLAW_GATEWAY_HOST=0.0.0.0) for host access. See the Docker & Quick Start Guide.

Pico WebSocket Protocol​

/pico/ws is the JSON protocol used by the Web UI chat, the pico channel clients, and channel proxies. When the pico channel is enabled:

  • Authentication: Authorization: Bearer <pico-token>, or Sec-WebSocket-Protocol: token.<token> (echoed back on upgrade), or ?token= only when allow_token_query is enabled.
  • Session: pass ?session_id=<id> on the URL to continue an existing session; otherwise the server generates one. The channel treats the conversation as pico:<sessionID>.
  • All-session observer: pass ?all_sessions=1 to open a read-only observer connection that receives lightweight session.activity events for every session. Observer connections do not receive message content and reject message.send/media.send frames.
  • Limits: the endpoint returns 503 when the channel is not running or the connection limit (max_connections, default 100) is exceeded.

Every frame is a JSON envelope:

{
"type": "message.send",
"id": "optional-frame-id",
"session_id": "optional-session-id",
"timestamp": 0,
"payload": {}
}
Directiontype values
Client → servermessage.send, media.send, ping
Server → clientmessage.create, message.update, message.delete, media.create, typing.start, typing.stop, session.activity, error, pong

Payload keys of interest: content, message_id, kind (thought, tool_calls, tool_feedback), tool_calls, model_name, usage, final, and the legacy thought boolean. session.activity events carry the originating session_id and an event payload equal to the underlying event type (for example, typing.start or message.create). The activity payload includes final: true when the underlying message is the turn's final response; observers use that flag to set unread state only after a completed answer, while non-final message activity and typing.start indicate a running turn. Observers never receive message content.

Launcher API​

The launcher serves the dashboard SPA and a REST API for everything the UI does. All routes require the dashboard session cookie except the public login/setup pages and /api/auth/*.

GroupRepresentative endpointsPurpose
AuthPOST /api/auth/setup, POST /api/auth/login, POST /api/auth/logout, GET /api/auth/statusDashboard password lifecycle (public)
Pico proxyGET /api/pico/info, POST /api/pico/token, POST /api/pico/setup, GET /pico/ws, GET /pico/media/{id}Chat proxy to the Gateway; frontend never talks to the Gateway directly
ConfigGET/PUT/PATCH /api/config, /api/config/reset, /api/config/test-command-patternsRead and edit config.json
Gateway lifecycle/api/gateway/status, /logs, /logs/clear, /start, /stop, /restartManage the picoclaw gateway subprocess and its log buffer
Models/api/models* (CRUD, /default-chain, /catalog, /{index}/test, /test-inline)Model list management
Channels/api/channels/catalog, /api/channels/{name}/configChannel configuration catalog
Sessions/api/sessions, /api/sessions/{id}, /api/sessions/{id}/fork, GET /api/sessions/searchChat history; /search returns ranked message snippets matching a text query
FilesGET /api/files/previewReturn a text preview of a workspace file; ?path= required; truncated at 384 KB
Skills/api/skills*Browse, import, and remove skills
CommandsGET /api/commandsSlash command metadata (built-in and custom) for the chat composer slash palette
Tools/api/tools, /api/tools/{name}/state, /api/tools/web-search-configTool availability and settings
Subagents/api/agents/subagents, /api/agents/subagents/activeAgent roster, delegation permissions, sub-turn limits, and live subagent tasks
MCPGET /api/agents/mcpMCP server connection status, tools, and config; reconciled against the live gateway snapshot
OAuth/api/oauth/providers, /login, /flows/{id}, /flows/{id}/poll, /logout, /oauth/callbackProvider OAuth flows
QR flows/api/weixin/flows*, /api/wecom/flows*WeChat/WeCom QR binding
System/api/system/launcher-config, /api/system/autostart, /api/system/version, POST /api/updateLauncher settings and self-update

Unauthenticated requests behave as follows: dashboard pages redirect to /launcher-login, /api/* returns 401 JSON, and the /pico/ws proxy returns 401 plain text. The proxy injects the Pico token into upstream connections, so browser clients never handle it directly.

Availability Summary​

SurfaceEndpointsCondition
Gateway health/health, /readyAlways
Gateway reload/reload, /reload/statusAlways (requires the PID-file token when set)
Pico/pico/ws, /pico/media/{id}pico channel enabled with a non-empty token (the launcher auto-enables it)
Channel webhooks/webhook/*The respective channel enabled
Launcher API/api/*, /pico/* proxyLauncher running; dashboard cookie required (503 when the Gateway is down for the Pico proxy)