---
title: "Create a context document"
method: POST
path: "/api/v1/context"
tags: ["Context"]
---

# Create a context document

`POST /api/v1/context`

## Request

- Base URL: `https://app.khotan.com`
- URL: `https://app.khotan.com/api/v1/context`
- Auth: one of:
  - HTTP bearer
  - API key in header `x-api-key`

Creates a markdown document from title, kind, and content, with optional slug, description, and tags. The slug is derived from the title when omitted and is immutable after creation; a collision with an active document responds 409. Limit violations respond 422 with the limit name, maximum, and submitted value.

## Request body

- object
  - `title` string, required
  - `kind` 'instructions' | 'knowledge' | 'record', required: "instructions" = procedures to follow (SOPs, runbooks); "knowledge" = reference material (specs, policies); "record" = accounts of events (meeting notes, transcripts, interviews).
  - `content` string, required: Canonical raw markdown (max 256 KB, enforced by the domain layer).
  - `slug` string: Derived from the title when omitted; conflicts return 409.
  - `description` string: One-line purpose statement powering the manifest listing (max 200 characters, enforced by the domain layer).
  - `tags` string[]: Flat tag list; express hierarchy with naming conventions like "ops/runbook/deploy".
  - `properties` object: Structured facts beside the markdown: any JSON object.
  - `folderId` string, nullable: Folder placement; omit or null for the organization root.

## Response `201`

The created document, including its content.

- object
  - `slug` string, required
  - `title` string, required
  - `description` string, nullable, required: One-line purpose statement for selection without fetching.
  - `kind` 'instructions' | 'knowledge' | 'record', required
  - `tags` string[], required
  - `revision` integer, required
  - `contentSize` integer, required: Raw markdown size in bytes.
  - `folderId` string, nullable, required: Folder placement; null at the organization root.
  - `path` string, nullable, required: Human-readable folder path; null at the organization root.
  - `updatedAt` string, required
  - `staffOnly` boolean, required: Visible only to the operator's team. The organization's own members and keys never see it.
  - `content` string, required: The canonical raw markdown.
  - `properties` object, required: Structured facts beside the markdown: any JSON object.
  - `links` object[], required: Projects and resources this document links to.
    - `type` 'project' | 'deployment' | 'pipeline' | 'postgres' | 'redis' | 'turso' | 'r2', required: The kind of project or resource the document links to.
    - `id` string, required: The linked project or resource id.
    - `name` string, required: The target's current name, or "Deleted" when it no longer exists.
    - `removed` boolean, required: True when the target was deleted. Replace or remove the link.
  - `createdAt` string, required
  - `createdByType` 'agent' | 'api' | 'user', required
  - `updatedByType` 'agent' | 'api' | 'user', required

## Other responses

- `400`: The request was malformed or failed validation.
- `401`: Authentication is missing or invalid.
- `409`: Response.
- `422`: Response.
- `429`: Too many requests; retry after the indicated delay.

---

[API](https://skmtc.dev/khotan/apis/khotan-api.md) - [All operations](https://skmtc.dev/khotan/apis/khotan-api/llms.txt) - [OpenAPI document](https://skmtc.dev/khotan/apis/khotan-api/revisions/90b512a53e42?raw)
