Context

/api/v1 operations for context. See HTTP API for authentication, the error envelope, and rate limits.

Operations

GET /api/v1/context

List context documents

Returns the organization's active document manifest: slug, title, description, kind, tags, revision, contentSize, and updatedAt — never content. Filter by kind, or pass q to search via the weighted full-text index (title ranks above description above content). Fetch individual documents by slug for their markdown.

Auth: API key required.

Operation ID: listContextDocuments

Query parameters:

Responses:

CLI: khotan context list

POST /api/v1/context

Create a context document

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.

Auth: API key required.

Operation ID: createContextDocument

Request body (application/json, required):

Responses:

CLI: khotan context create

GET /api/v1/context/search

Search context documents

Hybrid semantic + full-text search over the organization's active context documents, reranked for relevance. Returns the best passage from each matching document, with its slug, title, kind, and a relevance score. Use the slug to fetch the full markdown when a passage is insufficient.

Auth: API key required.

Operation ID: searchContextDocuments

Query parameters:

Responses:

CLI: khotan context search

GET /api/v1/context/folders

List context folders

Returns the organization's folder tree as a flat list of folders with parentId, name, slug, path, depth, and the active-document count directly within each folder.

Auth: API key required.

Operation ID: listContextFolders

Responses:

CLI: khotan context folders list

POST /api/v1/context/folders

Create a context folder

Creates a folder under an optional parent (omit or null for the organization root). The name must be unique among active sibling folders; a collision responds 409 folder_conflict. An unknown parent responds 404 folder_not_found.

Auth: API key required.

Operation ID: createContextFolder

Request body (application/json, required):

Responses:

CLI: khotan context folders create

PATCH /api/v1/context/folders/{id}

Rename or move a context folder

Renames the folder when name is provided and moves it when parentId is provided (null moves it to the organization root). Sibling name collisions respond 409 folder_conflict; moving a folder into itself or a descendant responds 422 folder_cycle.

Auth: API key required.

Operation ID: updateContextFolder

Path parameters:

Request body (application/json, required):

Responses:

CLI: khotan context folders update

DELETE /api/v1/context/folders/{id}

Delete a context folder

Soft-deletes the folder. A non-empty folder responds 409 folder_not_empty unless recursive=true is passed, in which case its subfolders and documents are soft-deleted too (their revision history is retained).

Auth: API key required.

Operation ID: deleteContextFolder

Path parameters:

Query parameters:

Responses:

CLI: khotan context folders delete

GET /api/v1/context/{slug}

Get a context document

Returns the full document, including its raw markdown content, in a JSON envelope. Unknown or deleted slugs respond 404. Fetching a document records its access time.

Auth: API key required.

Operation ID: getContextDocument

Path parameters:

Responses:

CLI: khotan context get

PATCH /api/v1/context/{slug}

Update a context document

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.

Auth: API key required.

Operation ID: updateContextDocument

Path parameters:

Request body (application/json, required):

Responses:

CLI: khotan context update

DELETE /api/v1/context/{slug}

Delete a context document

Soft-deletes the document. It disappears from the manifest and fetches and its slug becomes reusable; the row and its revision history are retained.

Auth: API key required.

Operation ID: deleteContextDocument

Path parameters:

Responses:

CLI: khotan context delete

GET /api/v1/context/{slug}/raw

Get a context document's raw markdown

Returns exactly the document's markdown text with a text/markdown content type and no JSON envelope. Unknown or deleted slugs respond 404 (as JSON). Fetching a document records its access time.

Auth: API key required.

Operation ID: getContextDocumentRaw

Path parameters:

Responses:

CLI: khotan context raw

List a context document's links

Returns the projects and resources the document links to, each with its current name. A target that was deleted shows removed: true. Unknown or deleted slugs respond 404.

Auth: API key required.

Operation ID: listContextDocumentLinks

Path parameters:

Responses:

CLI: khotan context links list

Set a context document's links

Replaces the document's complete link set with the given projects and resources. Links not listed are removed. Every new target must be live in the organization, or nothing changes. A link whose target was deleted since is kept unless you leave it out. A document can have at most 200 links. Unknown or deleted slugs respond 404.

Auth: API key required.

Operation ID: setContextDocumentLinks

Path parameters:

Request body (application/json, required):

Responses:

CLI: khotan context links set

GET /api/v1/context/{slug}/revisions

List a context document's revisions

Returns the document's revision history, newest first: revision number, title, author, optional change summary, and timestamp — never the snapshot content. Unknown or deleted slugs respond 404.

Auth: API key required.

Operation ID: listContextDocumentRevisions

Path parameters:

Responses:

CLI: khotan context revisions list

GET /api/v1/context/{slug}/revisions/{revision}

Get a context document revision

Returns a single revision including its captured title and markdown content. Unknown or deleted slugs, and uncaptured revisions, respond 404.

Auth: API key required.

Operation ID: getContextDocumentRevision

Path parameters:

Responses:

CLI: khotan context revisions get

POST /api/v1/context/{slug}/revisions/{revision}/restore

Restore a context document revision

Restores the document to the given revision by creating a new forward revision whose title and content match that snapshot. Prior revisions are retained. Unknown slugs or uncaptured revisions respond 404; a concurrent write responds 409 revision_conflict.

Auth: API key required.

Operation ID: restoreContextDocumentRevision

Path parameters:

Responses:

CLI: khotan context revisions restore