Base URLs and local parity
| deployment | origin | behavior |
|---|---|---|
| Production cloud | https://api.commandagi.com | Global API, Durable Object threads, cloud Drives, billing, and MCP (453 tools) |
Local platform (workerd) | http://127.0.0.1:<port> | Identical worker bundle via commandagi platform start; forwards cloud-only authority/billing routes when signed in |
All routes resolve identically with or without a /v1 prefix (/v1/threads and /threads match the same handler).
Authentication and headers
Pass an API key (cagi_ + 64 hex chars, hashed on disk/D1) or OAuth 2.0 PKCE access token as a bearer header:
curl https://api.commandagi.com/v1/me \
-H "Authorization: Bearer cagi_YOUR_KEY"- OAuth 2.0 + PKCE: Public clients hitting
POST /mcpwithout headers receive a401challenge pointing to OAuth discovery metadata for interactive login. - Organization context: Send
x-cagi-account: <account-id>to scope calls to an organization account. - WebDAV & Git endpoints: Accept the same
cagi_…key as HTTP Basic-auth password. - Equal principal enforcement: Both human and agent keys check caller role, scopes, and standing grants identically; requests lacking an identifiable principal return
403 named_principal_required.
Optimistic concurrency (ETag)
File and world.tsx writes guard against silent overwrites using standard HTTP preconditions:
- Send
If-Match: "<sha256>"when updating an existing file. - Send
If-None-Match: *when creating a file that must not already exist. - Missing preconditions return
428; concurrent modification mismatches return412 stale_file.
Event logs and real-time streams
Thread chat turns, tool dispatches, run records, and sensor streams use unified incremental queries, WebSockets, and append-only NDJSON uploads:
- Thread event windowing:
GET /threads/:id/eventsflushes buffered Durable Object turns and accepts?after=<seq>,?cursor=<seq>,?limit=1..2000,?kind=,?type=, and?class=filters. - Live WebSocket streams: Workbench sessions and thread monitors connect with
Upgrade: websocketon thread/channel endpoints for synchronized HLC frames without polling. - Append-only NDJSON & multipart uploads: Stream writers append ordered records (
application/x-ndjson, guarding offsets withx-commandagi-expect-size) so interrupted links stay consistent.
Complete endpoint groups
| group | representative endpoints |
|---|---|
| account, orgs & settings | GET /me · GET POST /accounts · GET PUT PATCH /accounts/:id/settings · GET /accounts/me/chain · /orgs |
| standing grants & keys | GET POST /accounts/:id/standing-grants · DELETE /standing-grants/:id · /accounts/:id/signing-key · /keys |
| hosts & relays | GET /accounts/:id/hosts · POST /hosts/:hostId/call · /embodiment-threads · /vpn/* |
| Drives, git & search | GET /drive · POST /drive/upload · GET PUT /drive/:id/content · /me/files/search · /me/embeddings · /me/graph · /accounts/:id/git/* |
| agents & threads | GET POST /agents · /agent-sign-ins · GET /me/threads · POST /threads · GET /threads/:id/events · POST /threads/:id/inject · /evals |
| MCP & agent interop | POST /mcp · GET /.well-known/agent-card.json · /arbitrate |
| engineering & simulation | /kernels/3d/v1/* · /kernels/fea/v1/* · POST /physics/runs · /fab/* · /kicad-library/* · /worlds/* · /sims/* |
| Matrix, geo & world events | /v1/matrix/join · /v1/matrix/streams · /world/events/* · /news/* · POST /geo/ingest · /v1/foresight/* |
| sites, comms, money & markets | /sites/* · /mailboxes/* · /email/* · /shipping/* · /money/* · /trading/venues · /trading/order · /trading/cancel · /services/* · /bounties/* |
| models & health | GET /models · GET /models/families · POST /models/call · GET /capacity · GET /health |
Models (CommandAGI-000 & BYOK)
GET /models enumerates selectable models (?useCase=think|robot_think|realtime|realtime_stt), and GET /models/families lists routable route:<family> keys. First-party capabilities run under commandagi/CommandAGI-000 (with specialized endpoints such as commandagi/000-perceive), while organization/account BYOK provider credentials override or extend available models per scope.
HTTP status semantics
| status | meaning |
|---|---|
401 | Missing or invalid bearer credential (cagi_… or OAuth token) |
403 | Authenticated principal lacks required role, scope, or standing grant |
404 | Resource absent or invisible to the caller's account |
409 | State or dependency conflict on mutation or delete |
412 | Optimistic lock conflict (If-Match / If-None-Match, stale_file) |
422 | Code document AST/schema refusal or restricted source terms failure |
428 | Required If-Match or If-None-Match precondition header omitted |
503 | Upstream dependency unavailable or needs_cloud when local workerd is offline |