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

# Schemas

> List, read, and save the JSON Schemas that validate page frontmatter.

A schema is a JSON Schema file at `.kiwi/schemas/<type>.json`. When enforcement is on, every markdown write is checked against the schema named by the page's discriminator field (`type` by default), and invalid writes return `422`. See [Schemas](https://docs.kiwifs.com/concepts/schemas.md) for how validation works.

```toml .kiwi/config.toml theme={null}
[schema]
enforce = true
discriminator = "type"     # frontmatter field that picks the schema
enforce_level = "reject"   # or "warn" to log violations and allow the write
```

## List schemas

Return the type names that have a schema file.

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

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

Returns a JSON array of type names. The array is empty when `.kiwi/schemas/` does not exist.

```json theme={null}
["concept", "episode", "runbook"]
```

## Get a schema

Return one schema document.

```http theme={null}
GET /api/kiwi/schemas/:type
```

**type** `string` *required*

Type name. Letters, digits, `-`, and `_` only.

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

Returns `400` for an invalid type name and `404` if no schema exists. The response is the stored JSON Schema.

```json theme={null}
{
  "type": "object",
  "required": ["title", "status", "owner"],
  "properties": {
    "title": { "type": "string" },
    "status": { "type": "string", "enum": ["draft", "reviewed", "verified"] },
    "owner": { "type": "string" }
  }
}
```

## Save a schema

Create or replace a schema. The body is the JSON Schema document. The validator reloads right away, so the next write uses the new schema.

```http theme={null}
PUT /api/kiwi/schemas/:type
```

**type** `string` *required*

Type name. Letters, digits, `-`, and `_` only.

```bash theme={null}
curl -X PUT 'http://localhost:3333/api/kiwi/schemas/runbook' \
  -H "Content-Type: application/json" \
  -d '{
    "type": "object",
    "required": ["title", "status", "owner"],
    "properties": {
      "title": {"type": "string"},
      "status": {"type": "string", "enum": ["draft", "reviewed", "verified"]},
      "owner": {"type": "string"}
    }
  }'
```

Returns `400` for an invalid type name or a body that isn't JSON.

**status** `string`

Always `ok`.

**type** `string`

Type name saved.

```json theme={null}
{ "status": "ok", "type": "runbook" }
```

> [!NOTE]
>
> Schema files live under `.kiwi/` and are written directly, not through the write pipeline, so saving a schema does not create a git commit.

## Related

> [card] [Schemas concepts](https://docs.kiwifs.com/concepts/schemas.md)
>
> Discriminators, enforcement levels, and error format.

> [card] [Files](https://docs.kiwifs.com/api/files.md)
>
> Writes that schemas validate.


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