Appearance
API
Orbit has three doors onto the same commands and queries: GraphQL, MCP and the CLI. They run the same handlers with the same authorisation and audit. The reference lists the operations by module.
| Door | Endpoint | For | Token |
|---|---|---|---|
| GraphQL | POST /graphql | the web app, integrations | sidecar JWT |
| MCP | POST /mcp | AI agents and MCP clients | MCP token from POST /mcp/token |
| CLI | the orbit binary | scripts and admins | sidecar JWT, via orbit login |
| SCIM 2.0 | /scim/v2 | identity providers | SCIM token from an owner |
| Files | POST /files/<module>/<purpose> | uploads (receipts, CVs, policy PDFs) | sidecar JWT |
Authentication
Every request needs a bearer token from the auth sidecar:
Authorization: Bearer <token>- Sign in to the sidecar (
POST /api/auth/sign-in/email, or OIDC single sign-on). This sets a session cookie. - Choose the organisation to act in (
POST /api/auth/organization/set-active). - Get a token with
GET /api/auth/token. It returns{ "token": "..." }.
In the self-hosted stack the sidecar is reached on the same origin as Orbit, under /api/auth. Open email sign-up is off there: accounts come from deploy/bootstrap.sh, an operator or the optional OIDC provider.
The token lasts 15 minutes. Get a new one before it expires. The organisation must have been provisioned as an Orbit tenant by an operator (orbit tenant provision), or every request is refused as UNAUTHENTICATED. Your role in the organisation (owner, admin or member) is read from the token on each request. The sidecar's endpoints are listed in services/auth/README.md.
GraphQL
POST /graphql with a JSON body { "query": "...", "variables": { ... } }. Each command is a mutation and each query is a query field. Each field takes one input argument and returns a JSON value.
graphql
mutation { helloGreetingPost(input: { text: "Hello" }) }MCP
POST /mcp: an MCP server over Streamable HTTP. It is stateless, answers with JSON (no server-sent events) and takes one JSON-RPC message per request. Requests that carry an Origin header are refused. tools/list shows only the tools of modules your tenant has enabled. A successful tool call returns { "result": <output> } as structured content.
/mcp takes an MCP token, not a sidecar token. A person signed in to the web app gets one for their agent with POST /mcp/token and their sidecar token as the bearer; it returns { "token", "expiresAt", "agent" } and lasts one hour. MCP tokens work on /mcp only: /graphql and the CLI refuse them. POST /mcp/token/revoke (same bearer) revokes every MCP token the person holds in the tenant and returns { "revokedAt" }.
A tool marked sensitive does nothing on its first call. It asks the person the agent acts for to approve that exact call and returns { "status": "approval_required", "tool", "confirmation_id", "expiresInSeconds": 1800, "message" }. The person approves or rejects it in the web app's approval queue. Then call the tool again, within 30 minutes of the first call, with exactly the same arguments plus "confirm": true and the confirmation_id. It works once, with the same token. Before the approval it is refused with CONFLICT and reason: "not_approved"; other reasons are rejected, expired, used and mismatch. See Security model.
CLI
The CLI is part of the orbit binary. It calls /graphql and never connects to the database.
bash
printf '%s' "$TOKEN" | orbit login --server http://127.0.0.1:8080
orbit hello greeting post --text "Hello"
orbit hello greeting list --json
orbit logoutorbit login reads the token from standard input and never prints it. It is stored in credentials.json under $ORBIT_CONFIG_DIR, else $XDG_CONFIG_HOME/orbit, else $HOME/.config/orbit. Each command also takes --server <URL> and --input-json <JSON> (field flags override its fields). With --json, standard output carries exactly one JSON document: {"ok": true, "data": ...} or {"ok": false, "error": {"code", "message", "requestId"}}.
SCIM
/scim/v2 serves SCIM 2.0 Users and Groups (the two roles, admin and member) for identity providers, with a bearer token an owner creates (Provisioning, ADR 0010). It is served only when the operator has set ORBIT_AUTH_PROVISION_SECRET and the sidecar upstream.
Files
Uploads go through the files door as bus commands: POST /files/<module>/<purpose> returns an upload id that a later command consumes once. Downloads use single-use, short-lived links (ADR 0009).
Request ids
Every HTTP response carries an x-request-id header with a fresh id. Errors repeat it as requestId. The server log records the full reason for a refusal under that id, so quote it when you report a problem.
Error codes
Every door reports the same six codes. Each has one fixed message. The reason behind a refusal is never sent to the caller.
| Code | Message | Meaning | HTTP status (before the operation runs) | CLI exit code |
|---|---|---|---|---|
UNAUTHENTICATED | authentication required | No token, a bad or expired token, or an organisation that is not a provisioned tenant | 401 | 3 |
FORBIDDEN | not allowed | A policy denied it, the module is not enabled for the tenant, or the caller made too many rejected attempts | 403 (429 when the caller has too many requests in flight) | 4 |
NOT_FOUND | not found | A record that does not exist, or that you may not see | 404 | 5 |
INVALID | invalid input | Input does not match the schema or the module's rules | 400 (413 for a body over 1 MiB, 408 for a body sent too slowly) | 6 |
CONFLICT | conflict | The change conflicts with the current state | 409 | 7 |
INTERNAL | internal error | Anything else. Details are in the server log only | 500 | 8 |
The CLI also exits with 0 on success, 1 when it could not finish (for example, the server is unreachable) and 2 for a usage error.
How each door reports them:
- GraphQL. An error inside an operation comes back with HTTP 200 in the
errorsarray, withextensions.codeandextensions.requestId. A request refused before the schema runs (authentication, a body that is too large or not JSON) gets the HTTP status above and the sameerrorsshape. - MCP. A refused tool call returns a tool error whose structured content is
{ "code", "message", "requestId" }. A request refused at authentication gets HTTP 401 (withWWW-Authenticate: Bearer) or 403 and the same JSON object. - CLI. The exit code in the table, and the error on standard error (or in the
--jsondocument).
Limits
- 20 fields per GraphQL request. Each selected field counts as 1, aliases included. Fields run at the same time and each can dispatch a command, so this stops one request from turning into many attempts. A request over the limit is refused before anything runs, with an error whose message says the query is too complex. Query depth is limited to 16.
- 20 rejected attempts per caller per minute. Denials and failed commands count. After that, requests are refused with
FORBIDDENuntil the minute passes. - 32 requests in flight per caller, on GraphQL and MCP together. More are refused at once with HTTP 429 and
FORBIDDEN. - 20 open agent requests per person, and 10 MCP tokens per person per hour.
- 1 MiB request body, read only after the token is accepted. It must arrive within 5 seconds, or the request is refused with HTTP 408.
- 30 seconds per request, then HTTP 503. A command that was already dispatched still completes and is audited.
Generated files
The schema, the tool list and the CLI help are generated from the command registry. Tests in crates/orbit-bin compare them with these committed snapshots and fail if they drift:
| File | Build |
|---|---|
schema.all-modules.graphql | Every module (--features hello) |
mcp-tools.all-modules.json | Every module |
cli-help.all-modules.txt | Every module |
schema.graphql, mcp-tools.json, cli-help.txt | No optional modules |
After a deliberate change, regenerate them with UPDATE_SNAPSHOTS=1 cargo test -p orbit and UPDATE_SNAPSHOTS=1 cargo test -p orbit --all-features, and commit the files.