Skip to content

WebSocket RPC

GoClaw uses WebSocket JSON-RPC (protocol v3) as its primary control plane. Clients connect to /ws, authenticate via a connect frame, then exchange request/response/event frames.


Overview

  • Connection URL: ws://<host>:<port>/ws
  • Protocol version: 3
  • Authentication: A connect frame is required as the first request after upgrade
  • Format: Plain JSON, each frame is a JSON object

Connection and Authentication

After a successful WebSocket upgrade (HTTP 101), the first request must be connect:

json
{
  "type": "req",
  "id": "client-gen-uuid",
  "method": "connect",
  "params": {
    "token": "gateway-token-or-api-key",
    "user_id": "external-user-id",
    "sender_id": "optional-device-id",
    "locale": "en"
  }
}

Successful response:

json
{
  "type": "res",
  "id": "client-gen-uuid",
  "ok": true,
  "payload": {
    "protocol": 3,
    "role": "admin",
    "user_id": "user-123",
    "server": {"version": "1.0.0", "uptime": "2h30m"}
  }
}

Authentication flow: Gateway token is compared using timing-safe comparison -> admin role. If no match, SHA-256 hash -> API key lookup -> role inferred from scopes. Pairing codes are also accepted for channel devices.

Connection Parameters

ParameterValueDescription
Read limit512 KBAutomatically closes connection if exceeded
Send buffer256Drops messages when full
Read deadline60sReset on each message or pong
Write deadline10sTimeout per write
Ping interval30sServer keepalive

Frame Format

Request Frame (Client -> Server)

json
{
  "type": "req",
  "id": "<client-gen-uuid>",
  "method": "<method-name>",
  "params": { ... }
}

Response Frame (Server -> Client)

json
{
  "type": "res",
  "id": "<matches-request-id>",
  "ok": true,
  "payload": { ... }
}

On error:

json
{
  "type": "res",
  "id": "<matches-request-id>",
  "ok": false,
  "error": {
    "code": "UNAUTHORIZED",
    "message": "permission denied",
    "details": "",
    "retryable": false,
    "retryAfterMs": 0
  }
}

Event Frame (Server -> Client)

json
{
  "type": "event",
  "event": "<event-name>",
  "payload": { ... },
  "seq": 42,
  "stateVersion": { ... }
}

Methods — By Group

System

MethodDescriptionMinimum Role
connectAuthentication handshake (must be the first request)
healthCheck server health and connected clientsViewer
statusQuick agent/session/client countsViewer

Chat

MethodDescriptionMinimum Role
chat.sendSend message to agent, receive response (supports streaming)Operator
chat.historyGet chat history for a sessionViewer
chat.abortCancel running agent invocationsOperator
chat.injectInject message into session transcript without triggering the agentOperator

chat.send request:

json
{
  "message": "Hello agent",
  "agentId": "uuid-or-key",
  "sessionKey": "optional-session",
  "stream": true,
  "media": [{"type": "image", "url": "..."}]
}

When stream: true, intermediate events are emitted: chunk, tool.call, tool.result, run.started, run.completed.

Sessions

MethodDescriptionMinimum Role
sessions.listList sessions (paginated)Viewer
sessions.previewGet session history and summaryViewer
sessions.patchUpdate label, model, metadataOperator
sessions.deleteDelete sessionOperator
sessions.resetClear all messages in a sessionOperator

Agents

MethodDescriptionMinimum Role
agents.listList all agentsViewer
agentGet a specific agent's stateViewer
agent.waitWait for agent to completeViewer
agent.identity.getGet agent identity (name, emoji, avatar, description)Viewer
agents.createCreate a new agentAdmin
agents.updateUpdate agent propertiesAdmin
agents.deleteDelete agentAdmin
agents.files.listList agent context filesAdmin
agents.files.getRead context file contentAdmin
agents.files.setWrite context file contentAdmin

Teams

MethodDescriptionMinimum Role
teams.listList all teamsAdmin
teams.createCreate a new teamAdmin
teams.getGet team details with membersAdmin
teams.updateUpdate team propertiesAdmin
teams.deleteDelete teamAdmin
teams.members.addAdd agent to team with roleAdmin
teams.members.removeRemove agent from teamAdmin
teams.tasks.listList team tasks (filterable)Admin
teams.tasks.getGet task with comments/eventsAdmin
teams.tasks.createCreate taskAdmin
teams.tasks.approveApprove taskAdmin
teams.tasks.rejectReject taskAdmin
teams.tasks.commentAdd comment to taskAdmin
teams.tasks.assignAssign task to memberAdmin
teams.tasks.deleteDelete taskAdmin
teams.known_usersGet list of user IDs in teamAdmin
teams.scopesGet channel/chat scopes for task routingAdmin
teams.workspace.listList workspace itemsAdmin
teams.workspace.readRead workspace file contentAdmin
teams.workspace.deleteDelete workspace itemAdmin

