Docs/Gateway/Control API
Gateway

Control API

5 min read

Everything the board does, a script can do. Each running Director serves a local REST Control API - create sessions, send prompts, queue work, interrupt, and close, all over plain JSON. It is how DevThrottle's own scheduler starts sessions, and it is yours to use for automation on your machine.

Ports and discovery

Each Director claims the first free port in the range 7879-7898 on 127.0.0.1 and keeps it across restarts. More than one Director can run on a machine, so discovery is a scan: probe GET /healthz across the range and collect whoever answers.

GET/healthz
Liveness and identity in one call.
GET http://127.0.0.1:7879/healthz
{
  "status": "ok",
  "directors": 1,
  "sessions": 3,
  "version": "1.4.2",
  "serverTime": "2026-07-06T15:04:05Z",
  "directorId": "d-3f6a...",
  "machineName": "MY-PC"
}
Note
The Control API answers on the local machine only and does not require a token there - the boundary is your machine. Anything that can run code on your PC can drive your board, which is exactly the point for local automation.

List sessions

GET/sessions
All live sessions as a JSON array. Add ?includeExited=true to include exited ones.

Each session object carries what the card shows and more - useful fields include sessionId, name, number, repoPath, agent, activityState, statusColor, lastStatusReason, needsYouSince, idleSeconds, and createdAt. GET /sessions/{id} fetches one, and PATCH /sessions/{id} with { "name": "..." } renames it.

Create a session

POST/sessions
Start a new agent session. Returns 201 with the created session.
ParameterTypeRequiredDescription
repoPathstringRequiredWorking folder for the session. Must exist. Use forward slashes, e.g. "D:/repos/my-project".
agentstringOptionalWhich agent to run. Defaults to "ClaudeCode"; "Pi" is the other verified driver. "RawCli" runs any command-line tool.
namestringOptionalDisplay name for the card. Composed automatically when omitted.
purposestringOptionalShort note on what the session is for; used to compose the name when name is omitted.
prePromptstringOptionalA first prompt sent automatically once the agent is ready - the way to launch a task unattended.
prePromptWaitMsnumberOptionalHow long to wait for the agent to become ready before sending prePrompt. Default 30000.
argsstringOptionalExtra command-line arguments for the agent. Defaults per agent when omitted.
commandstringOptionalThe executable to run. Required when agent is "RawCli".
commandArgsstringOptionalArguments for the RawCli command.
resumeSessionIdstringOptionalResume a previous Claude Code conversation instead of starting fresh.
PowerShell
'{
  "repoPath": "D:/repos/my-project",
  "agent": "ClaudeCode",
  "name": "nightly-refactor",
  "prePrompt": "Run the test suite and fix any failures you find."
}' | Out-File -Encoding ascii new-session.json

curl.exe -s -X POST http://127.0.0.1:7879/sessions `
  -H "Content-Type: application/json" `
  --data-binary "@new-session.json"
Tip
Write the JSON body to a file and post it with --data-binary. Shells - especially Git Bash on Windows - mangle backslashes and quotes in inline JSON, and a mangled body comes back as a bare 400 with no error message. Forward slashes in repoPath avoid the backslash problem entirely.

Send prompts and queue work

POST/sessions/{id}/prompt
Send text into the session's terminal now. Body: { "text": "..." }. Returns whether it was accepted and the session's activity state; 409 if the session has exited.
POST/sessions/{id}/queue
Queue a prompt instead - it is delivered when the agent is ready. GET the same path lists the queue; DELETE /sessions/{id}/queue/{itemId} removes one item, and DELETE /sessions/{id}/queue clears it.

Interrupt and close

POST/sessions/{id}/interrupt
Hard-interrupt the agent (the API equivalent of the Interrupt button).
DELETE/sessions/{id}
End the agent process and remove the session from the board.

Fleet calls through the Gateway

The Gateway (port 7878) aggregates every Director on the machine and relays to them - that is what the Cockpit and your phone talk to, and its routes require the machine's Gateway token as a bearer token. Two relays worth knowing: GET /directors lists the registered Directors with their machineName and controlEndpoint, and POST /directors/{id}/sessions creates a session on a specific Director through the Gateway. For scheduling work rather than scripting it, use the built-in cron, which drives this same API under the hood.