HTTP API

Which of Kraft's HTTP routes are stable, which the pages here document, where the full schema is, and who may call them.

The Kraft server serves its board, and the JSON API behind it, on one port (127.0.0.1:8765 by default). The kraft command and the MCP server are clients of that API. Two routes are stable. The pages here document the work-item routes a script plausibly calls, and the schema lists every route: /openapi.json, with /docs and /redoc to read it.

A script that must outlive a release calls the two stable routes, kraft … --json or the MCP server, not the board's routes.

Stable routes

Only two routes are meant for other programs, and only these keep their shape between minor releases. The schema tags them stable. See Versioning and stability. Who may call them is under Who may call.

RouteUse
POST /api/triggersFile a work item from a webhook or script. See Inbound triggers.
GET /api/healthCheck that the server is up. Needs no login. See GET /api/health.

GET /api/health

curl -s http://127.0.0.1:8765/api/health | jq .status

The answer carries:

FieldMeaning
statusok or degraded.
invalid_templates, invalid_policy, invalid_intake, invalid_forgesThe reasons it is degraded. invalid_intake is why intake.yaml doesn't load, else null; invalid_forges is the same for forges.yaml.
forge_tokensEach client: api account's last token check, by name: {state, expires_on}, never who it signs in as. A state of no_token, refused, forbidden or tls, or an expires_on within 7 days, makes status degraded. Added in 2.5
storagenull without storage.worktrees.limit, else {state, used_bytes, quota_bytes, limit_bytes, measured_at, too_recent}. state is ok, over_quota or held, and held makes status degraded. too_recent counts finished items the last automatic clean-up left because they ended less than min_age ago.
intake_offWhether auto-intake and intake.yaml's schedules are off for it.
mcp_command_on_pathWhether Claude can start its user- or plugin-scope kraft MCP server on the server's PATH, which workers get. It leaves out a repo's own entries, which a launch also counts. null: nothing to check. Added in 2.5
addon_updatesEach auto-updating add-on's last update, by add-on id: {outcome, kind}, without the message, which kraft admin doctor shows. Empty when none has run. See Auto-update.
run_dir, pid, uptime_s, bind, portWhich instance this is.
versionThe version it runs.
installedThe version installed on disk, which differs until a restart finishes an update.
reattach_summaryWhat startup found of agent sessions that were running: scanned, adopted, resolved_from_file, unknown and resumed_work_items. Each adopted, resolved_from_file and unknown entry is <work item id>/<session id>, since a session ID is unique only within its work item.
indexThe search index: last_scan_at, repos_scanned, documents, and the state of embeddings.
kraft_default{signature, count}: a short hash of the lines the kraft-default row of kraft admin doctor shows, and how many; {signature: null, count: 0} when none. The lines are on GET /api/kraft-default. Added in 2.6
session_expiry_daysHow long a login lasts, which the login screen shows.

An add-on that is installed and didn't load is under invalid_templates, as add-on <id> with the reason, and status is degraded. A held or failed entry of addon_updates leaves status as it is.

intake_off is true when the server started on an intake.yaml that doesn't load. A trigger left in policy.yaml still fires. It is false when a reload refused the file and the running schedules are kept.

Who may call

CallerWhat it needs
A process on the same machine, while Kraft is bound to loopbackNothing, as long as it addresses the server as 127.0.0.1, localhost or [::1].
Anyone, once Kraft is bound off loopbackA browser session from the login page, or the MCP bearer token in $KRAFT_HOME/run/mcp-token, sent as Authorization: Bearer <token>.
A trigger sender, once Kraft is bound off loopbackFor POST /api/triggers only, the trigger token in $KRAFT_HOME/run/trigger-token, sent the same way.
A remote caller while no password is setNothing works. Kraft answers 403.

The MCP bearer token is a full-access credential. See Security for the whole model, and Remote access to set a password.

Refusals

StatusWhen
401The request has no valid credentials.
403A remote caller, while no password is set.
403The Host isn't an allowed name: unexpected Host for a server bound to …. See the rules below.
403A cross-site write. The /api/ws/events WebSocket refuses the handshake the same way when its Origin is another site's.

A Host isn't allowed when:

  • Kraft is bound to loopback and the request isn't addressed to 127.0.0.1, localhost or [::1].
  • Kraft is bound off loopback and the request comes from a browser (it sends Sec-Fetch-Site, Origin, Referer or an HTML Accept) whose Host is neither a loopback name nor in allowed_hosts. The CLI, MCP and curl need no entry there.

A browser opening a page (a GET outside /api with an HTML Accept) gets the 403 as a short HTML page instead. The page names the Host it sent and how to allow it. The WebSocket applies the same Host rules.

The schema

FastAPI generates a schema of every HTTP route, including the ones these pages leave out:

