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

# Publishing and sharing

> Publish pages to public URLs, share private pages by token, and set space visibility.

KiwiFS has three ways to let people read pages without an API key:

| Mechanism | Scope | Set by | Read at |
| - | - | - | - |
| Publishing | One page | `published: true` frontmatter | `/p/{path}` |
| Public visibility | One page | `visibility: public` frontmatter | `/p/{path}` and `/api/kiwi/public/...` |
| Share link | One page, optional password and expiry | `POST /api/kiwi/share` | `/api/kiwi/public/{token}` |

Space visibility is separate: it opens read endpoints for the whole space. See [Publishing](https://docs.kiwifs.com/concepts/publishing.md) for when to use each.

## Publish a page

Set `published: true` in the page's frontmatter, and `published_at` if the page has never been published.

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

**X-Actor** `string`

Git commit author attribution.

**path** `string` *required*

Page path.

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

Returns `404` if the page does not exist and `409` if it changed during the request.

**path** `string`

Page path.

**published** `boolean`

Always `true`.

**published\_at** `string`

First publish time (RFC 3339). Republishing keeps the original value.

**public\_url** `string`

Relative URL of the published page.

```json theme={null}
{
  "path": "concepts/auth.md",
  "published": true,
  "published_at": "2026-10-02T14:30:00Z",
  "public_url": "/p/concepts/auth.md"
}
```

## Unpublish a page

Set `published: false`. The `published_at` field stays for history.

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

**X-Actor** `string`

Git commit author attribution.

**path** `string` *required*

Page path.

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

Returns `404` if the page does not exist and `409` if it changed during the request.

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

## Bulk publish or unpublish

Publish or unpublish many pages in a single git commit. Both endpoints take the same body and return the same shape.

```http theme={null}
POST /api/kiwi/publish/bulk
POST /api/kiwi/unpublish/bulk
```

**X-Actor** `string`

Git commit author attribution.

**paths** `string[]` *required*

Page paths. Duplicates are ignored, and a leading `/` is stripped.

```bash theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/publish/bulk' \
  -H "Content-Type: application/json" \
  -H "X-Actor: agent:publisher" \
  -d '{"paths": ["concepts/auth.md", "concepts/billing.md", "concepts/missing.md"]}'
```

Returns `400` if `paths` is empty or contains an empty string. Pages that are missing or fail to update are reported in `errors` rather than failing the whole request.

**published** `boolean`

`true` for publish, `false` for unpublish.

**requested** `integer`

Number of paths in the request.

**changed** `integer`

Pages whose frontmatter changed.

**skipped** `integer`

Unique paths that needed no change or failed.

**paths** `object[]`

One entry per page that is now in the requested state, with `path`, `published`, `published_at`, and `public_url` as in [Publish a page](#publish-a-page).

**errors** `object[]`

Pages that could not be updated, each with `path` and `error`. Omitted when empty.

```json theme={null}
{
  "published": true,
  "requested": 3,
  "changed": 1,
  "skipped": 2,
  "paths": [
    { "path": "concepts/auth.md", "published": true, "published_at": "2026-10-02T14:30:00Z", "public_url": "/p/concepts/auth.md" },
    { "path": "concepts/billing.md", "published": true, "published_at": "2026-10-19T09:00:00Z", "public_url": "/p/concepts/billing.md" }
  ],
  "errors": [
    { "path": "concepts/missing.md", "error": "code=404, message=file not found" }
  ]
}
```

## Get publish status

Return whether one page is published.

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

**path** `string` *required*

Page path.

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

Returns `404` if the page does not exist.

**path** `string`

Page path.

**published** `boolean`

Whether the page is published.

**published\_at** `string`

First publish time, if the page was ever published.

**public\_url** `string`

Relative public URL. Only present while published.

**view\_count** `integer`

Views of the published page since the server started counting. `0` when view tracking is off.

```json theme={null}
{
  "path": "concepts/auth.md",
  "published": true,
  "published_at": "2026-10-02T14:30:00Z",
  "public_url": "/p/concepts/auth.md",
  "view_count": 42
}
```

## List published pages

Return every published markdown page, newest first.

```http theme={null}
GET /api/kiwi/publish/list
```

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

**count** `integer`

Number of published pages.

**pages** `object[]`

Published pages, sorted by `published_at` descending.

**properties**

**path** `string`

Page path.

**published\_at** `string`

First publish time, if set.

**public\_url** `string`

Relative public URL.

```json theme={null}
{
  "count": 2,
  "pages": [
    { "path": "concepts/billing.md", "published_at": "2026-10-19T09:00:00Z", "public_url": "/p/concepts/billing.md" },
    { "path": "concepts/auth.md", "published_at": "2026-10-02T14:30:00Z", "public_url": "/p/concepts/auth.md" }
  ]
}
```

## Read a published page

Render a published or `visibility: public` page. This route sits outside `/api/kiwi` and never requires authentication.

```http theme={null}
GET /p/{path}
```

**path** `string` *required*

Page path. `.md` is appended if the path has no extension.

**Accept** `string` (default: text/html)

`text/html` for a themed reader page, `text/markdown` for the raw file, or `application/json` for frontmatter plus rendered HTML.

```bash HTML theme={null}
curl 'http://localhost:3333/p/concepts/auth'
```

```bash JSON theme={null}
curl 'http://localhost:3333/p/concepts/auth.md' -H "Accept: application/json"
```

```bash Markdown theme={null}
curl 'http://localhost:3333/p/concepts/auth.md' -H "Accept: text/markdown"
```

Returns `404` for pages that aren't published or public, so private pages don't leak their existence, and `406` for an `Accept` header with no supported type. Images and other non-markdown files are served when a markdown page in the same folder or a parent folder is published or public. Responses carry `Cache-Control: public, max-age=60`.

With `Accept: application/json`:

**frontmatter** `object`

Page frontmatter.

**html** `string`

Rendered body HTML, with heading IDs.

**markdown** `string`

Page body without frontmatter.

```json theme={null}
{
  "frontmatter": { "title": "Authentication", "published": true, "published_at": "2026-10-02T14:30:00Z" },
  "html": "<h2 id=\"overview\">Overview</h2>\n<p>OAuth2 and JWT...</p>\n",
  "markdown": "## Overview\n\nOAuth2 and JWT...\n"
}
```

## Read public files

Fetch one public or published file without authentication. Use this when you want raw bytes instead of the rendered reader page.

```http theme={null}
GET /api/kiwi/public/file
```

**path** `string` *required*

File path.

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

Returns the raw file with a content type based on its extension. Returns `400` for a missing or escaping path and `404` for files that aren't public. Non-markdown files follow the same folder rule as `/p/`.

## Browse the public tree

Return the directory tree, filtered to public and published pages.

```http theme={null}
GET /api/kiwi/public/tree
```

**path** `string` (default: /)

Folder to start from.

**filter** `string`

Set to `published` to include only published pages and skip `visibility: public` pages.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/public/tree?filter=published'
```

Folders with no visible pages are omitted. Returns `404` if `path` does not exist.

```json theme={null}
{
  "path": "",
  "name": "/",
  "isDir": true,
  "children": [
    {
      "path": "concepts",
      "name": "concepts",
      "isDir": true,
      "children": [
        { "path": "concepts/auth.md", "name": "auth.md", "isDir": false, "size": 1420 }
      ]
    }
  ]
}
```

## Create a share link

Create a token that grants read access to one file, with an optional expiry and password. The page does not need to be published.

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

**X-Actor** `string`

Recorded as `createdBy`.

**path** `string` *required*

File path. Returns `404` if it does not exist.

**expiresIn** `string`

Go duration such as `168h`. Omit for a link that never expires.

**password** `string`

Password readers must supply. Stored as a bcrypt hash and never returned.

```bash theme={null}
curl -X POST 'http://localhost:3333/api/kiwi/share' \
  -H "Content-Type: application/json" \
  -H "X-Actor: agent:sharer" \
  -d '{"path": "concepts/auth.md", "expiresIn": "168h", "password": "s3cret"}'
```

Returns `400` for an invalid `expiresIn` and `501` if share links are disabled on this server.

**id** `string`

Link ID, used to revoke it.

**path** `string`

Shared file path.

**token** `string`

Secret token for the public URL.

**expiresAt** `string`

Expiry time (RFC 3339). A zero time (`0001-01-01T00:00:00Z`) means no expiry.

**createdBy** `string`

Actor that created the link.

**createdAt** `string`

Creation time.

**viewCount** `integer`

Times the link has been opened.

```json theme={null}
{
  "id": "9f8e7d6c5b4a3921",
  "path": "concepts/auth.md",
  "token": "3c1f0a9e8d7b6c5a4f3e2d1c0b9a8f7e6d5c4b3a2f1e0d9c8b7a6f5e4d3c2b1a",
  "expiresAt": "2026-10-26T14:30:00Z",
  "createdBy": "agent:sharer",
  "createdAt": "2026-10-19T14:30:00Z",
  "viewCount": 0
}
```

## List share links

Return the share links for one file.

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

**path** `string` *required*

File path.

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

Returns a JSON array of share links with the fields shown in [Create a share link](#create-a-share-link). Returns `501` if share links are disabled.

## Revoke a share link

Delete a share link by its `id` (not its token).

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

**id** `string` *required*

Link ID.

```bash theme={null}
curl -X DELETE 'http://localhost:3333/api/kiwi/share/9f8e7d6c5b4a3921'
```

Returns `404` if the link does not exist.

```json theme={null}
{ "revoked": "9f8e7d6c5b4a3921" }
```

## Open a share link

Return the raw shared file. This route needs no API key.

```http theme={null}
GET /api/kiwi/public/:token
```

**token** `string` *required*

Share token.

**password** `string`

Password for a protected link.

**X-Share-Password** `string`

Alternative to the `password` query parameter.

```bash theme={null}
curl 'http://localhost:3333/api/kiwi/public/3c1f0a9e8d7b6c5a4f3e2d1c0b9a8f7e6d5c4b3a2f1e0d9c8b7a6f5e4d3c2b1a' \
  -H "X-Share-Password: s3cret"
```

Returns `401` with a `WWW-Authenticate` header when the password is missing or wrong, and `404` when the token is unknown or expired.

## Get space visibility

Return the current space's visibility and root directory.

```http theme={null}
GET /api/kiwi/space/info
```

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

**visibility** `string`

`private`, `unlisted`, or `public`. Defaults to `private`.

**root** `string`

Absolute path of the knowledge root on the server.

```json theme={null}
{ "visibility": "private", "root": "/data/knowledge" }
```

## Set space visibility

Change who can read the space without an API key. The value is saved to `[space] visibility` in `.kiwi/config.toml` and applies immediately.

```http theme={null}
PUT /api/kiwi/space/visibility
```

**visibility** `string` *required*

* `private`: every request needs auth (when auth is configured).
* `unlisted`: `GET` requests to `/file`, `/peek`, and `/section` with a `path` are open; listing, tree, and search still need auth.
* `public`: every `GET` and `HEAD` request under `/api/kiwi` is open.

```bash theme={null}
curl -X PUT 'http://localhost:3333/api/kiwi/space/visibility' \
  -H "Authorization: Bearer $KIWI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"visibility": "unlisted"}'
```

Returns `400` for any other value.

```json theme={null}
{ "visibility": "unlisted" }
```

> [!WARNING]
>
> Space visibility only relaxes reads. Writes always need auth when auth is configured.

## Related

> [card] [Publishing concepts](https://docs.kiwifs.com/concepts/publishing.md)
>
> When to publish, share, or open a space.

> [card] [Web UI](https://docs.kiwifs.com/guides/web-ui.md#publishing-and-pdf-export)
>
> The publish toggle in the page header.


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