Skip to content

Gateway API

The gateway listens on 127.0.0.1:8120. Every route under /api except /api/health needs the access token, sent as Authorization: Bearer <token>; a missing or wrong token gets 401. The web page uses exactly these routes, so anything it does can also be scripted.

TOKEN=$(grep ^TRADING_AGENT_GATEWAY_ACCESS_TOKEN .env | cut -d= -f2-)
curl -s -H "Authorization: Bearer $TOKEN" http://127.0.0.1:8120/api/desks

Health

Method Route What it does Token
GET /api/health Is the gateway running, and each desk's state no

Desks

Method Route What it does Token
GET /api/desks Every desk's state, models and session yes
GET /api/desks/{desk} One desk, with its persona yes
GET /api/desks/{desk}/context How full the context window is, by category, and the desk's tools yes
GET /api/desks/{desk}/commands The desk's slash commands and usable skills, each with its usage, what it does, and whether it is answered at once, beside the running turn, or queued; the web page's and the terminal's command menus read it yes
POST /api/desks/{desk}/model Try one model first from now on, optionally another of its provider's models, or go back to the configured order, as /model does yes
POST /api/desks/{desk}/messages Queue a message or slash command, with attachment_ids naming uploaded files; the answer arrives as events yes
POST /api/desks/{desk}/attachments Upload one picture or document (a form with a file field); answers its attachment yes
GET /api/desks/{desk}/attachments/{attachment} The uploaded file itself yes
GET /api/desks/{desk}/pictures/{path} A picture inside the desk's folder, such as a screenshot in a tool card yes
POST /api/desks/{desk}/pause Stop the desk asking its models yes
POST /api/desks/{desk}/resume Start it again yes
POST /api/desks/{desk}/flatten Cancel the desk's orders and close its positions, with a reason yes

Questions, plans and permissions

Method Route What it does Token
GET /api/requests The desks' waiting requests, or all of them with status=all yes
POST /api/requests/{request}/answer Answer a question yes
POST /api/requests/{request}/plan Approve a plan, or ask for changes yes
POST /api/requests/{request}/permission Allow a held call once or always, or deny it yes
POST /api/requests/{request}/dismiss Close a request without answering yes
GET /api/permissions The standing "Always allow" permissions yes
POST /api/permissions/revoke Make a desk ask again before using a tool yes

Each answer is handed to the desk as a new message; the desk never waited for it. An answer is recorded as given "via web" unless the client sends the header X-Trading-Agent-Client: terminal, which the terminal program does; any other value counts as web.

The account

Method Route What it does Token
GET /api/account Balance, margin, day and week, each desk's profit, positions, owners, halts yes
GET /api/orders UBI's order book: orders, trades or open parents yes
GET /api/desk-orders Each desk's open orders in the desk order book yes
POST /api/account/kill Fire the kill switch; needs yes

Memory and the journal

Method Route What it does Token
GET /api/desks/{desk}/sessions The desk's sessions yes
GET /api/desks/{desk}/sessions/{session} One session's exchanges yes
GET /api/desks/{desk}/summaries The daily summaries yes
GET /api/desks/{desk}/notes The notes files yes
GET /api/desks/{desk}/search Search the desk's memory yes
GET /api/desks/{desk}/journal One day of the desk's journal yes
GET /api/journal One day of the gateway's own journal yes

Your files and proposals

Method Route What it does Token
GET /api/files The files you may edit yes
GET /api/files/content One file's text yes
PUT /api/files/content Save one file; TradingRules.md is checked first yes
GET /api/proposals Every proposal, with its diff yes
POST /api/proposals/{proposal}/accept Apply a proposal yes
POST /api/proposals/{proposal}/reject Reject it yes

Schedule

Method Route What it does Token
GET /api/desks/{desk}/jobs The desk's jobs with their next runs, and the latest runs yes
POST /api/desks/{desk}/jobs Create a job yes
DELETE /api/desks/{desk}/jobs/{job} Delete one of your jobs yes
POST /api/desks/{desk}/jobs/{job}/run Start a job now yes
GET /api/desks/{desk}/alerts The desk's price alerts yes
DELETE /api/desks/{desk}/alerts/{alert} Remove one yes

Extensions and checkpoints

Method Route What it does Token
GET /api/desks/{desk}/skills The desk's skills with their usage yes
GET /api/subagents The subagent definitions yes
GET /api/mcp Each MCP server's state and tools yes
GET /api/packages The installed packages yes
GET /api/desks/{desk}/checkpoints The desk's checkpoints yes
POST /api/desks/{desk}/checkpoints/{checkpoint}/restore Restore one yes

System

Method Route What it does Token
GET /api/usage Today's tokens per desk and model, and Claude's limits yes
GET /api/configuration The configuration, with secrets masked yes

Channels and apps

Method Route What it does Token
GET /api/channels Telegram's state, waiting codes and paired chats yes
POST /api/channels/telegram/pairings/{code}/approve Pair the chat that was given a code yes
DELETE /api/channels/telegram/chats/{chat} Unpair a chat yes
GET /api/devices Whether app notifications are on, and the registered phones, without their Firebase tokens yes
POST /api/devices Register a phone's Firebase token for notifications yes
DELETE /api/devices/{device} Remove a phone yes
POST /api/devices/{device}/test Send a test notification to one phone yes
GET /api/apps The packages' apps and their state yes
POST /api/apps/{package}/{action} Start, stop or restart an app's unit yes

Webhooks

Method Route What it does Token
POST /hooks/wake/{desk} Wake a desk from TradingView or a script webhook token

The event stream

/ws/events?token=<token> is a WebSocket that sends every event as JSON as it happens: its kind, its desk, its payload and its created_at. Add &desk=intraday to receive one desk's events and the events that belong to no desk, such as the kill switch. A wrong token closes the connection with code 1008.

{"kind": "tool_call", "desk": "general", "payload": {"trigger_id": "c38a67fb...", "call_id": "f60067d3...", "name": "get_portfolio", "arguments": {"kind": "funds"}}, "created_at": "2026-10-16T19:35:41.662832+00:00"}

Every other address that is not under /api, /ws or /hooks is answered with the web page.