PathWhat it serves
/openapi.jsonThe OpenAPI schema, as JSON. Its info names Kraft and the installed version.
/docsSwagger UI for that schema.
/redocReDoc for that schema.
curl -s http://127.0.0.1:8765/openapi.json | jq '.paths | keys | length'
curl -s http://127.0.0.1:8765/openapi.json | jq '[.paths[][] | select(.tags | index("stable")) | .summary]'

These three paths need no login. Open /docs or /redoc in a browser to read the API there. Both pages load their scripts from a public CDN, jsdelivr, each pinned to one exact release that your browser refuses unless it matches the hash Kraft ships. Nothing else on either page comes from another site. On a machine without internet access, load /openapi.json into your own OpenAPI viewer.

What the schema covers

Added in 2.6

Every route has a summary, a description and a tag. A route with a typed body lists its fields. GET /api/work-items and GET /api/work-items/{id} also describe their answers. The schema names the stable fields and allows others, so a client should ignore keys it doesn't know. A route's tag is its group:

TagRoutes
stableThe two stable routes, which also carry their own group's tag.
work itemsFiling, reading, changing, events, diff, documents and attachments.
gates and run controlGates, pause, resume, skip, escalate, end, archive, retry and the routes a worker calls.
reviewReview threads, their comments and submitting a review.
forge readsAn item's merge request, pipelines, jobs, job logs, merged requests and labels.
worker sessionsSession logs, sub-agents and permission asks.
draftsThe Templates and Settings editors' drafts and their ops, and an item's own draft.
repos, forges and workersRepos, forge accounts and worker machines.
chainsChain templates, the library and the config checks.
harnessesHarness profiles and providers.
settingsPolicy, theme, intake, access, notifications and update settings.
search and analyticsSearch, the index, indexed documents, editors and analytics.
authLogin, logout and the browser sessions.
serverHealth, applying saved changes, updates and storage.

The schema describes the answers of only the work item list and detail routes, which the other routes build by hand. The work item object is the full reference for the one a client reads. The /api/ws/events WebSocket isn't an HTTP route, so the schema omits it. Events describes it.

The drafts routes and their ops are the Templates and Settings editors' own protocol. Read their schema entries to see what an editor sends, but expect them to change in any release.

Work item IDs in a path

Added in 2.1

The {id} segment of a route under /api/work-items/ may be the start of a work item ID instead of all of it. A start is 4 characters or more, from 0-9 and a-z. Kraft makes it the whole ID before the route runs, so the answer and everything the route does name the whole ID.

What the segment isAnswer
An item's whole IDThat item, even when it is also the start of a longer ID.
The start of exactly one item's IDThat item.
The start of more than one409, naming every ID it starts.
Anything else, a value under 4 characters or one with another character included404 unknown work item, as for an ID that doesn't exist.

A caller the refusals above turn away gets that refusal first, so it learns nothing about which IDs exist. A worker inside a network sandbox reaches Kraft through its own channel, which still takes only its own item's whole ID.

Session IDs in a path

A session ID is unique only within its work item, so a session's routes are under its item, as /api/work-items/{id}/sessions/{session}/.... {id} may be the start of the item's ID, as above. {session} is always the whole session ID. A session of another item answers 404 unknown session.

curl -s "http://127.0.0.1:8765/api/work-items/k3f9/sessions/$SESSION/log?format=jsonl&follow=1"

log serves the session's log as plain text, ?format=text for the same without colour codes, or ?format=jsonl for lines, with &follow=1 to stream them until the session stops. The older /api/worker-sessions/{session}/... routes still answer for a session ID that exactly one session has, for a client built before session IDs were per item.

A worker's own session travels in the X-Kraft-Session-Id header as <work item id>/<session id>, from KRAFT_SESSION_ID. Any other value answers 400, apart from a bare 32-character ID from a session of an older Kraft.

Status codes

Added in 2.6

The routes answer with a small set of codes.

StatusMeaning
200, 201, 204Done. 201 follows a create, 204 a delete with nothing to say.
202Accepted, and not yet done, as for a restart.
400The request is malformed for what the route can read.
401, 403No valid credentials, or a caller the route refuses: see Refusals. A 403 also answers an agent's call to a person's action, such as approving a gate.
404No such item, repo or session. A work item ID prefix that matches nothing answers 404 too.
409The item's state forbids the action: it has ended, isn't waiting at that gate, or a walk is already running. The detail says which.
422A field is refused. detail is one sentence naming it.
429Too many failed logins, or too many probes at once.
502A call to the forge failed, or filing an item failed after its checks passed. detail carries the reason.
503A configuration file doesn't load, so Kraft refuses new work until it does. Approve, reject and retry also answer it while a restart is marked for when nothing is running.

What each work item status allows is in the actions field of the work item object.

In this section

Copyright © 2026