Languages: every operation supports cURL, Node.js (TypeScript), Python, Go, Ruby, and PHP. The first 15 operations on this page show all six languages; the remaining 11 show cURL and TypeScript — the two most-used.
Knowledge Bases API
Store, index, and search knowledge-base documents for agent grounding Base path:/api/v1/knowledge-bases
Endpoint count: 26
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.
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. Roll back with POST .../rollback and a body like
{ "version": 1 } once the hunks confirm the regression.
200
5. Worked sequences — advanced lifecycle
Beyond upload and read-back, most AI-agent deployments run the full editorial loop: register an external source connector withPOST /api/v1/knowledge-bases/{id}/connectors, kick off its initial sync
with POST .../sync, watch drift and staleness, moderate the AI
assistant’s proposed documents, roll a published version back after
reading the lineage, and delete the documents the team has retired. The
samples below keep the same identifiers end-to-end; pause on scheduled
syncs by patching a connector with enabled: false.
5.1 Create a connector and start its initial sync
Register a connector that pulls one knowledge base’s documents from an external source. The body names theprovider (one of notion,
confluence, google_drive, sharepoint, zendesk) plus an optional
scope, sync_schedule (default daily), and auto_refresh_on_drift.
The returned id stays the handle for every later call.
201
"status": "queued" (some builds surface the same transition as
"syncing"); once a worker claims the row, the same endpoint reports
"status": "running" as below. The response is 202 because the sync
runs asynchronously; poll
GET /api/v1/knowledge-bases/{id}/connectors for the connector’s
last-sync status as it moves through queued → syncing → running.
202
5.2 Read the connector drift report and staleness
Once a sync has pulled, the connector drain worker hashes the live source and compares it against the cached content your agents ground on. Read the drift scorecard to decide whether to re-sync or to switchauto_refresh_on_drift on. Until the worker has checked a connector at
least once, detection_active is false — the 0-drifted totals are not
yet a passing signal.
200
fresh, stale, or critical against your org’s threshold (90 days by
default; override per call with ?default_threshold_days= or per document
via its metadata) so an operator’s review queue catches the files an agent
still quotes as current.
200
5.3 Approve or reject the assistant’s proposed document
This moderation path runs in addition to the plain upload flow when your knowledge base enablesrequire_publish_approval, or when an AI
assistant (for example, a gap-cluster draft) proposes a document —
either way the file arrives with status: pending and never enters
retrieval until a reviewer acts. Approving flips the document to
approved and starts the deferred vector indexing; rejecting flips it to
rejected and its chunks are never indexed. Optional notes are stored
on the document so the submitter gets actionable feedback.
Approve:
200
200
approved (or missing) returns 409 CONFLICT, and a publish-scan
rejected document must be fixed and re-uploaded before it can be
approved. Both actions are audit-logged.
5.4 Roll back a published version
Read the version lineage first, then the diff that tells you what the head changed, and roll back the published version if the retrieval set needs a previous copy.GET .../versions lists the immutable lineage —
current head plus retained snapshots — without the heavy content blobs.
200
404; a version whose content was too large to
retain returns 422 — rollback works only against retained snapshots.
200
202
5.5 Search the knowledge base
ThePOST .../search hook is the same retrieval an attached AI agent’s
search_knowledge tool runs, and the response shape exists so you can
preview what an agent would ground on before a customer asks. The body is
query (required, ≤ 1000 chars) plus optional limit (default 5, max
20); when a per-base search config is active, recency, source weighting,
and category filters apply before the list is truncated. An empty
results array means no chunk cleared the raw similarity floor — check
whether the document you expect is uploaded, approved, and indexed.
200
5.6 Delete a document and re-approve publication
A document stuck in moderation, or one the team retires, goes away in one call; anything that carries a public help-center article keeps its status through the same record — flipis_public on the publication
endpoint once status is ready. Deleting returns 204 with no body.
204
{ is_public: boolean, slug?, summary? }; flipping
public requires the document’s ingestion be done (status: ready), and
the slug is unique across every published article in your workspace — a
slug collision returns 409 CONFLICT.
200
pending.
SDK surface bridge — Create a knowledge base and add its first source entry — the no-exec/callable shape the agent-runtime retrieval layer consumes.
These three tabs mirror SDK status and coverage. Python fronts
client.request, Go fronts client.Request, and TS fronts fetch-TS — each with the sandbox key.Create a knowledge base
Add a source entry
List knowledge bases
GET /api/v1/knowledge-basescursor and limit. Use this to resolve a knowledge-base id (kb_…) before uploading documents or registering connectors. Read-only; requires the knowledge:read scope.
Get a knowledge base
GET /api/v1/knowledge-bases/{id}knowledge:read scope.
Get knowledge-base connector drift report
GET /api/v1/knowledge-bases/{id}/connector-drift-reportauto_refresh_on_drift turned on. Read-only; requires the knowledge:read scope.
List knowledge-base connectors
GET /api/v1/knowledge-bases/{id}/connectorsknowledge:read scope.
List documents in a knowledge base
GET /api/v1/knowledge-bases/{id}/documentscursor and limit. Poll this endpoint after an upload or indexing retry until the document’s status settles on indexed (or error). Read-only; requires the knowledge:read scope.
List document versions
GET /api/v1/knowledge-bases/{id}/documents/{docId}/versionsknowledge:read scope.
Document id (
kb_doc_ prefixed), as returned by GET /knowledge-bases/:id/documents. Obtain from GET /api/v1/knowledge-bases//documents.Diff two document versions
GET /api/v1/knowledge-bases/{id}/documents/{docId}/versions/difffrom and to are required 1-based version numbers. Use it to check exactly what a rollback or a re-upload changed before promoting it to RAG retrieval. Read-only; requires the knowledge:read scope.
Document id (
kb_doc_ prefixed), as returned by GET /knowledge-bases/:id/documents. Obtain from GET /api/v1/knowledge-bases//documents.1-based version number of the earlier snapshot. Coerced to a number in-handler, so a numeric string also parses.
1-based version number of the later snapshot. Coerced to a number in-handler, so a numeric string also parses.
Get knowledge-base search config
GET /api/v1/knowledge-bases/{id}/search-configknowledge:read scope.
Get knowledge-base staleness report
GET /api/v1/knowledge-bases/{id}/stalenessdefault_threshold_days query, 1-3650). Use it to find KB content that needs a connector resync or manual update before it grounds an AI agent’s answers. Read-only; requires the knowledge:read scope.
Staleness threshold in days, 1-3650 (default 30). Coerced to a number in-handler; documents not refreshed within it are reported AGING or STALE.
Create a knowledge base
POST /api/v1/knowledge-bases201 with the new knowledge base. Requires the knowledge:write scope; the creation is audit-logged.
Cadence for recurring re-fetch of external-source documents;
manual (default) refreshes only on demand.Add a connector to a knowledge base
POST /api/v1/knowledge-bases/{id}/connectorsconnection_id defaults to your organization id when omitted. Returns 201 with the new connector. Requires the knowledge:write scope; the registration is audit-logged.
External source provider the connector pulls from.
Connection id to pull from (max 200 chars). Optional on create — defaults to your organization id (the connection-id convention shared with the integrations catalog).
Which slice of the source to pull:
space_keys, folder_ids, collection_ids, labels (all optional; empty = everything the connection can see).How often the source is re-pulled (default
daily; manual syncs only on demand).When true, a detected source content drift auto-queues a resync; when false (default), drift only appears in the drift report.
Sync a connector immediately
POST /api/v1/knowledge-bases/{id}/connectors/{connectorId}/sync202 with the connector record immediately. Requires the knowledge:write scope; the request is audit-logged.
Connector id (
kbc_ prefixed), as returned by GET /knowledge-bases/:id/connectors. Obtain from GET /api/v1/knowledge-bases//connectors.Upload a document to a knowledge base
POST /api/v1/knowledge-bases/{id}/documentsname / type / content for inline text, or multipart/form-data for a binary file (PDF, DOCX, images — images go through vision OCR). The 10 MB content cap applies either way. Returns 202 with the document record: indexing is asynchronous, so poll GET /knowledge-bases/:id/documents until the document’s status is indexed (or error). Requires the knowledge:write scope.
Approve a document for retrieval
POST /api/v1/knowledge-bases/{id}/documents/{docId}/approvenotes (up to 2000 chars) on the document’s moderation block. Requires the knowledge:write scope (admin / owner / developer); the approval is audit-logged.
Document id (
kb_doc_ prefixed), as returned by GET /knowledge-bases/:id/documents. Obtain from GET /api/v1/knowledge-bases//documents.Reject a document from retrieval
POST /api/v1/knowledge-bases/{id}/documents/{docId}/rejectnotes (up to 2000 chars) with the rejection reason. Requires the knowledge:write scope (admin / owner / developer); the rejection is audit-logged.
Document id (
kb_doc_ prefixed), as returned by GET /knowledge-bases/:id/documents. Obtain from GET /api/v1/knowledge-bases//documents.Optional rejection rationale (up to 2000 chars), persisted on the document’s moderation block.
Retry document indexing
Need this flow in Python, Go, Ruby, or PHP? The Worked sequences section renders this surface’s hero flows in the full six-language group.
POST /api/v1/knowledge-bases/{id}/documents/{docId}/retryerror indexing status and you fixed the underlying cause — the document’s chunks are re-extracted and re-indexed so the AI agent can retrieve them again. The retry is asynchronous: the endpoint returns 202 immediately with an empty body, and the document’s status transitions through pending to indexed (or back to error if it fails again) — poll GET /knowledge-bases/:id/documents for the outcome. Only failed documents are meaningfully retried. Requires an admin-class role and the knowledge:write scope; the call is audit-logged.
Document id within that knowledge base, as returned by
GET /knowledge-bases/:id/documents. Obtain from GET /api/v1/knowledge-bases//documents.Roll back a document to a prior version
POST /api/v1/knowledge-bases/{id}/documents/{docId}/rollback202 with the new document record while re-indexing runs asynchronously. Use the versions + diff endpoints to pick the version first. Requires the knowledge:write scope; the rollback is audit-logged.
Document id (
kb_doc_ prefixed), as returned by GET /knowledge-bases/:id/documents. Obtain from GET /api/v1/knowledge-bases//documents.1-based version number of the snapshot to restore. Coerced, so a JSON number or a numeric string both parse.
Trigger an immediate knowledge-base refresh
POST /api/v1/knowledge-bases/{id}/refresh202 immediately with the knowledge-base record; re-poll the knowledge base’s last_refresh_at to confirm completion. Requires the knowledge:write scope; the request is audit-logged.
Search a knowledge base
POST /api/v1/knowledge-bases/{id}/searchGET /knowledge-bases/:id/search-config.
Maximum chunks to return, 1-20 (default 5). Coerced, so a JSON number or a numeric string both parse.
Update a knowledge base
PUT /api/v1/knowledge-bases/{id}knowledge:write scope; the update is audit-logged.
Update knowledge-base search config
PUT /api/v1/knowledge-bases/{id}/search-config{} resets the KB to legacy raw-similarity ordering and an omitted knob never silently changes the others. Values are range-clamped server-side. Returns the normalised config. Requires the knowledge:write scope (admin / owner / developer).
Minimum raw vector similarity (0..1) a chunk must clear to reach the agent. 0 = no floor (default).
Update a knowledge-base connector
PATCH /api/v1/knowledge-bases/{id}/connectors/{connectorId}knowledge:write scope; the update is audit-logged.
Connector id (
kbc_ prefixed), as returned by GET /knowledge-bases/:id/connectors. Obtain from GET /api/v1/knowledge-bases//connectors.External source provider the connector pulls from.
Connection id to pull from (max 200 chars). Optional on create — defaults to your organization id (the connection-id convention shared with the integrations catalog).
Which slice of the source to pull:
space_keys, folder_ids, collection_ids, labels (all optional; empty = everything the connection can see).How often the source is re-pulled (default
daily; manual syncs only on demand).When true, a detected source content drift auto-queues a resync; when false (default), drift only appears in the drift report.
Update document help-center publication
PATCH /api/v1/knowledge-bases/{id}/documents/{docId}/publicationis_public), or rename its public slug / summary. The partial PATCH body avoids re-stating a slug that isn’t being renamed. Setting is_public=true exposes the content to the open web — every flip is audit-logged. Requires the knowledge:write scope (admin / owner / developer).
Document id (
kb_doc_ prefixed), as returned by GET /knowledge-bases/:id/documents. Obtain from GET /api/v1/knowledge-bases//documents.Public URL segment for the help-center page (lowercase letters, digits, hyphens; max 200 chars).
Delete a knowledge base
DELETE /api/v1/knowledge-bases/{id}204 No Content with an empty body. Requires the knowledge:write scope; the deletion is audit-logged.
204 No Content
Delete a knowledge-base connector
DELETE /api/v1/knowledge-bases/{id}/connectors/{connectorId}204 No Content with an empty body. Requires the knowledge:write scope; the deletion is audit-logged.
Connector id (
kbc_ prefixed), as returned by GET /knowledge-bases/:id/connectors. Obtain from GET /api/v1/knowledge-bases//connectors.204 No Content
Delete a knowledge-base document
DELETE /api/v1/knowledge-bases/{id}/documents/{docId}204 No Content with an empty body. To correct content rather than remove it, roll back to an earlier version or re-upload. Requires the knowledge:write scope; the deletion is audit-logged.
Document id (
kb_doc_ prefixed), as returned by GET /knowledge-bases/:id/documents. Obtain from GET /api/v1/knowledge-bases//documents.204 No Content