> ## 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.

# Utilities

> Content helpers, feeds, raw files, web UI settings, D2 rendering, comments, real-time events, and admin endpoints.

These endpoints support agents and the web UI around the core file API: reading a page in pieces, linting and rendering, following activity, storing per-user settings, and running admin checks. They use the `/api/kiwi` prefix and the authentication rules in the [API overview](https://docs.kiwifs.com/api/overview.md), except `/raw/*` and `/llms.txt`, which have their own rules described below.

Symlink targets (`GET /api/kiwi/readlink`) and page templates (`GET /api/kiwi/templates`, `GET /api/kiwi/template`) are documented with the [Files API](https://docs.kiwifs.com/api/files.md).

## Content helpers

### Lint markdown

Check a page, or markdown you haven't saved yet, for structural problems the editor can't fix automatically.

```http theme={null}
POST /api/kiwi/lint
```

**path** `string`

File to lint. Ignored when `content` is set.

**content** `string`

Markdown to lint inline.

```bash theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/lint' \
  -H "Content-Type: application/json" \
  -d '{"path": "concepts/auth.md"}'
```

Returns `400` when neither `path` nor `content` is set and `404` when `path` does not exist.

**issues** `object[]`

Problems found. Always an array, empty when the page is clean.

**properties**

**rule** `string`

Rule ID, such as `frontmatter-yaml-invalid`, `table-column-mismatch`, `fence-unclosed`, `fence-mermaid-invalid`, `fence-widget-invalid`, `quiz-invalid`, `heading-skip-level`, or `link-image-broken`.

**line** `integer`

1-based line. `0` means the whole file.

**column** `integer`

1-based column. `0` means not applicable.

**message** `string`

Human-readable description.

**severity** `string`

`error`, `warning`, or `info`.

```json theme={null}
{
  "issues": [
    { "rule": "heading-skip-level", "line": 12, "column": 0, "message": "heading jumps from h2 to h4", "severity": "warning" }
  ]
}
```

### Peek at a page

Return a page's title, frontmatter, opening paragraph, links, and headings without the full body. Use it to decide whether a page is worth reading.

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

**path** `string` *required*

File path.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/peek?path=concepts/auth.md'
```

Returns `404` if the file does not exist.

**path** `string`

File path.

**title** `string`

First heading, or the file name.

**frontmatter** `object`

Parsed frontmatter.

**snippet** `string`

First paragraph, up to 300 characters.

**links\_out** `string[]`

Wiki link targets in the page, as written.

**links\_in** `string[]`

Pages that link to this one.

**word\_count** `integer`

Words in the body.

**headings** `string[]`

Heading text, in order.

```json theme={null}
{
  "path": "concepts/auth.md",
  "title": "Authentication",
  "frontmatter": { "status": "published", "tags": ["security"] },
  "snippet": "KiwiFS supports API keys, per-space keys, and OIDC...",
  "links_out": ["concepts/oidc", "guides/auth-tokens"],
  "links_in": ["index.md"],
  "word_count": 812,
  "headings": ["Authentication", "API keys", "OIDC"]
}
```

### Read one section

Return a single heading section of a page.

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

**path** `string` *required*

File path.

**heading** `string`

Heading text, matched case-insensitively. Use `Parent > Child` to pick a nested heading.

**index** `integer`

0-based section index. Used when `heading` is not set.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/section?path=concepts/auth.md&heading=OIDC'
```

Returns `400` when neither `heading` nor `index` is set or `index` isn't a number, and `404` when the file or section does not exist.

**path** `string`

File path.

**heading** `string`

Matched heading text.

**level** `integer`

Heading level (1–6).

**content** `string`

Section markdown, from the heading to the next heading of the same or higher level.

**line\_start** `integer`

First line of the section in the body.

**line\_end** `integer`

Last line of the section in the body.

```json theme={null}
{
  "path": "concepts/auth.md",
  "heading": "OIDC",
  "level": 2,
  "content": "## OIDC\n\nSet `auth.type = \"oidc\"`...",
  "line_start": 40,
  "line_end": 58
}
```

### Clip a web page

Fetch a URL, convert the article to markdown, and save it as a page.

```http theme={null}
POST /api/kiwi/clip
```

**X-Actor** `string` (default: clipper)

Git commit author attribution.

**url** `string` *required*

Page to clip.

**title** `string`

Title override. Defaults to the article title.

**tags** `string[]`

Tags to add to the frontmatter.

**folder** `string` (default: clips/)

Folder for the new page. The file name is the slugified title.

```bash theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/clip' \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/article", "tags": ["research"]}'
```

Returns `400` if `url` is missing and `500` if the fetch, conversion, or write fails.

**path** `string`

Path of the new page.

**title** `string`

Page title.

**excerpt** `string`

Short excerpt of the article.

```json theme={null}
{ "path": "clips/designing-data-intensive-apps.md", "title": "Designing Data-Intensive Apps", "excerpt": "Reliability, scalability, and maintainability..." }
```

### Ingest a document

Convert a document on the server's filesystem (PDF, Office, HTML, images, audio, and more) to markdown and write it into the knowledge base. Requires the [`markitdown`](https://github.com/microsoft/markitdown) CLI on the server's `PATH`.

```http theme={null}
POST /api/kiwi/ingest
```

**file** `string` *required*

Path to the source file on the server. Supported extensions: `pdf`, `docx`, `pptx`, `xlsx`, `html`, `htm`, `csv`, `json`, `xml`, `epub`, `jpg`, `jpeg`, `png`, `gif`, `bmp`, `tiff`, `mp3`, `wav`, `m4a`, `zip`.

**split\_mode** `string` (default: single)

`single` writes one page. `sections` writes one page per heading.

**prefix** `string` (default: imports/\<file-name>/)

Folder for the output pages.

**extract\_keywords** `boolean` (default: false)

Add TF-IDF keywords to each page.

**max\_keywords** `integer` (default: 10)

Keywords per section when `extract_keywords` is on.

**convert\_crossrefs** `boolean` (default: false)

Turn references between sections into wiki links.

**actor** `string` (default: kiwi-ingest)

Git commit author attribution.

```bash theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/ingest' \
  -H "Content-Type: application/json" \
  -d '{"file": "/data/inbox/q3-report.pdf", "split_mode": "sections", "extract_keywords": true}'
```

Returns `400` for a missing `file` or unsupported extension and `500` if conversion or writing fails (including when `markitdown` is not installed).

**source\_file** `string`

Source path.

**format** `string`

Source extension.

**total\_sections** `integer`

Sections found in the converted document.

**output\_files** `string[]`

Pages written.

**top\_keywords** `string[]`

Extracted keywords, if enabled.

```json theme={null}
{
  "source_file": "/data/inbox/q3-report.pdf",
  "format": ".pdf",
  "total_sections": 3,
  "output_files": ["imports/q3-report/summary.md", "imports/q3-report/revenue.md", "imports/q3-report/outlook.md"],
  "top_keywords": ["revenue", "churn", "pipeline"]
}
```

## Agent context

### Workspace context

Return the files agents read at the start of a session.

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

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

Each field is an empty string when its file does not exist.

**playbook** `string`

Contents of `.kiwi/playbook.md`.

**schema** `string`

Contents of `SCHEMA.md` at the knowledge root.

**index** `string`

Contents of `index.md` at the knowledge root.

**rules** `string`

Contents of `.kiwi/rules.md`.

```json theme={null}
{
  "playbook": "# Playbook\n\nSearch before you write...",
  "schema": "# Schema\n\nEvery page has `status` and `owner`...",
  "index": "# Index\n\n- [[concepts/auth]]...",
  "rules": "Always cite the source page."
}
```

### Rules file

Read or replace `.kiwi/rules.md`, the team's instructions for agents. `GET` can also wrap the rules in a ready-made file for a specific agent harness.

```http theme={null}
GET /api/kiwi/rules
PUT /api/kiwi/rules
```

**format** `string`

`GET` only. One of `cursor`, `claude`, `agents`, `openclaw`, or `skill`. Omit it to get the raw file.

**X-Actor** `string`

`PUT` only. Git commit author attribution.

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

```bash Read as a Cursor rules file theme={null}
curl 'http://localhost:3333/api/kiwi/rules?format=cursor'
```

```bash Replace rules theme={null}
curl -X PUT 'http://localhost:3333/api/kiwi/rules' \
  -H "Content-Type: text/markdown" \
  --data-binary @rules.md
```

`GET` returns plain text, or an empty body when the file doesn't exist. `PUT` takes raw markdown up to 256 KB, returns `413` above that, and commits the file.

```json PUT response theme={null}
{ "status": "ok", "path": ".kiwi/rules.md" }
```

## Feeds and activity

### Activity timeline

List recent file changes from git history, newest first.

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

**limit** `integer` (default: 50)

Events to return. Maximum 500.

**offset** `integer` (default: 0)

Events to skip.

**actor** `string`

Only events whose git author name equals this value.

**type** `string`

`write` or `delete`. Omit for both.

**path\_prefix** `string`

Only paths starting with this prefix.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/timeline?limit=20&path_prefix=runbooks/'
```

Returns `400` for any other `type` value.

**events** `object[]`

**properties**

**type** `string`

`write` or `delete`.

**path** `string`

File path.

**actor** `string`

Git author name.

**timestamp** `string`

Commit time (RFC 3339).

**message** `string`

Commit subject.

**total** `integer`

`offset` plus the events returned, plus one when the page is full. A value greater than `offset + limit` means more events may exist.

```json theme={null}
{
  "events": [
    { "type": "write", "path": "runbooks/deploy.md", "actor": "agent:deployer", "timestamp": "2026-10-19T14:02:11Z", "message": "agent:deployer: runbooks/deploy.md" }
  ],
  "total": 1
}
```

### Atom and JSON feeds

Subscribe to the 50 most recent changes in a feed reader.

```http theme={null}
GET /api/kiwi/feed.xml
GET /api/kiwi/feed.json
```

**filter** `string`

`published` limits write events to pages with `published: true`.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/feed.xml?filter=published'
```

`feed.xml` returns Atom (`application/atom+xml`). `feed.json` returns [JSON Feed](https://www.jsonfeed.org) (`application/feed+json`). Item titles read `Updated: <path>` or `Deleted: <path>`, and links use the server's public URL.

### Recently edited pages

Return the markdown pages edited most recently, from git history or file modification times.

```http theme={null}
GET /api/kiwi/recent-pages
```

**limit** `integer` (default: 10)

Pages to return. Maximum 50.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/recent-pages?limit=5'
```

**pages** `object[]`

**properties**

**path** `string`

Page path.

**title** `string`

Page title.

**actor** `string`

Last editor.

**timestamp** `string`

Last edit time.

```json theme={null}
{ "pages": [{ "path": "runbooks/deploy.md", "title": "Deploy", "actor": "agent:deployer", "timestamp": "2026-10-19T14:02:11Z" }] }
```

## Real-time events

### Subscribe to events

Open a [Server-Sent Events](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) stream that receives an event for every change. See [Real-time events](https://docs.kiwifs.com/concepts/real-time-events.md) for client patterns.

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

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

Each message has an `event:` line with the event type and a `data:` line with a JSON object. The server sends a `:keep-alive` comment every 15 seconds. It returns `503` when 256 clients are already connected. Events are not replayed, so reconnect and re-read state after a disconnect.

```text theme={null}
event: write
data: {"op":"write","path":"concepts/auth.md","actor":"agent:docs-writer","etag":"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2"}

event: delete
data: {"op":"delete","path":"concepts/old-page.md","actor":"agent:cleanup"}

event: bulk
data: {"op":"bulk","paths":["a.md","b.md"],"actor":"agent:importer"}
```

**op** `string`

Event type. Same as the `event:` line.

**path** `string`

File path, for single-file events.

**paths** `string[]`

File paths, for `bulk` and `rollback`.

**actor** `string`

Who made the change.

**etag** `string`

New git blob hash, on most `write` events.

**extra** `object`

Event-specific details, such as the janitor scan summary.

| Event | Sent when |
| - | - |
| `write` | A file is created or updated, including the new path of a rename |
| `delete` | A file is deleted, including the old path of a rename |
| `bulk` | A bulk write commits |
| `rollback` | A bulk write fails and its files are restored |
| `comment.add` | A comment is added |
| `comment.resolve` | A comment is resolved or reopened |
| `comment.delete` | A comment is deleted |
| `janitor` | A scheduled janitor scan finishes or fails |

## Comments

Comments are inline annotations anchored to a quoted span of a page. They are stored in `.kiwi/comments/<path>.json`, and every change is committed to git and broadcast as an SSE event.

### List comments

Return every comment on a page, resolved or not.

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

**path** `string` *required*

Page path.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/comments?path=concepts/auth.md'
```

**path** `string`

Page path.

**comments** `object[]`

**properties**

**id** `string`

Comment ID.

**path** `string`

Page path.

**anchor** `object`

Where the comment attaches: `quote`, plus optional `prefix`, `suffix`, and `offset`.

**body** `string`

Comment text.

**author** `string`

Who wrote it.

**createdAt** `string`

Creation time (RFC 3339).

**resolved** `boolean`

Present and `true` once resolved.

```json theme={null}
{
  "path": "concepts/auth.md",
  "comments": [
    {
      "id": "c7f3a9e2b1d84c6f",
      "path": "concepts/auth.md",
      "anchor": { "quote": "tokens expire after 24 hours", "prefix": "By default, ", "offset": 412 },
      "body": "Is this still true after the session change?",
      "author": "agent:reviewer",
      "createdAt": "2026-10-19T13:40:00Z"
    }
  ]
}
```

### Add a comment

Attach a comment to a span of text in a page.

```http theme={null}
POST /api/kiwi/comments
```

**path** `string` *required*

Page path.

**X-Actor** `string`

Author, used when `author` is not set.

**anchor** `object` *required*

**properties**

**quote** `string` *required*

Exact text the comment refers to.

**prefix** `string`

Text just before the quote, to disambiguate repeats.

**suffix** `string`

Text just after the quote.

**offset** `integer`

Character offset hint.

**body** `string` *required*

Comment text.

**author** `string`

Author. Falls back to `X-Actor`, then the server's default actor.

```bash theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/comments?path=concepts/auth.md' \
  -H "Content-Type: application/json" \
  -H "X-Actor: agent:reviewer" \
  -d '{"anchor": {"quote": "tokens expire after 24 hours"}, "body": "Is this still true?"}'
```

Returns `400` when `body` or `anchor.quote` is missing. The response is the new comment.

### Resolve a comment

Mark a comment resolved, or reopen it.

```http theme={null}
PATCH /api/kiwi/comments/:id
```

**id** `string` *required*

Comment ID.

**path** `string` *required*

Page path.

**resolved** `boolean` *required*

`true` to resolve, `false` to reopen.

```bash theme={null}
curl -X PATCH 'http://localhost:3333/api/kiwi/comments/c7f3a9e2b1d84c6f?path=concepts/auth.md' \
  -H "Content-Type: application/json" \
  -d '{"resolved": true}'
```

Returns `404` if the comment does not exist. The response is the updated comment.

### Delete a comment

Remove a comment.

```http theme={null}
DELETE /api/kiwi/comments/:id
```

**id** `string` *required*

Comment ID.

**path** `string` *required*

Page path.

```bash theme={null}
curl -X DELETE 'http://localhost:3333/api/kiwi/comments/c7f3a9e2b1d84c6f?path=concepts/auth.md'
```

Returns `404` if the comment does not exist.

```json theme={null}
{ "deleted": "c7f3a9e2b1d84c6f", "path": "concepts/auth.md" }
```

## Rendering

### Render a D2 diagram

Render [D2](https://d2lang.com) source to SVG on the server. The web UI uses this for ` ```d2 ` fences. Use `GET` for short sources and `POST` when the source is too long for a URL.

```http theme={null}
GET /api/kiwi/render/d2
POST /api/kiwi/render/d2
```

**source** `string`

`GET` only. D2 source.

**theme** `string` (default: light)

`GET` only. `light` or `dark`.

**source** `string` *required*

`POST` only. D2 source, up to 64 KB.

**theme** `string` (default: light)

`POST` only. `light` or `dark`.

```bash theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/render/d2' \
  -H "Content-Type: application/json" \
  -d '{"source": "api -> db: query\napi -> cache", "theme": "dark"}' \
  -o diagram.svg
```

Returns an `image/svg+xml` body with an `ETag`. Send that ETag back in `If-None-Match` to get `304`. Layout uses dagre by default; set `layout-engine: elk` in the source's `d2-config` to use ELK. Imports are disabled. Error codes:

* `400`: empty source or source over 64 KB
* `422`: the diagram has a syntax or layout error (the message says where)
* `501`: the server was built without D2 support
* `503`: rendering took longer than 10 seconds

### Widget fence reference

Return the schema, description, and example for every widget fence (` ```array `, ` ```tree `, ` ```table `, and so on). The linter, the editor's slash menu, and the `kiwi_widget_reference` MCP tool all use the same catalog. See [Widgets](https://docs.kiwifs.com/concepts/widgets.md).

```http theme={null}
GET /api/kiwi/widgets/reference
```

**name** `string`

Return only this fence. Accepts the fence tag or an alias.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/widgets/reference?name=array'
```

Returns `404` for an unknown fence name.

**version** `integer`

Catalog version. Currently `1`.

**reserved\_top\_level\_keys** `string[]`

Keys every fence accepts at the top level, such as `steps`, `caption`, and `autoplay`.

**reserved\_step\_keys** `string[]`

Keys every step accepts, such as `note`, `line`, and `breakpoint`.

**fences** `object[]`

**properties**

**lang** `string`

Fence tag.

**aliases** `string[]`

Other tags that select this fence.

**strictAliases** `string[]`

Aliases, like `kiwi-array`, that always claim the block and report every error.

**description** `string`

What the widget shows.

**required** `string[]`

Required keys.

**requireOneOf** `string[]`

At least one of these keys must be present.

**example** `string`

A complete example fence.

**attributes** `object`

Schema for each key.

````json theme={null}
{
  "version": 1,
  "reserved_top_level_keys": ["steps", "frames", "code", "lang", "props", "link", "caption", "title", "id", "clock", "width", "autoplay", "loop", "why"],
  "reserved_step_keys": ["note", "line", "next", "label", "breakpoint", "duration", "why", "expect"],
  "fences": [
    {
      "lang": "array",
      "aliases": ["kiwi-array", "widget:array", "arraystack", "kiwi-arraystack"],
      "description": "One or more arrays on a shared index axis, with pointers, dependency arrows and span brackets.",
      "required": ["values", "rows"],
      "requireOneOf": ["values", "rows"],
      "example": "```array id=two-sum ...",
      "attributes": { "values": { "type": "array|string", "description": "Cell values..." } }
    }
  ]
}
````

## Raw files and llms.txt

### Raw files

Serve a file's bytes directly, for `<img>`, `<video>`, and `<iframe>` tags and downloads. Use [`GET /file`](/api/files#read-a-file) instead when you need an `ETag`.

```http theme={null}
GET /raw/:path
GET /api/kiwi/raw/:path
```

**path** `string` *required*

File path relative to the knowledge root.

**exp** `string`

Expiry from a [signed URL](#sign-a-raw-url).

**sig** `string`

Signature from a signed URL.

```bash theme={null}
curl -O 'http://localhost:3333/raw/assets/diagram.png' \
  -H "Authorization: Bearer $KIWI_API_KEY"
```

The `/api/kiwi/raw/` alias lets the web UI reach assets in a non-primary space. When auth is on and the space is `private`, a request must have one of:

* an `Authorization` header
* a valid `exp` and `sig` pair (otherwise `403`)
* a target that is already public: a branding logo or favicon, a page with `published: true` or `visibility: public`, or an asset next to such a page

Spaces with `public` or `unlisted` visibility serve raw files without credentials. Returns `404` if the file does not exist. SVGs are served with a restrictive `Content-Security-Policy`.

### Sign a raw URL

Get a short-lived `/raw/` URL that works without an `Authorization` header, for embedding private assets in HTML.

```http theme={null}
GET /api/kiwi/raw-sign
```

**path** `string` *required*

File path.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/raw-sign?path=assets/diagram.png' \
  -H "Authorization: Bearer $KIWI_API_KEY"
```

Returns `400` if `path` is missing or escapes the knowledge root. URLs stay valid for 30 to 60 minutes and stop working when the server restarts.

**path** `string`

Normalized file path.

**url** `string`

Signed relative URL.

**expires** `string`

Expiry time (RFC 3339, UTC).

```json theme={null}
{
  "path": "assets/diagram.png",
  "url": "/raw/assets/diagram.png?exp=1792418400&sig=Zk3x...",
  "expires": "2026-10-19T15:00:00Z"
}
```

### llms.txt

Describe the knowledge base in the [llms.txt](https://llmstxt.org) format, for agents that don't use MCP. These routes sit at the server root, not under `/api/kiwi`.

```http theme={null}
GET /llms.txt
GET /llms-full.txt
```

```bash theme={null}
curl 'http://localhost:3333/llms.txt'
```

`/llms.txt` returns a plain-text index: a title, a summary, and every page grouped by top-level folder, with its `description` frontmatter. `/llms-full.txt` returns the full markdown of every page, concatenated, with frontmatter stripped. It stops at 5 MiB and ends with a note saying how many pages were left out.

> [!NOTE]
>
> These routes don't take credentials. When auth is on and the space isn't `public`, they list only pages with `published: true` or `visibility: public`, the same pages `/p/*` would serve.

## Web UI settings

### UI configuration

Return the `[ui]` settings the web UI needs at startup.

```http theme={null}
GET /api/kiwi/ui-config
```

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

**themeLocked** `boolean`

`true` when theme edits are disabled.

**startPage** `string`

Page the web UI opens first.

**sidebar** `object`

`pinned` and `hidden` path lists, and `sections` (each with `label` and `paths`).

**branding** `object`

`name`, `logoUrl`, `faviconUrl`, `welcomeTitle`, and `welcomeMessage`.

**features** `object`

On or off for `graph`, `kanban`, `canvas`, `whiteboard`, `timeline`, `bases`, `data_sources`, `edit`, `history`, and `publish`.

**toolbarViews** `string[] | null`

Views shown in the page toolbar. `null` means the default set.

**tags** `object`

`banner` and `hide` tag lists, and `colors` (tag to color).

**typedFences** `boolean`

Whether widget fences render as widgets.

**typedFenceTags** `string[] | null`

Fence tags allowed to render. `null` means all of them.

```json theme={null}
{
  "themeLocked": false,
  "startPage": "index.md",
  "sidebar": { "pinned": ["index.md"], "hidden": [], "sections": [] },
  "branding": { "name": "Acme Wiki", "logoUrl": "", "faviconUrl": "", "welcomeTitle": "", "welcomeMessage": "" },
  "features": { "graph": true, "kanban": true, "canvas": true, "whiteboard": true, "timeline": true, "bases": true, "data_sources": true, "edit": true, "history": true, "publish": true },
  "toolbarViews": null,
  "tags": { "banner": [], "hide": [], "colors": {} },
  "typedFences": true,
  "typedFenceTags": null
}
```

### Theme

Read or replace `.kiwi/theme.json`, the workspace theme the web UI applies.

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

**X-Actor** `string`

`PUT` only. Git commit author attribution.

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

```bash Replace theme={null}
curl -X PUT 'http://localhost:3333/api/kiwi/theme' \
  -H "Content-Type: application/json" \
  -d '{"accent": "#7fbc3d", "fontFamily": "Inter"}'
```

`GET` returns the stored JSON object, or `{}` when there is none. `PUT` takes any JSON object up to 64 KB, commits it, and returns it. `PUT` returns `400` for invalid JSON, `403` when `ui.theme_locked` is on, and `413` above 64 KB.

### Custom CSS

Return the workspace stylesheet set by `[ui] custom_css` (default `.kiwi/custom.css`), with any `<script>` tags removed.

```http theme={null}
GET /api/kiwi/custom.css
```

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

Returns `text/css`, or an empty body when the file doesn't exist.

### Keybindings

Return the web UI's keyboard shortcuts after merging the defaults, `.kiwi/keybindings.json`, and `[ui.keybindings]` in the config.

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

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

**bindings** `object`

Action name to key chord, after merging.

**defaults** `object`

Built-in action name to key chord.

**conflicts** `object[]`

Chords bound to more than one action, each with `chord` and `actions`.

```json theme={null}
{
  "bindings": { "focus_tree_filter": "Mod+Alt+F" },
  "defaults": { "focus_tree_filter": "Mod+Alt+F" },
  "conflicts": []
}
```

### Editor slash commands

Return the custom slash commands defined in `[[ui.editor.slash_commands]]`. Entries without an `id` or `template`, or with an `id` that isn't letters, digits, `_`, or `-`, are skipped.

```http theme={null}
GET /api/kiwi/editor/slash-commands
```

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/editor/slash-commands'
```

**commands** `object[]`

**properties**

**id** `string`

Command ID.

**label** `string`

Menu label. Defaults to `id`.

**icon** `string`

Icon name. Defaults to `FileText`.

**description** `string`

Menu description.

**template** `string`

Path of the template file to insert. Fetch its content with the file API.

```json theme={null}
{ "commands": [{ "id": "incident", "label": "Incident report", "icon": "FileText", "description": "Postmortem skeleton", "template": ".kiwi/templates/incident.md" }] }
```

### User preferences

Read or update the calling user's web UI preferences, stored in `.kiwi/users/<user-id>/preferences.json`. The user comes from `X-Actor`, which the auth layer sets from your credentials.

```http theme={null}
GET /api/kiwi/preferences
PUT /api/kiwi/preferences
```

**theme** `string`

Color theme.

**sidebar\_collapsed** `boolean`

Whether the sidebar starts collapsed.

**default\_view** `string`

`editor` or `source`.

**font\_size** `string`

`sm`, `base`, or `lg`.

**editor\_line\_numbers** `boolean`

Show line numbers in the source editor.

**vim\_mode** `boolean`

Enable Vim keybindings in the source editor.

```bash theme={null}
curl -X PUT 'http://localhost:3333/api/kiwi/preferences' \
  -H "Authorization: Bearer $KIWI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"font_size": "lg", "vim_mode": true}'
```

`PUT` merges the fields you send into the stored preferences, commits the file, and returns the merged result. Both methods return `401` for anonymous callers and the built-in web UI actor. `PUT` returns `400` for an invalid `default_view` or `font_size` and `413` above 8 KB.

```json theme={null}
{ "theme": "dark", "font_size": "lg", "vim_mode": true }
```

### Personal state and notes

Store small JSON blobs per user, such as UI state, and read a user's private companion note for a page. Files live in `.kiwi/users/<user-id>/state/` for authenticated users and in `.me/` otherwise. These files are written directly and are not committed to git.

```http theme={null}
GET /api/kiwi/me/state
PUT /api/kiwi/me/state
GET /api/kiwi/me/note
```

**name** `string`

`me/state` only, required. State name. Must not contain `/`, `\`, or `.`.

**path** `string`

`me/note` only, required. Page path. The note is the file with the same base name in the user's state folder.

```bash Save state theme={null}
curl -X PUT 'http://localhost:3333/api/kiwi/me/state?name=reading-list' \
  -H "Content-Type: application/json" \
  -d '{"pages": ["concepts/auth.md"]}'
```

```bash Read state theme={null}
curl 'http://localhost:3333/api/kiwi/me/state?name=reading-list'
```

```bash Read a note theme={null}
curl 'http://localhost:3333/api/kiwi/me/note?path=concepts/auth.md'
```

`GET /me/state` returns the stored JSON, or `{}` when nothing is stored. `PUT /me/state` takes any valid JSON up to 512 KB and returns `204`. It returns `400` for a bad `name` or invalid JSON and `413` above 512 KB. `GET /me/note` returns `text/markdown`, or `404` when there is no note.

## Admin

### Backup status

Report the state of the background git push configured in `[backup]`. See [Backup and sync](/deploy/backup-sync).

```http theme={null}
GET /api/kiwi/backup/status
GET /api/kiwi/sync/status
```

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

`/sync/status` is an alias.

**enabled** `boolean`

`false` when no backup remote is configured.

**status** `object`

Present when enabled.

**properties**

**last\_push\_at** `string`

Time of the last push attempt (RFC 3339).

**success** `boolean`

Whether the last push succeeded.

**error** `string`

Error from the last push, if it failed.

```json theme={null}
{ "enabled": true, "status": { "last_push_at": "2026-10-19T14:00:00Z", "success": true } }
```

### Audit log

Read the request audit log. Requires `[audit] enabled = true`; entries are written to `.kiwi/audit/YYYY-MM-DD.jsonl`. See [Audit log](/concepts/audit-log).

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

**since** `string` (default: 24 hours ago)

RFC 3339 timestamp. Only entries at or after this time.

**limit** `integer` (default: 100)

Maximum entries, up to 10000. Values outside 1–10000 fall back to 100.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/audit?since=2026-10-19T00:00:00Z&limit=500'
```

Returns `400` for a malformed `since` and `501` when audit logging is off.

**response** `object[]`

**properties**

**ts** `string`

Request start time (RFC 3339, UTC).

**method** `string`

HTTP method.

**path** `string`

Request path.

**space** `string`

Space, when set.

**actor** `string`

Actor, or `anonymous`.

**token\_hash** `string`

Short hash of the bearer token, when one was sent.

**ip** `string`

Client IP.

**status** `integer`

Response status code.

**duration\_ms** `integer`

Handling time in milliseconds.

```json theme={null}
[
  { "ts": "2026-10-19T14:02:11.482Z", "method": "PUT", "path": "/api/kiwi/file", "actor": "agent:deployer", "token_hash": "9f86d081", "ip": "10.0.0.12", "status": 200, "duration_ms": 18 }
]
```

## MCP equivalents

| REST | MCP tool |
| - | - |
| `POST /lint` | `kiwi_lint` |
| `GET /peek` | `kiwi_peek` |
| `GET /section` | `kiwi_section` |
| `POST /clip` | `kiwi_clip` |
| `POST /ingest` | `kiwi_ingest` |
| `GET /context` | `kiwi_context` |
| `GET /timeline` | `kiwi_timeline` |
| `GET /feed.xml`, `GET /feed.json` | `kiwi_feed` |
| `GET /widgets/reference` | `kiwi_widget_reference` |

## Related

> [card] [Files API](https://docs.kiwifs.com/api/files.md)
>
> Read, write, and rename pages.

> [card] [Real-time events](https://docs.kiwifs.com/concepts/real-time-events.md)
>
> Build clients on the SSE stream.

> [card] [Widgets](https://docs.kiwifs.com/concepts/widgets.md)
>
> Widget fences and how they render.

> [card] [Audit log](https://docs.kiwifs.com/concepts/audit-log.md)
>
> Turn on and read request auditing.


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