API
Everything the web UI and anastroctl do flows through HTTP APIs defined by OpenAPI 3.1 specs.
OpenAPI documents
Section titled “OpenAPI documents”Every OpenAPI document is generated from the server code and committed under
api/openapi/ (CI fails on
drift, so the files always match the code):
| File | Scope | Served by | Transport |
|---|---|---|---|
cluster.json |
Orgs, projects, machines, threads, filesystems, hosts, inference, integrations, auth, cluster secrets | apid on control-plane nodes |
iroh ALPN anastro/api/1, loopback HTTP |
node.json |
Node health, services, logs, config, upgrades, Postgres, etcd, backups, storage probes, reset |
machined on every node |
iroh ALPN anastro/node/1 |
maintenance.json |
Hardware inspection and initial config during maintenance mode | machined (unconfigured nodes) |
iroh ALPN anastro/node/1 |
dwfs.json |
Workspace control API for runners (leases, heads, locations) | apid |
iroh ALPN dwfs/1 (internal) |
agents.json |
Agents sidecar API called only by local apid |
anastro-agents (127.0.0.1:7445) |
Loopback HTTP (internal) |
Most automation targets cluster.json. The node API (node.json) stays reachable even when apid
or Postgres is down—it powers node status, node services, node logs, cluster apply,
cluster upgrade, and cluster backup.
Each operation declares its minimum role in x-roles, which compiles into the Cedar policies under
api/policies/
(Authorization).
Interactive API docs
Section titled “Interactive API docs”Every apid serves an interactive Scalar UI at /api/docs and the raw spec at
/api/openapi/cluster.json. Launch anastroctl ui and visit /api/docs on the localhost origin it
prints.
Transports
Section titled “Transports”| Transport | Used by | How it works |
|---|---|---|
| HTTP over iroh | anastroctl, anastroctl ui, native apps, host agents, peer nodes |
QUIC on UDP 7444; each bidirectional stream carries one HTTP/1.1 connection, routed by ALPN. The caller’s iroh endpoint ID is its identity. |
| Loopback HTTP | Local dev stack (apid on 127.0.0.1:7443) |
Plain HTTP on loopback only. |
machined owns each node’s UDP 7444 iroh endpoint, handles anastro/node/1 itself, and forwards
anastro/api/1 and dwfs/1 streams to apid over a local Unix socket. Unknown peers are dropped
immediately after the handshake (except in maintenance mode, host registration, and peer unsealing).
By design, Anastro exposes no public HTTPS API endpoint. Browsers reach the API through
anastroctl ui or the native apps over loopback; the optional
Cloudflare Tunnel carries only webhooks, OAuth redirects,
/.well-known/anastro, and relays.
Authentication
Section titled “Authentication”| Credential | Presented via | Used by |
|---|---|---|
| Device key | iroh endpoint identity | anastroctl, anastroctl ui, native apps, anastroctl mcp serve, anastroctl inference proxy |
| Operator key | iroh endpoint identity (--as-operator) |
Keys in cluster.operator_keys: full node API admin (works without Postgres), plus host list/cordon/drain/rebalance on cluster API |
| API key | iroh endpoint identity (ANASTRO_KEY or --key-file) |
Scripts, CI, and service accounts (account key create --ttl <ttl>, optional --project and --scope, max [auth] api_key_max_ttl = 90d default) |
| Gateway token | Authorization: Bearer agw1.… or x-api-key |
/v1/inference/… only (thread, machine, and personal gateway tokens) |
Gateway tokens are stored only as hashes; for API keys, the cluster only stores the public key.
apid accepts no browser cookies.
Sensitive actions (approving devices, creating invites, issuing recovery links, linking model
accounts, revealing secrets, deleting projects) strictly require a human device key—API keys and
MCP calls receive 403.
Errors
Section titled “Errors”Errors follow RFC 9457 (application/problem+json):
{ "type": "about:blank", "title": "Forbidden", "status": 403, "detail": "this needs a device key"}Missing resources return 404.
Streaming
Section titled “Streaming”Long-running endpoints stream Server-Sent Events (text/event-stream):
| Endpoint | Stream contents |
|---|---|
GET /v1/threads/{id}/events |
Live thread events |
POST /v1/machines/{id}/bash |
Command output (output events, ending with result) when Accept: text/event-stream is set |
POST /v1/inference/responses, …/chat/completions, …/messages, …/anthropic/v1/messages |
Streamed model completions |
GET /v1/services/{name}/logs?follow=true (node API) |
Live systemd journal stream |
Interactive shells use WebSockets: GET /v1/machines/{id}/terminal?rows=<rows>&cols=<cols>
upgrades (101) to a login shell on a running machine.
Raw GET calls with anastroctl
Section titled “Raw GET calls with anastroctl”Query any cluster API GET endpoint directly over iroh as your device:
anastroctl api get /v1/machinesanastroctl api get /api/openapi/cluster.json -n <node>Targets the first node in your context unless -n specifies one. Only GET is supported; use
resource subcommands for mutations (CLI reference).
Full design: API definition and authentication in the spec.