Knowledge Base
Upload Knowledge Base Document
Upload a knowledge base document to store and index a PDF, TXT, or DOCX file for agent retrieval.
POST
Upload Knowledge Base Document
Changes state - verify before retry
Upload a knowledge base document to store and index a PDF, TXT, or DOCX file for agent retrieval. The knowledge base must already exist in the authenticated workspace and must not have been deleted.
Optional
Before you begin
- Create a knowledge base and keep its
kb_ID. - Prepare a PDF, TXT, or DOCX file no larger than 20 MB (20971520 bytes). Legacy binary
.docfiles are not accepted. A file over the limit returns400, and one well over it is refused with413before the request is processed. The text extracted from the file must also stay under 20 MB, or the upload returns400. - Choose a non-empty title unique within that knowledge base; a duplicate title returns
409 Conflict. Each knowledge base allows 25 documents; the 26th upload returns400.
Upload Knowledge Base Document Request
description and source fields describe the file. The file name must end in .pdf, .txt or .docx, and the file part’s Content-Type must be application/pdf, text/plain or application/vnd.openxmlformats-officedocument.wordprocessingml.document; a part sent as application/octet-stream returns 400. Let your HTTP client set the multipart boundary.
Verify the result
A201 response contains the created document in data: its id, title, knowledge_base_id (raw, without kb_), document_type, file_size in KB, file_path, the extracted text in content, and its indexing state. ingest_status is ready when indexing finished during the request and processing when it is still running; in that case, call List Knowledge Base Documents and poll until it is ready. If indexing cannot be started at all, the upload fails with 500 and the document is not kept. If a started job fails later, the document is removed from the list (it is marked deleted with ingest_status failed), so a document that disappears while you poll has failed; correct the file and upload it again with the same title. Attach the knowledge base to the intended agent and ask a test question covered by the document.
Errors and recovery
Uploading stores a file and starts background indexing. It is not an idempotent replacement operation. After an uncertain response, list documents before retrying; changing the title can create duplicate content. To replace an existing document, use dashboard document management.
Related endpoints
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
multipart/form-data