Skip to main content

Knowledge Bases API

Knowledge Bases endpoints exposed by the Devotel CPaaS API Base path: /api/v1/knowledge-bases Endpoint count: 20

List knowledge bases

GET /api/v1/knowledge-bases/
List every knowledge base in the current tenant, newest first, with cursor pagination. Use it to populate a knowledge-base picker or to resolve a base’s id before uploading documents or running a search. List rows omit the heavy config blob — fetch a single base to read it. Requires the knowledge:read scope.

Get a knowledge base

GET /api/v1/knowledge-bases/{id}
Retrieve a single knowledge base by ID, including its config (source connectors and search config) and the denormalised document / chunk counts. Requires the knowledge:read scope.
string
required
Knowledge base ID (kb_…).

List documents in a knowledge base

GET /api/v1/knowledge-bases/{id}/documents
List the documents in a knowledge base, newest first, with cursor pagination. Internal chunk rows are excluded — only top-level documents are returned. Use it to render a base’s document table or to resolve a docId for retry, publication, or moderation actions. Requires the knowledge:read scope.
string
required
Knowledge base ID (kb_…).

List document version history

GET /api/v1/knowledge-bases/{id}/documents/{docId}/versions
List the immutable version lineage of a knowledge-base document — the current head plus every retained snapshot of a superseded version, newest first. Each re-upload retains the prior copy as an immutable snapshot, so this surfaces how the RAG ground-truth has changed over time. Read-only; requires the knowledge:read scope.
string
required
Knowledge base ID (kb_…).
string
required
Document ID whose version lineage is returned.

Diff two document versions

GET /api/v1/knowledge-bases/{id}/documents/{docId}/versions/diff
Line-oriented diff between two retained versions of a knowledge-base document. Returns added / removed / unchanged line counts plus unified-style hunk lines (+ added, - removed, context). truncated is true when the inputs were too large for a line-level diff. Read-only; requires the knowledge:read scope.
string
required
Knowledge base ID (kb_…).
string
required
Document ID whose versions are compared.
integer
required
1-based version number to diff FROM (the older side).
integer
required
1-based version number to diff TO (the newer side).

Get knowledge-base search config

GET /api/v1/knowledge-bases/{id}/search-config
Read a knowledge base’s retrieval re-rank / relevance-boost config — recency boost, per-source weights, category include/exclude, and the minimum-score threshold that govern which chunks ground every agent answer for this KB. A KB that has never been tuned reads back as the neutral default (every field a no-op, identical to legacy raw-similarity ordering). Read-only; requires the knowledge:read scope.
string
required
Knowledge base ID (kb_…).

Get knowledge-base staleness report

GET /api/v1/knowledge-bases/{id}/staleness
Freshness scorecard for a knowledge base: classifies every non-chunk document as fresh, stale, or critical against its review-cadence window and returns the bucket totals plus an oldest-first attention_required queue, so you can spot the articles most likely to ground a wrong agent answer. A document’s age is measured from its last operator-verified time (falling back to its last update); the default window is 90 days, overridable per request. Read-only; requires the knowledge:read scope.
string
required
Knowledge base ID (kb_…).
integer
Org-wide review-cadence window in days applied to documents without a per-document override. Defaults to 90.

Create a knowledge base

POST /api/v1/knowledge-bases/
Create a knowledge base — the RAG container that documents are uploaded into and that AI agents search at answer time. Optionally set a recurring refresh_schedule so URL / connector-backed sources re-scrape on a cadence; it defaults to manual (scrape-once). Returns the created base. Requires the knowledge:write scope (admin / owner / developer).
string
required
Human-readable name for the knowledge base.
string
Optional summary of what this base contains.
string (enum: manual|hourly|daily|weekly)
Recurring re-scrape cadence for external-source documents. Defaults to manual.

Upload a document

POST /api/v1/knowledge-bases/{id}/documents
Upload a document into a knowledge base. Accepts either a JSON body with inline text content, or a multipart/form-data file upload (PDF, DOCX, or image — extracted via OCR). The document is queued for asynchronous chunking and embedding, so it is returned in processing status; poll the document list until it reaches ready. Requires the knowledge:write scope (admin / owner / developer).
string
required
Knowledge base ID (kb_…).
string
required
Document title.
string
Source type / extension (e.g. text, markdown, pdf, html). Defaults to text.
string
required
The document body (inline text). Max 10 MB via this JSON path.
string
Optional origin URL the content was fetched from.
object
Optional arbitrary metadata to store alongside the document.

Approve a pending document

POST /api/v1/knowledge-bases/{id}/documents/{docId}/approve
Approve a document that is pending moderation review. Flips its publish lifecycle to approved and kicks off deferred vector indexing so its chunks become retrievable by agents. Optional reviewer notes are stored on the document for the submitter. Requires the knowledge:write scope (admin / owner / developer).
string
required
Knowledge base ID (kb_…).
string
required
Document ID (doc_…).
string
Optional reviewer feedback stored on the document.

Reject a pending document

