HTTP API & streams.

One HTTP and streaming surface behind the workbench, CLI, SDKs, and MCP — running identically on Cloudflare Workers or locally under workerd.

Base URLs and local parity

deploymentoriginbehavior
Production cloudhttps://api.commandagi.comGlobal 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:

shell
curl https://api.commandagi.com/v1/me \
  -H "Authorization: Bearer cagi_YOUR_KEY"
  • OAuth 2.0 + PKCE: Public clients hitting POST /mcp without headers receive a 401 challenge 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 return 412 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/events flushes 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: websocket on thread/channel endpoints for synchronized HLC frames without polling.
  • Append-only NDJSON & multipart uploads: Stream writers append ordered records (application/x-ndjson, guarding offsets with x-commandagi-expect-size) so interrupted links stay consistent.

Complete endpoint groups

grouprepresentative endpoints
account, orgs & settingsGET /me · GET POST /accounts · GET PUT PATCH /accounts/:id/settings · GET /accounts/me/chain · /orgs
standing grants & keysGET POST /accounts/:id/standing-grants · DELETE /standing-grants/:id · /accounts/:id/signing-key · /keys
hosts & relaysGET /accounts/:id/hosts · POST /hosts/:hostId/call · /embodiment-threads · /vpn/*
Drives, git & searchGET /drive · POST /drive/upload · GET PUT /drive/:id/content · /me/files/search · /me/embeddings · /me/graph · /accounts/:id/git/*
agents & threadsGET POST /agents · /agent-sign-ins · GET /me/threads · POST /threads · GET /threads/:id/events · POST /threads/:id/inject · /evals
MCP & agent interopPOST /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 & healthGET /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

statusmeaning
401Missing or invalid bearer credential (cagi_… or OAuth token)
403Authenticated principal lacks required role, scope, or standing grant
404Resource absent or invisible to the caller's account
409State or dependency conflict on mutation or delete
412Optimistic lock conflict (If-Match / If-None-Match, stale_file)
422Code document AST/schema refusal or restricted source terms failure
428Required If-Match or If-None-Match precondition header omitted
503Upstream dependency unavailable or needs_cloud when local workerd is offline