> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kiwifs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Workflows

> Manage workflow definitions, move pages between states, and read the kanban board.

A workflow is a state machine stored as JSON in `.kiwi/workflows/<name>.json`. A page joins a workflow through its `workflow` and `state` frontmatter fields. These endpoints edit definitions, move pages between states with transition checks, and return the kanban board the web UI renders. See [Workflows](https://docs.kiwifs.com/concepts/workflows.md) for the model.

Page updates (assign, advance, reorder) go through the write pipeline with an internal `If-Match` check, so a page edited between the server's read and write returns `409`. Retry the request.

## List workflows

Return every workflow definition.

```http theme={null}
GET /api/kiwi/workflows
```

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/workflows'
```

**workflows** `object[]`

Valid workflow definitions. See [Workflow definition](#workflow-definition) for the shape.

**errors** `string[]`

One message per workflow file that failed to parse or validate. Omitted when every file loaded.

```json theme={null}
{
  "workflows": [
    {
      "name": "triage",
      "states": [
        { "name": "open", "color": "#6b7280" },
        { "name": "in_progress", "wip_limit": 3 },
        { "name": "done", "terminal": true }
      ],
      "transitions": [
        { "from": "open", "to": "in_progress" },
        { "from": "in_progress", "to": "done" }
      ]
    }
  ],
  "errors": [".kiwi/workflows/broken.json: invalid character '}' looking for beginning of value"]
}
```

## Get a workflow

Return one workflow definition.

```http theme={null}
GET /api/kiwi/workflows/:name
```

**name** `string` *required*

Workflow name (the file name without `.json`).

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/workflows/triage'
```

Returns `404` if the workflow does not exist. The response is a [workflow definition](#workflow-definition).

## Save a workflow

Create or replace a workflow definition. The `name` in the URL wins over any `name` in the body.

```http theme={null}
PUT /api/kiwi/workflows/:name
```

**name** `string` *required*

Workflow name. Must not contain `/` or `\`, or leading or trailing spaces.

**states** `object[]` *required*

At least one state. Names must be unique.

**transitions** `object[]` *required*

Allowed moves. Every `from` and `to` must name a defined state, and terminal states can't have outbound transitions.

```bash theme={null}
curl -X PUT 'http://localhost:3333/api/kiwi/workflows/triage' \
  -H "Content-Type: application/json" \
  -d '{
    "states": [
      {"name": "open"},
      {"name": "in_progress", "wip_limit": 3},
      {"name": "done", "terminal": true}
    ],
    "transitions": [
      {"from": "open", "to": "in_progress"},
      {"from": "in_progress", "to": "done"}
    ]
  }'
```

Returns `400` for invalid JSON or a definition that fails validation. The body limit is 1 MB.

**status** `string`

Always `saved`.

**workflow** `object`

The saved definition.

```json theme={null}
{ "status": "saved", "workflow": { "name": "triage", "states": [/* ... */], "transitions": [/* ... */] } }
```

### Workflow definition

**name** `string`

Workflow name.

**states** `object[]`

Board columns, in display order.

**properties**

**name** `string`

State name, stored in the page's `state` field.

**color** `string`

Hex color for the web UI.

**terminal** `boolean`

Pages in this state can't move out.

**wip\_limit** `integer`

Maximum pages in this state. `0` or omitted means unlimited.

**transitions** `object[]`

Allowed moves.

**properties**

**from** `string`

Source state.

**to** `string`

Target state.

**required\_role** `string`

Optional role label stored with the transition.

## Delete a workflow

Delete a workflow definition file.

```http theme={null}
DELETE /api/kiwi/workflows/:name
```

**name** `string` *required*

Workflow name.

```bash theme={null}
curl -X DELETE 'http://localhost:3333/api/kiwi/workflows/triage'
```

Returns `404` if the workflow does not exist. Pages that reference it keep their `workflow` and `state` fields but can no longer be advanced.

```json theme={null}
{ "status": "deleted", "name": "triage" }
```

## Assign a page to a workflow

Set a page's `workflow` and `state` frontmatter, either to add it to a workflow or to place it in a column directly. Assignment does not check transitions.

```http theme={null}
POST /api/kiwi/workflow/assign
```

**path** `string` *required*

Markdown page path. Must end in `.md`.

**workflow** `string` *required*

Workflow name.

**state** `string` *required*

Target state. Matched case-insensitively and stored with the workflow's spelling.

**ordinal** `integer`

Position within the column. Lower values sort first.

**actor** `string`

Commit author. Falls back to the `X-Actor` header, then `system`.

```bash theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/workflow/assign' \
  -H "Content-Type: application/json" \
  -d '{"path": "tasks/t-42.md", "workflow": "triage", "state": "open", "actor": "agent:bot"}'
```

Returns `400` for a missing field, a non-markdown path, or an unknown state, and `404` if the workflow or page does not exist.

**path** `string`

Page path.

**workflow** `string`

Workflow name.

**state** `string`

Stored state name.

**etag** `string`

Git blob hash of the page after the call.

**noop** `boolean`

`true` when the page already had this workflow and state and no `ordinal` was given, so nothing was written.

```json theme={null}
{ "path": "tasks/t-42.md", "workflow": "triage", "state": "open", "etag": "5e4d3c2b1a0f9e8d7c6b5a4f3e2d1c0b9a8f7e6d" }
```

## Advance a page

Move a page to another state, enforcing the workflow's rules. The server also sets `modified` to the current UTC time and, if the page has a `status` field that mirrored the old state, updates `status` too.

```http theme={null}
POST /api/kiwi/workflow/advance
```

**path** `string` *required*

Markdown page path. The page must have `workflow` and `state` frontmatter.

**target\_state** `string` *required*

State to move to.

**workflow** `string`

Expected workflow. If set and it differs from the page's `workflow`, the call fails with `409`.

**actor** `string`

Commit author. Falls back to the `X-Actor` header, then `system`.

```bash theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/workflow/advance' \
  -H "Content-Type: application/json" \
  -d '{"path": "tasks/t-42.md", "target_state": "in_progress", "actor": "agent:bot"}'
```

The call returns `409` when:

* the target state does not exist in the workflow
* the current state is terminal
* no transition goes from the current state to the target
* the target column is at its `wip_limit`
* the target is `in_progress` and the page is blocked (a `blocked_by` page isn't finished, or `blocked: true`)
* the page changed during the request

It returns `400` when the page has no frontmatter, `workflow`, or `state`, and `404` when the page or workflow does not exist.

**path** `string`

Page path.

**from\_state** `string`

State before the call.

**to\_state** `string`

State after the call.

**etag** `string`

Git blob hash of the page after the call.

**noop** `boolean`

`true` when the page was already in `target_state`.

```json theme={null}
{ "path": "tasks/t-42.md", "from_state": "open", "to_state": "in_progress", "etag": "7c6b5a4f3e2d1c0b9a8f7e6d5c4b3a2f1e0d9c8b" }
```

## Reorder a card

Set a page's `ordinal` frontmatter field, which controls its position within its board column.

```http theme={null}
POST /api/kiwi/workflow/reorder
```

**path** `string` *required*

Page path.

**ordinal** `integer` *required*

New position. Cards sort by ascending `ordinal`; cards without one sort last. Leave gaps (the web UI uses steps of 1000) so you can insert between cards.

**actor** `string`

Commit author. Falls back to the `X-Actor` header, then `system`.

```bash theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/workflow/reorder' \
  -H "Content-Type: application/json" \
  -d '{"path": "tasks/t-42.md", "ordinal": 1500}'
```

Returns `404` if the page does not exist.

**path** `string`

Page path.

**ordinal** `integer`

Stored ordinal.

**etag** `string`

Git blob hash of the page after the call.

**noop** `boolean`

`true` when the page already had this ordinal.

```json theme={null}
{ "path": "tasks/t-42.md", "ordinal": 1500, "etag": "1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b" }
```

## Get the kanban board

Return the workflow definition and every markdown page in it, grouped by state.

```http theme={null}
GET /api/kiwi/workflow/board/:workflow
```

**workflow** `string` *required*

Workflow name.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/workflow/board/triage'
```

Returns `404` if the workflow does not exist.

**workflow** `object`

The [workflow definition](#workflow-definition).

**board** `object`

Map from state name to an array of cards. Every state has a key, even when empty. Pages whose `state` isn't in the workflow appear under `__unmatched__`.

**card properties**

**path** `string`

Page path.

**state** `string`

Page's `state` value.

**title** `string`

Frontmatter `title`, or the file name.

**priority** `any`

Frontmatter `priority`, if set.

**tags** `string[]`

Frontmatter tags, if set.

**due** `string`

Frontmatter `due`, if set.

**author** `string`

Frontmatter `author`, if set.

**ordinal** `integer`

Column position, if set.

**depends\_on** `string[]`

Frontmatter `depends_on`, if set.

**blocked** `boolean`

`true` if the card is blocked.

**block\_reason** `string`

Why the card is blocked.

**description** `string`

Short excerpt of the page body.

**modified** `string`

Frontmatter `modified`, or the file's modification time (RFC 3339).

```json theme={null}
{
  "workflow": { "name": "triage", "states": [/* ... */], "transitions": [/* ... */] },
  "board": {
    "open": [
      { "path": "tasks/t-15.md", "state": "open", "title": "Fix login redirect", "priority": "high", "ordinal": 1000 }
    ],
    "in_progress": [
      { "path": "tasks/t-42.md", "state": "in_progress", "title": "Rotate API keys", "modified": "2026-10-18T09:12:00Z" }
    ],
    "done": []
  }
}
```

## MCP equivalents

`kiwi_workflow_list`, `kiwi_workflow_get`, `kiwi_workflow_save`, `kiwi_workflow_advance`, and `kiwi_workflow_board`. Assign, reorder, and delete are REST-only.

## Related

> [card] [Workflows concepts](https://docs.kiwifs.com/concepts/workflows.md)
>
> States, transitions, WIP limits, and blocked cards.

> [card] [Claims](https://docs.kiwifs.com/api/claims.md)
>
> Lease a page before an agent works on it.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.