Knowledge base
Upload the documents an agent answers from: catalogs, price lists, policies and FAQs.
A knowledge document is a file you upload to one agent so it can answer from your own material instead of general knowledge: a product catalog, a price list, a returns policy, an FAQ. Documents are managed per agent under /api/agents/{agentId}/knowledge. Uploading a document attaches it to that agent in the same request, and the agent’s retrieval is switched on for you. There is no separate attach step.
How it works
- Validation. The file must have an allowed extension, be sent with an allowed MIME type, and its bytes must match the extension (a
.pdfmust start with%PDF-, a.docxmust be a ZIP container, and so on). Text formats are also screened for prompt-injection and fraud content. - Plan check. The workspace plan caps both the number of knowledge files and their total size, counted across every agent in the workspace.
- Attach. The document is stored, attached to the agent, and the agent’s retrieval is enabled. The response returns immediately with
status: "processing". - Indexing. Indexing continues in the background. A background reconciler re-checks documents that are still
processingorfailedevery few minutes, so a document can take several minutes to showreadyeven when indexing finished sooner. - Retrieval. From then on, the agent retrieves relevant passages from its documents while it talks. Knowledge is attached to the agent, not to a channel, so the same documents serve calls and text conversations.
- Removal. Deleting a document detaches it from the agent and removes it. When an agent’s last document is deleted, retrieval is switched off again.
The API accepts files only. There is no endpoint that ingests a URL or a raw text string. To use a web page or a snippet of text, save it as .html, .md or .txt and upload that file.
Document status
status is the value to branch on. It is derived from the indexing state (rag_index_status) and the indexing error:
A document under about 500 bytes is reported as document_too_small: it stays attached and shows ready, but it is not indexed. When you test retrieval, use a document larger than that.
The knowledge document object
Returned by the upload, by the list, and inside result of a completed upload job.
Supported files
The accepted MIME types are exactly application/pdf, text/plain, text/csv, text/markdown, text/x-markdown, application/json, application/vnd.openxmlformats-officedocument.wordprocessingml.document, text/html and application/epub+zip. The extension is read from the file name you send, case-insensitively. Files must be at least 4 bytes and at most 20 MB.
Always set the MIME type of the file part explicitly. Many HTTP clients send application/octet-stream when they cannot guess a type (a Blob created without type, curl -F for .md, .csv, .json, .docx or .epub), and that is rejected with 400:
MIME type not allowed: application/octet-stream. Allowed: ....
Also pass a file name with the part: without one, clients send a name such as blob, which fails the extension check with File type not allowed.
Common tasks
Upload a document
Upload in the background
Add ?async=true to queue the upload instead of waiting for it. Validation of the extension, MIME type, content and screening, and the plan’s file-count check, still run before the response; everything after that runs in a job.
Poll the job
GET /api/agents/{agentId}/knowledge/jobs/{jobId} returns the job. status moves from pending to processing and ends in completed (with the document in result) or failed (with the reason in error).
A job is kept for one hour after its last update, then the endpoint answers 404 NOT_FOUND. Background uploads are attempted once: a failed job is not retried, so upload the file again. Errors that the synchronous upload returns as HTTP errors, such as the plan’s total-size cap or an agent that is still provisioning, arrive here as status: "failed" with the message in error.
List an agent’s documents
GET /api/agents/{agentId}/knowledge uses offset pagination:
1 to 100.
0 to 100000.
Documents come newest first as { "data": [ ... ] }, with no total. Stop when a page returns fewer than limit items. Deleted documents are never listed.
Replace or delete a document
Documents cannot be edited. To update one, upload the new version, then delete the old one. Uploading first means the agent is never left without the content; deleting first frees plan capacity if you are at the cap.
A successful delete returns 204 No Content with an empty body. The document is removed from the voice runtime first; if that fails, the document stays in your list and the request can be retried safely. The agentId in the path must be the agent the document belongs to.
A document belongs to one agent. To give two agents the same material, upload the file to each of them. Each copy counts toward the plan’s file count and total size.
Errors
BILLING_ERROR responses carry metadata with limit, current and tier. For the file-count cap limit and current are file counts; for the size cap they are megabytes.
An oversized file and a misnamed multipart field are rejected before validation runs, so they surface as 500 INTERNAL_ERROR rather than 400 VALIDATION_FAILED. Check the size (20 MB) and the field name (file) on your side before uploading.
See Errors for the envelope and retry guidance.
Limits
Rate limits. Uploads and deletes count against the shared 10 per minute budget for agent, campaign and webhook configuration changes, in addition to the plan’s general API limit. Listing documents and polling jobs use only the general limit. See Rate limits.
Scopes. Listing documents and polling jobs need a read key. Uploading and deleting need write. See Authentication.
Plan limits. Both caps apply to the whole workspace, across all agents:
Deleted documents free their slot and their size immediately.
Per request.
Webhooks
No webhook events are emitted for knowledge documents. To follow indexing, list the agent’s documents as shown in Wait for the document to be ready, or poll the job when you upload with ?async=true. See Webhooks for the events Jelliu does send.
Related
Create and configure the agents that documents attach to.
Read the text conversations your agents answer from their knowledge.
Place and inspect the voice calls that retrieve from the same documents.
The shared budget for configuration changes.
Every knowledge endpoint, parameter and response.

