API reference

Documents

18 endpoints under /v1/documents.

List documents, filtered by workspace, category, tags, kind, visibility or origin.

get/v1/documents

Defaults to the current workspace; include_shared adds org-wide documents (workspace_id null). Paginated by limit and offset.

Requiresdocuments:read

Query parameters

  • category_idstring (uuid)optional

    Filter by specific category ID

  • workspace_idstringoptional

    Filter by workspace ID (uses current workspace if not specified)

  • tagsstringoptional

    Comma-separated category names to filter by

  • kindenumoptional

    Filter by document role. kb returns only knowledge-base documents (the wizard's KB-doc step uses this); guideline returns only guideline documents. Omit to list every kind.

    kbguideline

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Get document details

get/v1/documents/{document_id}

Requiresdocuments:read

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Update document metadata

put/v1/documents/{document_id}

Requiresdocuments:write

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Request body

  • filenamestringoptional
  • descriptionstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Delete a document

delete/v1/documents/{document_id}

Requiresdocuments:delete

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Replace all categories for a document

put/v1/documents/{document_id}/categories

Requiresdocuments:write

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Request body

  • category_idsstring (uuid)[]required

Failures return the error envelope; branch on error_code.

Request
Response

Add document to category

post/v1/documents/{document_id}/categories/{category_id}

Requirescategories:write

Path parameters

  • document_idstring (uuid)required
  • category_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Remove document from category

delete/v1/documents/{document_id}/categories/{category_id}

Requirescategories:write

Path parameters

  • document_idstring (uuid)required
  • category_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Return a txt/md document's text for editing.

get/v1/documents/{document_id}/content

Served on /api/documents/{id}/content (dashboard) and /v1/documents/{id}/content (SDK). Other file types are refused: what comes out is what PUT can replace.

Requiresdocuments:read

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Save a txt/md document's text; free to call on every autosave.

put/v1/documents/{document_id}/content

Served on /api/documents/{id}/content (admin role) and /v1/documents/{id}/content (SDK, documents:write scope). Idempotency-Key required. DeepContext is not touched; call POST /documents/{id}/index once the writer is done.

Requiresdocuments:write

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Request body

  • contentstringrequired

Failures return the error envelope; branch on error_code.

Request
Response

Report DC ingest lifecycle health for one document.

get/v1/documents/{document_id}/diagnostics

Returns a typed deviation list to branch on without parsing strings. Free read; documents:read suffices.

Requiresdocuments:read

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Update extracted text content for a document

put/v1/documents/{document_id}/extracted-text

Requiresdocuments:write

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Force the guideline classify+distill pass for one document.

post/v1/documents/{document_id}/guideline/recompile

Confirms a likely_kb verdict ("compile it anyway") or re-runs after a prompt-version bump. Enqueues with force=True, bypassing the classifier gate and the hash short-circuit. Tracked-only (0 credits); returns 202 with the task queued.

Requiresdocuments:write

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Send a written document's saved text to DeepContext for search.

post/v1/documents/{document_id}/index

Called when the writer leaves the document. A no-op when DeepContext already holds this text, so repeated calls are safe; indexed says whether anything was sent.

Requiresdocuments:write

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Keep an RFP-like document in the knowledge base on purpose.

post/v1/documents/{document_id}/keep-as-reference

The flag records the choice so the check never asks again and retrieval can tell it from company material. "Start a proposal from it" needs no route: the client sends the same file to the proposal upload and deletes this document.

Requirescategories:write

Path parameters

  • document_idstring (uuid)required

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Failures return the error envelope; branch on error_code.

Request
Response

Check whether files would be accepted, before any byte moves.

post/v1/documents/preflight

Returns one verdict per file, in order (a drop of twelve with room for ten admits the first ten), plus the room left. The upload remains the authority.

Requiresdocuments:read

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Request body

  • filesobject[]required
  • workspace_kindenumoptional
    dataguideline

Failures return the error envelope; branch on error_code.

Request
Response

Upload a document; indexing runs in the background.

post/v1/documents/upload

Poll processing_status for completion. Gated by the document_upload operation (max_documents, max_storage_gb).

Requiresdocuments:write

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Form fields

  • filefilerequired
  • category_idsstringoptional
  • kindenumoptional

    Document role override. When omitted, the document inherits the parent workspace's kind (data → kb, guideline → guideline) — the legacy implicit behaviour preserved for every existing caller. The KB pane upload defaults the kind via the workspace; the Guidelines pane upload routes through X-Workspace-ID to the guideline workspace and the kind seeds from there.

    kbguideline
  • visible_in_workspace_idstring (uuid)optional

    Per-workspace visibility scope for guideline documents (mig 123). NULL (default) = org-wide visibility (today's behavior, preserved). Set to a data workspace id = the guideline is only visible from that workspace's wizard / Guidelines tab. Meaningful only for guideline-kind uploads; the service layer rejects this field on KB-kind uploads with a 400, mirroring the DB-level CHECK.

Failures return the error envelope; branch on error_code.

Request
Response

Upload a document as a raw markdown or plaintext JSON body.

post/v1/documents/upload-text

Same document_upload gating (scope, limits) and atomic credit commit as POST /upload. Only .md and .txt; binary formats need the multipart route.

Requiresdocuments:write

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Request body

  • filenamestringrequired
  • contentstringrequired
  • category_idsstring (uuid)[]optional
  • index_on_leavebooleanoptional

Failures return the error envelope; branch on error_code.

Request
Response

Start a model writing a document, the same writing Arthur's start_document starts.

post/v1/documents/write

A new document's row exists on return, so its card can show at once. The text streams on GET /runs/{run_id}/stream as stage=document frames (snapshot | delta | complete); the run's lifecycle rides /runs/live with kind=document and the document_id.

Requiresdocuments:write

Headers

  • X-Organization-IDstringoptional
  • X-Workspace-IDstringoptional

Request body

  • instructionsstringoptional

    What the document should contain (new / rewrite / append).

  • contextstringoptional

    Material to write from, sent whole.

  • titlestringoptional
  • modeenumoptional
    newrewriteappendedit

Failures return the error envelope; branch on error_code.

Request
Response