Cron

MethodDescriptionMinimum Role
cron.listList cron jobsViewer
cron.createCreate a scheduled jobOperator
cron.updateUpdate job settingsOperator
cron.deleteDelete jobOperator
cron.toggleEnable/disable jobOperator
cron.statusGet scheduler statusViewer
cron.runTrigger immediate executionOperator
cron.runsList execution historyViewer

cron.create request:

json
{
  "name": "daily-report",
  "schedule": "every day at 09:00",
  "message": "Generate daily report",
  "deliver": "channel",
  "channel": "telegram",
  "to": "chat-id",
  "agentId": "uuid"
}

Skills

MethodDescriptionMinimum Role
skills.listList all available skillsViewer
skills.getGet skill metadata and contentViewer
skills.updateUpdate skill metadata (DB-backed only)Operator

Config

MethodDescriptionMinimum Role
config.getGet current configuration (secrets masked)Viewer
config.applyReplace entire config (optimistic locking via baseHash)Admin
config.patchPartially update configAdmin
config.schemaGet JSON schema for config form generationViewer

config.patch request:

json
{
  "raw": "{gateway: {port: 9090}}",
  "baseHash": "sha256-of-current-config"
}

Channels

MethodDescriptionMinimum Role
channels.listList enabled channelsViewer
channels.statusGet channel connection statusViewer
channels.instances.listList instancesViewer
channels.instances.getGet instance detailsViewer
channels.instances.createCreate instanceAdmin
channels.instances.updateUpdate instanceAdmin
channels.instances.deleteDelete instanceAdmin

Providers and Tools

MethodDescriptionMinimum Role
providers.modelsList available models from all providersViewer

API Keys

MethodDescriptionMinimum Role
api_keys.listList API keys (masked)Admin
api_keys.createCreate a new API keyAdmin
api_keys.revokeRevoke API keyAdmin

Pairing (Device Pairing)

MethodDescriptionAuth
device.pair.requestRequest pairing (from device)Unauthenticated
device.pair.approveApprove request (from admin)Admin
device.pair.denyDeny requestAdmin
device.pair.listList pending + paired devicesAdmin
device.pair.revokeRevoke deviceAdmin
browser.pairing.statusCheck pairing status (poll)Unauthenticated

Exec Approvals

MethodDescriptionMinimum Role
exec.approval.listList commands pending approvalOperator
exec.approval.approveApprove command (option: always approve)Operator
exec.approval.denyDeny command executionOperator

Usage and Quotas

MethodDescriptionMinimum Role
usage.getGet usage records by agentViewer
usage.summaryGet token usage summaryViewer
quota.usageGet quota consumptionViewer

Other

MethodDescriptionMinimum Role
sendSend outbound message via channelOperator
logs.tailEnable/disable live log streamingAdmin
delegations.listList delegation historyViewer
delegations.getGet delegation detailsViewer

Streaming Events

When chat.send is called with stream: true, the server pushes events in order:

EventDescriptionKey Payload
run.startedAgent run startedrunId, agentId
chunkText streaming chunkcontent (string)
tool.callTool invocation startedtoolName, toolInput
tool.resultTool invocation completedtoolName, result
run.completedAgent run finishedcontent, usage

Server-Pushed Events

EventDescription
session.updatedSession metadata changed
agent.updatedAgent configuration changed
cron.firedCron job triggered
team.task.*Team task lifecycle events
exec.approval.pendingCommand pending approval

Permission Matrix

RoleAccess
AdminAll methods
OperatorRead + write (chat, sessions, cron, approvals, send)
ViewerRead-only (list, get, preview, status, history)

Admin-only methods: config.apply, config.patch, agents.create, agents.update, agents.delete, channels.toggle, device.pair.approve, device.pair.deny, device.pair.revoke, teams.*, api_keys.*


Error Codes

CodeDescription
UNAUTHORIZEDAuthentication failed or insufficient role
INVALID_REQUESTMissing field, wrong type, or method does not exist
NOT_FOUNDResource does not exist
ALREADY_EXISTSResource already exists
UNAVAILABLEService temporarily unavailable
RESOURCE_EXHAUSTEDRate limit exceeded
AGENT_TIMEOUTAgent run exceeded time limit
INTERNALUnexpected server error

Error responses include retryable (boolean) and retryAfterMs (integer).


See Also