POST /api/v1/knowledge-bases/{id}/documents/{docId}/reject
Reject a document that is pending moderation review. Flips its publish lifecycle to rejected; its chunks are never indexed, so it stays out of agent retrieval. Optional reviewer notes are stored on the document so the submitter gets actionable feedback. Requires the knowledge:write scope (admin / owner / developer).
string
required
Knowledge base ID (kb_…).
string
required
Document ID (doc_…).
string
Optional reviewer feedback stored on the document.

Retry document ingestion

POST /api/v1/knowledge-bases/{id}/documents/{docId}/retry
Re-queue a document whose ingestion failed or stalled. Resets the document to processing and re-runs chunking / embedding on the next worker tick; use it after resolving the cause of a failed document. Takes no request body. Requires the knowledge:write scope (admin / owner / developer).
string
required
Knowledge base ID (kb_…).
string
required
Document ID (doc_…).

Roll back to an earlier version

POST /api/v1/knowledge-bases/{id}/documents/{docId}/rollback
Restore a retained earlier version of a knowledge-base document. Non-destructive: the target version’s content is re-uploaded as a new head version (the current head is snapshotted into history first), so rollback is fully reversible. Returns 202 with the freshly-minted head document. Requires the knowledge:write scope (admin / owner / developer).
string
required
Knowledge base ID (kb_…).
string
required
Document ID to roll back.
integer
required
1-based version number to restore (the first upload is version 1).

Trigger an immediate knowledge-base refresh

POST /api/v1/knowledge-bases/{id}/refresh
Force an immediate re-sync of a knowledge base’s external sources (URL / RSS / connector-backed documents) instead of waiting for its scheduled cadence. Flips the base’s next_refresh_at to now so the refresh worker re-scrapes and re-embeds its sources on the next tick. Takes no request body; use it after updating a source or when an agent is answering from stale content. Requires the knowledge:write scope (admin / owner / developer).
string
required
Knowledge base ID (kb_…).

Search a knowledge base

POST /api/v1/knowledge-bases/{id}/search
Run a semantic search over a knowledge base and return the top-matching document chunks, ranked by relevance. This is the same retrieval an AI agent uses to ground its answers, so use it to preview what an agent would retrieve for a question or to build your own RAG flow. When a per-base search config is active, recency, source weighting, and category filters are applied before results are truncated to limit. Requires the knowledge:read scope.
string
required
Knowledge base ID (kb_…).
string
required
Natural-language query to embed and match against the base’s chunks.
integer
Maximum number of chunks to return. Defaults to 5.

Update a knowledge base

PUT /api/v1/knowledge-bases/{id}
Update a knowledge base’s name, description, config, or refresh cadence. Only the fields you send are changed; omitted fields keep their current value. Returns the updated base. Requires the knowledge:write scope (admin / owner / developer).
string
required
Knowledge base ID (kb_…).
string
New name for the knowledge base.
string
New summary of what this base contains.
string (enum: manual|hourly|daily|weekly)
New recurring re-scrape cadence for external-source documents.
object
Replacement configuration blob (source connectors, search config).

Update knowledge-base search config

PUT /api/v1/knowledge-bases/{id}/search-config
Replace a knowledge base’s retrieval re-rank / relevance-boost config. Every field has a no-op default, so a PUT of {} 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).
string
required
Knowledge base ID (kb_…).
number | string
Minimum raw vector similarity (0..1) a chunk must clear to reach the agent. 0 = no floor (default).
number | string
Recency multiplier strength (0..5). 0 = off (default); fresher docs get up to ×(1 + boost).
number | string
Half-life in days of the recency decay (1..3650). Default 30.
object
Map of source label → score multiplier (0..20, keys matched case-insensitively). Default .
string[]
Allow-list of categories; empty = allow all (default).
string[]
Deny-list of categories. Default [].

Publish or unpublish a document

PATCH /api/v1/knowledge-bases/{id}/documents/{docId}/publication
Toggle a document’s public help-center publication. Set is_public to true (with a URL slug) to expose the article at the public help-center path, or false to take it down. An optional summary overrides the article’s public excerpt. A slug is required whenever is_public is true. Requires the knowledge:write scope (admin / owner / developer).
string
required
Knowledge base ID (kb_…).
string
required
Document ID (doc_…).
boolean
required
Whether the document should be publicly visible in the help center.
string
Public URL slug (lowercase letters, digits, hyphens). Required when is_public is true.
string
Optional public excerpt shown for the article.

Delete a knowledge base

DELETE /api/v1/knowledge-bases/{id}
Permanently delete a knowledge base together with all of its documents and embedded chunks, and detach it from any AI agent that referenced it. This cannot be undone. Requires the knowledge:write scope (admin / owner / developer).
string
required
Knowledge base ID (kb_…).

Delete a document

DELETE /api/v1/knowledge-bases/{id}/documents/{docId}
Delete a single document and all of its embedded chunks from a knowledge base, and decrement the base’s document / chunk counters. The content is immediately removed from agent retrieval. This cannot be undone. Requires the knowledge:write scope (admin / owner / developer).
string
required
Knowledge base ID (kb_…).
string
required
Document ID (doc_…).