Skip to main content
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.

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 .doc files are not accepted. A file over the limit returns 400, and one well over it is refused with 413 before the request is processed. The text extracted from the file must also stay under 20 MB, or the upload returns 400.
  • 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 returns 400.

Upload Knowledge Base Document Request

Optional 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

A 201 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.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

multipart/form-data
file
file
required

PDF, TXT, or DOCX file, at most 20 MB (20971520 bytes). Legacy DOC files are not supported.

title
string
required
Minimum string length: 1
knowledge_base_id
string
required
description
string
source
string

Response

Successful response.

success
boolean
required
error
boolean
required
statusCode
integer
required
message
string
required
data
object
required
timestamp
string<date-time>
required