HTTP API

Filing, reading and deciding work items

The routes a script plausibly calls on a work item, which file one, read the board and one item, approve or reject a gate, and retry a stopped item.

This page lists the work-item routes a script is likely to call. Every route under /api/ except the stable routes, and the /api/ws/events WebSocket, exists for the board and can change in any release. A script that must keep working calls the stable routes, or the kraft command with --json. The routes that aren't here, such as pause, resume, skip, cancel and archive, are in the schema. The shapes the routes answer with are on The work item object.

RouteWhat it does
POST /api/work-itemsFiles a work item, paused unless the body starts it.
GET /api/work-itemsLists the items on the board.
GET /api/work-items/{id}Answers one item in full.
POST /api/work-items/{id}/gates/{gate}/approveApproves the pending gate and starts the chain again.
POST /api/work-items/{id}/gates/{gate}/rejectRejects the pending gate and sends the chain back to work.
POST /api/work-items/{id}/retryRe-runs the node an item stopped on.

Filing a work item

POST /api/work-items

Files a work item. The item is paused unless the body sets autostart: true, like kraft item create without --autostart. POST /api/work-items?dry_run=1 runs the same checks and files nothing.

curl -s -X POST http://127.0.0.1:8765/api/work-items \
  -H 'Content-Type: application/json' \
  -d '{"title": "Add a --json flag", "repo": "/home/me/src/app", "autostart": false}'
{"id": "k3f9a2c1...", "status": "paused"}
FieldTypeDefaultMeaning
titlestringrequiredOne line of plain text, up to 500 characters, with no control character.
descriptionstring""The brief: prose the spec node writes a design from.
repostringrequiredThe absolute path of a connected repo. A relative path is refused.
chainstringthe repo's default_chainThe chain to run.
one_off_chainstring or objectnullA chain for this item alone, as a chain file's text or its mapping, never saved to the library. Not with chain. Custom content in it waits for a person's approval. Added in 2.5
base_branchstringnullThe branch the work starts from and the merge request targets: the repo's default branch when null. Refused unless origin has it.
in_placeboolean or nullnulltrue runs the item in the repo's own checkout, false in a worktree of its own; null follows the repo's worktrees. Added in 2.1
attachmentslist[]Existing documents, {kind, path} with kind spec or plan and path inside the repo. At most one per kind. They trim the gates they satisfy.
autostartbooleanfalseStart the item now instead of filing it paused.
auto_gatebooleantrueArms agent review for the item's auto_escalate gates.
depends_onlist[]Work item IDs this item comes after. Started while one is unfinished, the item is blocked and starts when they complete.
skip_nodeslist[]Node IDs to drop from the chain.
budget_usdnumber or nullthe policy defaultThe item's own dollar cap. null means no cap.
runnerstringnullWhere the item's steps run: a machine or group from workers.yaml, any or local. Added in 2.4
node_overrides, policyobject{}, nullPer-node overrides, and the item's own policy override.

The fields not listed here, such as workspace, members, implements_beads and approve_one_off, are in the schema.

The answer is 201 with id and status: paused for an item filed paused, queued when autostart: true found every slot busy, and blocked when it also named an unfinished item in depends_on. A repo_warning or duplicate_warning key appears when the repo lacks a setup or test command, or another open item has the same title.

StatusWhen
403autostart: true came from a worker session or the MCP server. An agent files work paused, and you start it.
403The repo is disabled and the request came from a worker session or the MCP server. A person enables it in Settings › Repos. Added in 2.5
422A field is refused: a relative or unconnected repo, an unknown chain, a bad title, a missing attachment, an unknown depends_on ID or base_branch, or a refused override. detail says which.
503policy.yaml, the library or a chain doesn't load. Kraft refuses new work until it does.

Reading work items

GET /api/work-items

Answers the board: {"items": [...], "cursor": N}. cursor is the highest event seq at the time of the read. Each row is the list row.

QueryMeaning
archived=trueOnly archived items. Without it, archived items are left out.
include_abandoned=trueInclude cancelled and abandoned items. Without it they are left out, archived or not.

GET /api/work-items/{id}

Answers one item as the detail object, and 404 for an ID that names no item.

curl -s http://127.0.0.1:8765/api/work-items/k3f9 | jq '{status, display_status, current_node_id, stop}'
{"status": "needs_human", "display_status": "needs_you", "current_node_id": "spec-review", "stop": {"kind": "gate", "node": "spec-review", "resume_at": null, "reason": "waiting for approval"}}

