Skip to main content
POST

Overview

Upload documents that your agents can answer questions from. The files are stored and indexed for search before the response is returned. If your organization already has a knowledge base with the same knowledgeBaseName, the files are added to it and the whole knowledge base is indexed again, instead of creating a second one. This is also the way to add files so that agents can use them; files added with Update Knowledge Base are not indexed. To use a knowledge base, add its ID to an agent’s knowledgeBase with Create Agent or Update Agent.

Prerequisites

  • An API key for your workspace
  • One or more documents, sent as multipart/form-data

Request

string
required
Your workspace API key. Create one from the profile menu in the dashboard → API Keys.
string
required
Name of the knowledge base. Reusing an existing name adds the files to that knowledge base.
string
Description of the knowledge base.
file[]
required
Documents to upload: up to 50 files of up to 10 MB each. Send each file as its own files (or files[]) field. A file with the same name as an existing one replaces it.

Response

string
Knowledge base ID. Use it in an agent’s knowledgeBase.
string
Name of the knowledge base.
string
Name of the search index built from the files. A video agent uses it as rag.vectorDBCollection.
string
Always PENDING; it isn’t updated. A successful response with a vectorDbCollection means the files were indexed.

Error Handling

Errors return status: false, with the reason in errorMessage.
  • 400 Bad Request – knowledgeBaseName is required, No files uploaded, File exceeds the 10MB per-file limit, or You can upload at most 50 files per request.
  • 401 Unauthorized – Missing or invalid API key.
  • 429 Too Many Requests – More than 1,000 Knowledge Base requests in 15 minutes from your IP address. The response body is { "message": "Too many requests. Please try again after 15 minutes." }.
  • 500 Internal Server Error – Unexpected server error.
  • 502 Bad Gateway – Indexing failed (Invalid response from external API). The files are already stored; send the request again with the same name.
After creating a knowledge base, you can:
  • GET /api/knowledgeBase – list your knowledge bases.
  • GET /api/knowledgeBase/{knowledgeBaseId}/documents – list its files.
  • Add it to an agent with PATCH /api/agents/{id} and knowledgeBase: ["<knowledge base _id>"].