Worked sequences
The twenty operations below are the full knowledge-base surface, but four round trips cover the document lifecycle most integrations actually run: upload a document, moderate it once the review queue picks it up, search the base to preview what an agent would retrieve, and diff two versions when the ground truth changed. Each sequence shows the body you send and the body the API returns. For the prose walkthrough of the whole lifecycle (create → load → attach → tune → maintain), read Build and Maintain an AI Knowledge Base. You need theknowledge:write scope (owner / admin / developer role) for
uploads and moderation, and knowledge:read for search and diffs.
1. Upload a document
Binary files (PDF, DOCX, images — OCR-extracted) go up asmultipart/form-data. Send the file bytes plus the name and type
fields; the accepted document comes back in processing status because
chunking and embedding run asynchronously. Poll
GET /knowledge-bases/kb_abc123/documents until the status reaches
ready.
Node.js
202
422 on a multipart upload means a missing name/type field or raw
JSON carrying binary bytes — binary formats are multipart-only (inline
text under the 10 MB cap may go up as a JSON content body instead; see
the operation below).
2. Approve or reject a pending document
A document submitted for moderation (for example, a gap-cluster draft) sits pending until a reviewer acts. Approving flips its publish lifecycle toapproved and starts deferred vector indexing so its chunks become
retrievable; rejecting flips it to rejected and its chunks are never
indexed. Optional notes are stored on the document for the submitter.
Approve:
200
200
3. Search the knowledge base
This is the same retrieval an attached agent’ssearch_knowledge tool
runs, and the response shape exists so you can preview what an agent would
ground on before a customer asks. Results are relevance-ranked chunks;
when a per-base search config is active, recency, source weighting, and
category filters apply before the list is truncated to limit (default
5).
200
results array means no chunk cleared the raw similarity floor —
check whether the document you expect is uploaded, approved, and indexed.
4. Diff two document versions
Every re-upload retains the prior copy as an immutable snapshot, so you can always ask what changed.GET /knowledge-bases/kb_abc123/documents/doc_9a1c3e5b7d/versions/diff takes
from and to 1-based version numbers and returns added / removed /
unchanged line counts plus unified-style hunk lines (+ added, -
removed, context). truncated: true means the inputs were too large
for a line-level diff. A 422 here means one of those versions isn’t in
the retained lineage.
200
POST /knowledge-bases/kb_abc123/documents/doc_9a1c3e5b7d/rollback with
{ "version": 1 } — non-destructive, since the current head is
snapshotted first.