Deciding a gate

POST /api/work-items/{id}/gates/{gate}/approve

Approves the pending gate {gate} and starts the chain again at the node after it. kraft item approve calls it. {gate} is the ID of a gate node of the item's chain. A review agent still running on the gate is stopped first: a person's decision outranks it. The body is optional.

FieldTypeDefaultMeaning
digeststringnullThe digest of the chain revision you read, as kraft view artifact printed it. Only a gate that approves a chain revision takes one.
headstringnullThe review_head of the item you were shown. The final review needs it. Other gates ignore it. Added in 2.3

The answer is the stored row.

StatusWhen
403The request carries the X-Kraft-Session-Id of a worker session of this item, or of its escalation turn. A gate is a person's call.
404There is no such item, or {gate} is no gate of its chain.
409The item has ended or is queued or blocked, {gate} isn't the gate the item is waiting at, or a walk is already running.
409The item has must-fix review threads that aren't resolved. The answer lists their IDs.
409A chain revision gate was approved without the revision's digest, or the revision changed since you read it. Read it again.
409The final review was approved without head, or the branch moved since the head you sent. Nothing is approved. Read review_head again. Added in 2.3
422The gate's required document is missing, or a chain revision can't be applied. The item stops as config: retry the node that owes the document.

POST /api/work-items/{id}/gates/{gate}/reject

Rejects the pending gate {gate} and sends the chain back to work, with your note as the steer. kraft item reject calls it. Each rejection counts against the gate's reject loop. Once that cap is spent, the item stays at the gate, stopped as cap, and a person decides.

curl -s -X POST http://127.0.0.1:8765/api/work-items/k3f9/gates/spec-review/reject \
  -H 'Content-Type: application/json' -d '{"note": "The spec ignores the --quiet flag."}'
FieldTypeDefaultMeaning
notestringrequiredWhy. It is recorded with the rejection and carried into the re-run.
nodestringnullThe node the chain re-enters at. Left out: the gate's reject_to, else the execution node before the gate, else the gate itself. It must be a node of the chain before the gate.

The answer is the stored row. The statuses are those of approve, with two more: 400 when node isn't a node of the chain before the gate, and 422 when the body has no note. 503 means policy.yaml doesn't load.

Retrying a work item

POST /api/work-items/{id}/retry

Re-runs the node an item stopped on, with steer text if you give it. It is the only way back onto an item stopped by a task failure, and kraft item retry calls it. Only a retry from a person resets the cap counters of what it re-runs. A retry that carries X-Kraft-Session-Id, X-Kraft-Client: mcp or X-Kraft-Client: agent-shell leaves them where they stand, so an item stopped on a cap stops again.

FieldTypeDefaultMeaning
steerstringnullText carried into the re-run.
pathstringthe stopped nodeWhat to re-run, by canonical path: node, node.step or node.step.task. A path after the node the item stands on answers 409.
restartbooleanfalseRe-run the whole chain from its first node. It can't be combined with path, task_config or policy.
task_configobjectnullTask fields to change for the retried task. An agent's retry may change only model and effort.
policyobjectnullThe retried scope's policy, validated against its bounds.
sandbox_from_configbooleanfalseReplace the sandbox frozen in the item's snapshot with the one repos.yaml sets now, then retry. A person's call. Added in 2.3
{"id": "k3f9a2c1...", "node_id": "implement", "path": "implement", "loop": null, "steer": null, "attempt": 2}

node_id is the node the re-run starts at, path the canonical path it re-runs (null for a restart), loop the key of that node's fix-loop counter, steer the text the re-run carries, and attempt the attempt number of the task it relaunches. A retry that stops at once answers the stored row.

With every slot busy, a retry answers 200 with {"id": "...", "status": "queued", "slots": {"busy": 3, "limit": 3}}, and the item waits as queued. An item that comes after an unfinished item answers 200 with status: "blocked" and waiting_on.

StatusWhen
403A worker session retries its own item, or sandbox_from_config or a task_config beyond model and effort comes from a worker or the MCP server.
404There is no such item.
409The item isn't stopped (its status isn't needs_human), has ended or has no current node. A paused item is told to resume.
409A walk is already running, path is after the node the item stands on, or steer is text no agent task downstream of the node would read.
409An unapproved one-off chain: a person reviews its custom content in the web UI, then starts it. Added in 2.5
422path, task_config, policy or the sandbox repos.yaml sets now is refused. Nothing changes.
Copyright © 2026