Filing, reading and deciding work items
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.
| Route | What it does |
|---|---|
POST /api/work-items | Files a work item, paused unless the body starts it. |
GET /api/work-items | Lists the items on the board. |
GET /api/work-items/{id} | Answers one item in full. |
POST /api/work-items/{id}/gates/{gate}/approve | Approves the pending gate and starts the chain again. |
POST /api/work-items/{id}/gates/{gate}/reject | Rejects the pending gate and sends the chain back to work. |
POST /api/work-items/{id}/retry | Re-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"}
| Field | Type | Default | Meaning |
|---|---|---|---|
title | string | required | One line of plain text, up to 500 characters, with no control character. |
description | string | "" | The brief: prose the spec node writes a design from. |
repo | string | required | The absolute path of a connected repo. A relative path is refused. |
chain | string | the repo's default_chain | The chain to run. |
one_off_chain | string or object | null | A 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_branch | string | null | The branch the work starts from and the merge request targets: the repo's default branch when null. Refused unless origin has it. |
in_place | boolean or null | null | true 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 |
attachments | list | [] | 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. |
autostart | boolean | false | Start the item now instead of filing it paused. |
auto_gate | boolean | true | Arms agent review for the item's auto_escalate gates. |
depends_on | list | [] | Work item IDs this item comes after. Started while one is unfinished, the item is blocked and starts when they complete. |
skip_nodes | list | [] | Node IDs to drop from the chain. |
budget_usd | number or null | the policy default | The item's own dollar cap. null means no cap. |
runner | string | null | Where the item's steps run: a machine or group from workers.yaml, any or local. Added in 2.4 |
node_overrides, policy | object | {}, null | Per-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.
| Status | When |
|---|---|
403 | autostart: true came from a worker session or the MCP server. An agent files work paused, and you start it. |
403 | The 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 |
422 | A 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. |
503 | policy.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.
| Query | Meaning |
|---|---|
archived=true | Only archived items. Without it, archived items are left out. |
include_abandoned=true | Include 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.
| Field | Type | Default | Meaning |
|---|---|---|---|
digest | string | null | The digest of the chain revision you read, as kraft view artifact printed it. Only a gate that approves a chain revision takes one. |
head | string | null | The 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.
| Status | When |
|---|---|
403 | The 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. |
404 | There is no such item, or {gate} is no gate of its chain. |
409 | The item has ended or is queued or blocked, {gate} isn't the gate the item is waiting at, or a walk is already running. |
409 | The item has must-fix review threads that aren't resolved. The answer lists their IDs. |
409 | A chain revision gate was approved without the revision's digest, or the revision changed since you read it. Read it again. |
409 | The 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 |
422 | The 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."}'
| Field | Type | Default | Meaning |
|---|---|---|---|
note | string | required | Why. It is recorded with the rejection and carried into the re-run. |
node | string | null | The 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.
| Field | Type | Default | Meaning |
|---|---|---|---|
steer | string | null | Text carried into the re-run. |
path | string | the stopped node | What to re-run, by canonical path: node, node.step or node.step.task. A path after the node the item stands on answers 409. |
restart | boolean | false | Re-run the whole chain from its first node. It can't be combined with path, task_config or policy. |
task_config | object | null | Task fields to change for the retried task. An agent's retry may change only model and effort. |
policy | object | null | The retried scope's policy, validated against its bounds. |
sandbox_from_config | boolean | false | Replace 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.
| Status | When |
|---|---|
403 | A 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. |
404 | There is no such item. |
409 | The item isn't stopped (its status isn't needs_human), has ended or has no current node. A paused item is told to resume. |
409 | A 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. |
409 | An unapproved one-off chain: a person reviews its custom content in the web UI, then starts it. Added in 2.5 |
422 | path, task_config, policy or the sandbox repos.yaml sets now is refused. Nothing changes. |
Related
- The work item object: the shapes these routes answer.
kraft item: the same actions from a terminal, with--json.- Events: the events these routes record.
Overview
Which of Kraft's HTTP routes are stable, which the pages here document, where the full schema is, and who may call them.
The work item object
The three shapes a work item answers in, its stored columns, and the fields that need an explanation, from its status and stop to its budget cap and plan progress.