Knowledge Engine API
Endpoints for managing Knowledge Engine modules, document ingestion, and semantic retrieval.
Modules
List Modules
GET /api/client/v1/rag/modules{ "modules": [{ "key": "support-kb", "name": "Support Knowledge Base", ... }] }Get Module
GET /api/client/v1/rag/modules/:keyDelete Module
DELETE /api/client/v1/rag/modules/:keyDocument Ingestion
Ingest Text
POST /api/client/v1/rag/modules/:key/ingest{
"fileName": "faq.txt",
"content": "Long document text here...",
"contentType": "text/plain",
"metadata": { "source": "docs", "version": "2.0" }
}{ "document": { "id": "doc-123", "fileName": "faq.txt", "chunkCount": 15 } }Status: 201
Ingest File
POST /api/client/v1/rag/modules/:key/ingest{
"fileName": "manual.pdf",
"data": "base64-encoded-file-content",
"contentType": "application/pdf",
"metadata": { "department": "support" }
}When data is provided instead of content, the file is converted to Markdown first, then chunked and embedded.
The file is converted by the console's extraction engine. OCR is off unless the knowledge base sets extraction.ocr. A request can override it for one file with "extraction": { "ocr": { "mode": "auto", "modelKey": "my-ocr", "languages": ["tr", "en"], "maxPages": 50, "images": false } }, or switch it off with "extraction": { "ocr": null }. mode is off, auto (scanned pages only) or always; without modelKey the bundled local engine reads the pages. An extraction value that is not an object, a key other than ocr, or a modelKey that is not an OCR or vision model of the project answers 400.
Querying
POST /api/client/v1/rag/modules/:key/query{
"query": "How do I reset my password?",
"topK": 5,
"filter": { "source": "docs" }
}{
"result": {
"matches": [
{
"content": "To reset your password, navigate to Settings...",
"score": 0.92,
"metadata": { "source": "docs", "documentTitle": "FAQ" }
}
]
}
}query must be a non-empty string, and topK, when sent, must be a whole number from 1 to 200. Anything else (an empty query, topK of 0, 201, 2.5 or "5") answers 400, for example topK must be an integer from 1 to 200. A module key that does not exist answers 404 and an inactive module answers 409, instead of a server error. A filter the vector store cannot apply answers 400.
When the knowledge base has access control on, a query reads only what the token may read.
Query history
The console's History tab reads the dashboard routes GET /api/rag/modules/:key/queries and GET /api/rag/modules/:key/usage (session authentication, in the active project). Both answer scope: "all" for Knowledge Engine admins of the project (and tenant owners and administrators), and scope: "own" with only the caller's own queries for everyone else. The query text is kept word for word, which is why it is limited this way. The counters in usage still count every query.
Documents
List Documents
GET /api/client/v1/rag/modules/:key/documentsDelete Document
DELETE /api/client/v1/rag/modules/:key/documents/:documentIdDeletes the document record and all associated vectors from the vector store.
Re-ingest Document
POST /api/client/v1/rag/modules/:key/documents/:documentIdRe-chunks and re-embeds an existing document. Optionally provide updated content:
{
"content": "Updated document text...",
"metadata": { "version": "3.0" }
}Send an empty body to re-ingest with existing content and current chunking settings.
Errors
| Status | Description |
|---|---|
| 400 | Missing or invalid fields: an empty query, topK outside 1 to 200 (or not a whole number), an invalid extraction or filter |
| 401 | Invalid API token |
| 404 | Module or document not found |
| 409 | The module is not active |
| 429 | Rate limit or quota exceeded |

