---
title: "Update a context document"
method: PATCH
path: "/api/v1/context/{slug}"
tags: ["Context"]
---

# Update a context document

`PATCH /api/v1/context/{slug}`

## Request

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

Updates the document's title, kind, content, description, tags, properties, and/or folder when expectedRevision matches the current revision. Properties replace the whole object; omit them to keep the current ones. Links are set separately. On mismatch, responds 409 revision_conflict with the current revision and updatedAt. The slug is immutable; title changes never re-slug. Limit violations respond 422 with the limit name, maximum, and submitted value.

## Path parameters

- `slug` string, required

## Request body

- object
  - `expectedRevision` integer, required: Required compare-and-swap token; a stale value returns 409 with the current revision and updatedAt.
  - `title` string
  - `kind` 'instructions' | 'knowledge' | 'record': "instructions" = procedures to follow (SOPs, runbooks); "knowledge" = reference material (specs, policies); "record" = accounts of events (meeting notes, transcripts, interviews).
  - `content` string: Canonical raw markdown (max 256 KB, enforced by the domain layer).
  - `description` string, nullable: Pass null to clear the description.
  - `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: Move the document; null moves it to the organization root.
  - `changeSummary` string, nullable: Optional note recorded on the revision history entry.

## Response `200`

The updated document record.

- 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.
- `404`: The resource was not found.
- `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)
