Skip to main content
A draft is a git branch with its own worktree. An agent can write a batch of changes there, you review the diff, and then merge it into main in one fast-forward or throw it away. Main stays untouched until the merge. Drafts are off by default. Turn them on in .kiwi/config.toml:
.kiwi/config.toml
When drafts are off, every endpoint on this page returns 501. All paths are relative to http://localhost:3333/api/kiwi. See Draft spaces for the workflow.

Create a draft

Branches from the current HEAD and returns the new draft. POST /drafts
string
Who owns the draft. Falls back to X-Actor, then api.
string
Eight-character hex ID used in every other draft route.
string
Git branch, draft/{id}.
string
Owner.
string
Creation time (RFC 3339).
201 Created
Returns 409 when max_active drafts already exist or the repository has no commits yet.

List drafts

Returns all active drafts as an array of the same objects. GET /drafts
Response

Get a draft

Returns one draft. GET /drafts/:id
string
required
Draft ID.
Returns the draft object, or 404 if the ID is unknown.

Read a file in a draft

Returns a file’s content as it is in the draft, with an ETag header. GET /drafts/:id/file
string
required
Draft ID.
string
required
File path.
The body is text/markdown. Returns 404 if the draft or file does not exist.

Write a file in a draft

Creates or replaces a file on the draft branch. The body is the full file content. PUT /drafts/:id/file
string
required
Draft ID.
string
required
File path.
string
default:"draft-api"
Commit author on the draft branch.
Response
Draft writes do not check If-Match. The merge is a plain git fast-forward, so review the diff before you merge.

Delete a file in a draft

Deletes a file on the draft branch. DELETE /drafts/:id/file
string
required
Draft ID.
string
required
File path.
string
default:"draft-api"
Commit author.
Returns 204 with no body.

Get a draft’s tree

Returns the draft’s folder hierarchy, in the same shape as GET /tree. GET /drafts/:id/tree
string
required
Draft ID.
string
default:"/"
Folder to start from.

Diff a draft

Returns everything the draft changed since it branched from main, as a unified diff. GET /drafts/:id/diff
string
required
Draft ID.
Response

Merge a draft

Fast-forwards main to the draft branch, then removes the draft. Uncommitted files in the draft worktree are committed first. POST /drafts/:id/merge
string
required
Draft ID.
Response
Returns 409 when main has moved since the draft was created, because only fast-forward merges are allowed. Recreate the draft from the new HEAD, or apply the changes to main directly.

Discard a draft

Deletes the draft’s branch and worktree. Main is unchanged. DELETE /drafts/:id
string
required
Draft ID.
Returns 204 with no body, or 404 if the ID is unknown.

Draft spaces

When to stage changes in a draft.

MCP tools

The kiwi_draft_* tools do the same from an agent.
Last modified on October 19, 2026