Skip to main content

HTTP API

The daemon listens on loopback only (default http://127.0.0.1:7644). The route table is Daemon.Handler in host/daemon/daemon.go. Routes use Go method patterns, so a wrong method gets 405 Method Not Allowed from the router.

MethodPathAuthPurpose
GET/v1/healthnoneDaemon status and interpreter pin
GET/v1/headnoneSelected world head (plain text)
GET/v1/worlds/{ref}noneOne world row
GET/v1/objects/{ref}noneOne object, payload optional
GET/v1/objects/by-semantic-id/{name...}noneObjects with a given semantic ID, paged
GET/v1/log/{index}noneOne log entry
GET/v1/lognoneA page of log entries
GET/v1/registry/{name...}noneA registry head
POST/v1/commitsessionCommit a world transition (the only REST mutation)
GET/v1/receipts/{id}noneReceipt of a rest: commit
GET/v1/episodes/{episode}/reportnoneOne episode's summary: calls by tool, effects, budgets, refusals
GET/v1/session/selfsessionThe calling session's episode, time left and grants
GET/workbenchnoneRead-only HTML operator renderer
GET/workbench/live.jsnoneThe workbench's embedded same-origin live client script
GET/.well-known/agent.jsonsessionSession-scoped A2A agent card
POST/a2a/sessionA2A JSON-RPC (tasks/send)
POST/mcp/sessionMCP Streamable HTTP (initialize, ping, tools/list, tools/call)
POST/agui/noneRead-only AG-UI 1.0 SSE run of the world's live state, bounded to 18 s; resume with standard state or Last-Event-ID (QUICKSTART, "Watch the world live")

The other eleven /v1 routes are the frozen v1 machine table, pinned against a checked sketch by a test. /v1/session/self (row 223d), /workbench, /workbench/live.js, the agent card, /a2a/, /mcp/ and /agui/ are additive.

Auth means Authorization: Bearer <64-hex-credential> holding a live session (see Sessions and episodes). The GET /v1/* routes are not authenticated today, except GET /v1/session/self.

Conventions​

Refs are canonical sha256:<64 hex> text. A malformed ref is 400 BadRequest naming the field.

Errors on the /v1 routes and the agent card use one envelope:

{"error":{"class":"NotFound","message":"log entry not found"}}
ClassStatusMeaning
BadRequest400The client's input is malformed; the message names what (not sanitized)
InvalidSession400Malformed Authorization header
SessionAbsent, SessionUnknown, SessionExpired401No, unknown or expired session
NotFound404The thing is not there (distinct from malformed)
HeadConflict409Stale observedHead; carries observedHead and selectedHead
PayloadTooLarge413Commit body over 8 MiB
Internal500Always the fixed message internal store failure; the cause goes to the daemon's stderr
Timeout503A read (10 s), commit (3 s) or credential lookup (3 s) deadline ended
CommitUncertain503The commit's outcome is unknown; reconcile before resending
LookupIndexUnavailable503The semantic-ID index is absent or incompatible
ProjectionUnavailable503Agent card: a registry read failed; retry
ProjectionDeadlineExceeded504Agent card: the bounded read deadline was hit

Paging. limit defaults to 100 when absent or below 1, and is capped at 500.

GET /v1/health​

{"status":"ok","daemon_version":"0.1.0","db_path":"/tmp/world-demo.db",
"interpreter_ref":"sha256:…","interpreter_version":"AILANG v0.41.0\nCommit: 24ee108\n…"}

interpreter_ref and interpreter_version are empty when serve ran without --ailang-bin.

When serve has --workspace-root and some episode directory under it is not a git worktree (adopted with session new --allow-non-git), the body adds degraded_episodes, a list of those episode IDs (row 185). The key is absent otherwise, so the body of a daemon with no degraded episode is unchanged.

GET /v1/head​

200 text/plain: the selected head ref, for example sha256:…. 404 NotFound no world head has been selected yet before genesis.

GET /v1/worlds/{ref}​

{"ref":"sha256:…","revision":0,"stateRoot":"sha256:…","logHead":"sha256:…"}

404 NotFound world not found.

GET /v1/objects/{ref}​

{"hash":"sha256:…","interfaceHash":"sha256:…","semanticId":"world/effect-record/v1",
"provenance":"…"}

Add ?payload=true to include "payload":"<base64>". Without it the key is absent, so object reads stay bounded. 404 NotFound object not found.

GET /v1/objects/by-semantic-id/{name...}​

The name may contain slashes. Query: after=<ref> resumes strictly after that hash; limit=N.

{"items":[{"hash":"sha256:…","interfaceHash":"sha256:…","semanticId":"world/invocation-record/v2","provenance":"coordinator:mcp"}]}

Ascending hash order, never payloads. A name no object carries is 200 with "items":[], never 404. 400 for an empty name, a malformed after or a non-integer limit; 503 LookupIndexUnavailable if the index is missing.

GET /v1/log/{index}​

{"header":{"entryIndex":1,"semanticsEpoch":1,"transitionFn":"sha256:…",
"interpreter":"sha256:…","prevEntryHash":"sha256:…","writtenBy":"coordinator:mcp"},
"entryHash":"sha256:…","transitionRef":"sha256:…"}

400 log index must be a non-negative integer; 404 NotFound log entry not found.

GET /v1/log?from=N&limit=M​

{"items":[ {…log entry…}, … ]}

from defaults to 0 and must be a non-negative integer. The page stops at the first absent index, so from past the end returns "items":[]. The whole page shares one 10 s read deadline.

GET /v1/registry/{name...}​

{"name":"world/epoch-registry/v1","head":"sha256:…"}

Names in use: world/epoch-registry/v1 (bootstrapped at startup), world/transition-registry/v1 (after a transitions publish), world/approvals/v1. 404 NotFound registry head not found.

POST /v1/commit​

Requires a session. Body: one JSON object; unknown fields and trailing values are refused.

{
"invocationId": "rest:<your-id>",
"observedHead": "",
"objects": [
{"hash": "sha256:…", "interfaceHash": "sha256:…", "semanticId": "…",
"provenance": "…", "payload": "<base64>"}
],
"nextWorld": {"ref": "sha256:…", "revision": 0, "stateRoot": "sha256:…", "logHead": "sha256:…"},
"entry": {
"header": {"entryIndex": 0, "semanticsEpoch": 1, "transitionFn": "sha256:…",
"interpreter": "sha256:…", "prevEntryHash": "sha256:…", "writtenBy": "…"},
"entryHash": "sha256:…",
"transitionRef": "sha256:…"
}
}
  • invocationId is optional and must start with rest:. With it, the commit's intent is journaled first and a receipt is available; resending the same commit with the same ID is idempotent, and reusing the ID for a different commit is 400.
  • observedHead is empty only for genesis.
  • Each object's hash must be sha256: of its payload bytes; the store verifies it.

Success: 200 {"selectedHead":"sha256:…"}.

FailureResponse
No or bad session401/400 session classes
Body over 8,388,608 bytes413 PayloadTooLarge
Invalid JSON, unknown field, bad ref400 BadRequest naming the problem
Stale observedHead409 HeadConflict with observedHead, selectedHead
Budget ended before the durable step503 Timeout: not committed; safe to resend
Budget ended after the durable step began503 CommitUncertain: reconcile via GET /v1/receipts/{id} (with an invocationId) or GET /v1/log/{entryIndex} before any resend
Payload/hash mismatch, other store failures500 Internal

GET /v1/receipts/{id}​

Only IDs starting with rest: (otherwise 400 receipt id must be rest:<id>).

{"invocationId":"rest:demo-1","state":"resolved","resultRef":"sha256:…"}

state is resolved (it landed; resultRef is the committed nextWorld.ref), not-started or indeterminate. Treat indeterminate as not landed and fail-closed.

GET /v1/episodes/{episode}/report​

One episode's summary in one pass over that episode's own journal rows and the records they name (row 198); ailang-worldd episode report <episode> --json prints this body unchanged.

{"episode":"ep1","entries":[12,40],"total_calls":27,
"calls_by_tool":{"ailang-edit":9,"ailang-read":12,"workspace-exec":6},
"effects":[{"effect":"Workspace.Exec","decision":"allowed","count":6},
{"effect":"Workspace.Read","decision":"allowed","count":11}],
"budgets":[{"effect":"Workspace.Exec","scope":"worktree","minted":600,"used":6,"left":594}],
"plan_refusals":{"count":1,"by_tool":{"ailang-read":1},
"first":[{"entry":15,"tool":"ailang-read","reason":"missing required argument \"path\""}]},
"handler_refusals":{"count":0,"by_tool":{},"first":[]},
"first_at":"2026-10-19T09:00:00Z","last_at":"2026-10-19T09:31:12Z",
"calls_by_surface":{"mcp":27},"uncommitted_intents":0,"notes":{"…":"…"}}

decision is allowed, failed or denied:<denial>. A plan refusal named no effect and answered ok:false; a handler refusal's effect was allowed and ran, but its result is ok:false. budgets has one row per (effect, scope) with an effect record: left is the latest budgetAfter, used the cost of the allowed records. Times are the coordinator's logical clock (UTC). An episode with no committed call is 404 NotFound. Unauthenticated like the other GET routes (residual R1, row 199).

GET /v1/session/self​

Requires a session. What the caller's own session may do: its episode, worktree, time left and grants. ailang-worldd whoami calls it, and so does the context block every World launch starts with (see Run your agents through World).

curl -s -H "Authorization: Bearer $WORLD_SESSION" http://127.0.0.1:47330/v1/session/self
{"episode":"ep1","worktree":"<workspace-root>/ep1","expiresAt":1793000000,"secondsLeft":6120,
"grants":[{"effect":"Workspace.Read","scope":"worktree","budget":50,"used":2,"left":48}],
"entries":{"first":12,"last":40},
"addr":"http://127.0.0.1:47330","surface":"http://127.0.0.1:47330/surface"}
  • expiresAt is Unix seconds; secondsLeft is never below 0.
  • grants has one row per granted (effect, scope): used is what the episode has spent, left is budget − used, never below 0. Budgets persist per episode, across sessions.
  • entries is the episode's first and last log entry. It is absent when the episode has no committed call yet.
  • worktree is <workspace-root>/<episode>, or empty when serve has no --workspace-root.
  • addr is http:// plus the request's Host; surface is addr plus /surface.

Every session denial is 401, malformed headers included (other routes answer a malformed header with 400). The body is the REST error envelope:

ClassMessage
SessionAbsenta session credential is required: no Authorization Bearer header was present
InvalidSessionmalformed Authorization header: expected a Bearer <64-hex-credential>
SessionUnknownunknown session credential: no session matches this token
SessionExpiredsession credential has expired

A credential lookup or read past the 10 s read deadline is 503 Timeout; a store failure is 500 Internal.

GET /workbench​

200 text/html with a strict Content-Security-Policy and Cache-Control: no-store. Query parameters: world, object, from, entry, payload (0 or 1), refsAfter, commitsAfter; an unknown or repeated parameter is 400. Not part of the frozen API; its HTML may change.

GET /.well-known/agent.json​

Requires a session. Returns the A2A agent card, with skills listing exactly the transitions this session's grants admit, in registry byte order:

{"name":"ailang-worldd","description":"…","url":"http://127.0.0.1:7644","version":"0.1.0",
"capabilities":{"streaming":false,"pushNotifications":false,"stateTransitionHistory":false},
"defaultInputModes":["application/json"],"defaultOutputModes":["application/json"],
"skills":[{"id":"ailang-read","name":"Read (sandboxed)","description":"…","tags":[],"examples":[]}]}

No registry head yet means 200 with "skills":[]. Session denials use the REST error envelope above; a failed registry read is 503 ProjectionUnavailable, a deadline 504 ProjectionDeadlineExceeded.

POST /a2a/ and POST /mcp/​

See MCP and A2A.