Worked knowledge-bases samples
The endpoint list below documents every operation’s parameters; this overlay walks a knowledge base the way an AI-agent integration actually uses it: list the knowledge bases → read their documents → upload one document → handle a stale or rejected-upload error. Success envelopes are{ data, meta }, error envelopes { error, meta } — see How to
read a worked sample. Run samples with a
sandbox (dv_test_sk_*) key; documents the pipeline cannot validate
(error indexing status) never enter the agent’s retrieval set, and
you can re-queue them via the retry endpoint (see Knowledge
bases).
Every response carries meta.request_id and meta.timestamp. Quote the
request id when you report a failing upload or a drifted document
status.
1. List knowledge bases
GET /api/v1/knowledge-bases returns your workspace’s knowledge-base
records — id, name, description, optional config, refresh cadence — with
pagination. Use this to populate an AI-agent threading UI or pick the kb
to which a document will be uploaded.
200
refresh_scheduleismanual(default) or one of the recurring cadence values the create endpoint accepts — the non-manualvalues drive recurring re-scrape of URL/RSS/Notion sources.document_countis a read cache; update it with the list- read and use thedocumentsendpoint below for per-file truth.
2. Read a knowledge base’s documents
GET /api/v1/knowledge-bases/{id}/documents returns the document ledger for one knowledge base — the rows an operator sees on the dashboard — and reports pre-ingest status for each file (pending, indexed, error, failed). A rejected upload tells you the analysis and moderation pipeline flagged it so you can act on the offending chunk.
200
3. Upload one document
POST /api/v1/knowledge-bases/{id}/documents ingests a text/markdown document into the knowledge base. The body is the uploadDocumentSchema — name, type (one of the allowed text-code/image formats via vision
OCR), and content up to the router’s 10 MB text-upload cap. Files larger than that need the multipart endpoint the dashboard uses; an image upload flows through OCR transcription and chains into the same retrieval set.
200
4. Errors
Errors follow the{ error, meta } envelope. The failure every uploader
hits:
422 — validation. A name past 200 characters, unsupported type, or
a body over the text-upload cap:
422
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
202 because the sync runs asynchronously; poll
GET /api/v1/knowledge-bases/{id}/connectors for the connector’s
last-sync status.
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.