curl --location 'https://api.weya.live/backend/api/knowledgeBase/createKnowledgeBase' \
--header 'x-api-key: YOUR_API_KEY' \
--form 'knowledgeBaseName="Customer Support KB"' \
--form 'description="Knowledge base for customer support queries"' \
--form 'files=@"/path/to/FAQ.pdf"' \
--form 'files=@"/path/to/Pricing.pdf"'
{
"status": true,
"code": 200,
"message": "Files uploaded successfully, vectorDbCollection updated",
"errorMessage": null,
"data": {
"_id": "687b1c2ab7c7d3f123456789",
"organizationId": "64e5f12345abcdef00000001",
"knowledgeBaseName": "Customer Support KB",
"description": "Knowledge base for customer support queries",
"bucketUrl": "https://…/",
"vectorDbCollection": "kb_customer_support_1a2b3c",
"status": "PENDING",
"createdAt": "2026-07-20T10:35:00.000Z",
"updatedAt": "2026-07-20T10:35:05.000Z"
}
}
Knowledge Base
Create Knowledge Base
Create a knowledge base from uploaded documents, or add documents to an existing one.
POST
/
api
/
knowledgeBase
/
createKnowledgeBase
curl --location 'https://api.weya.live/backend/api/knowledgeBase/createKnowledgeBase' \
--header 'x-api-key: YOUR_API_KEY' \
--form 'knowledgeBaseName="Customer Support KB"' \
--form 'description="Knowledge base for customer support queries"' \
--form 'files=@"/path/to/FAQ.pdf"' \
--form 'files=@"/path/to/Pricing.pdf"'
{
"status": true,
"code": 200,
"message": "Files uploaded successfully, vectorDbCollection updated",
"errorMessage": null,
"data": {
"_id": "687b1c2ab7c7d3f123456789",
"organizationId": "64e5f12345abcdef00000001",
"knowledgeBaseName": "Customer Support KB",
"description": "Knowledge base for customer support queries",
"bucketUrl": "https://…/",
"vectorDbCollection": "kb_customer_support_1a2b3c",
"status": "PENDING",
"createdAt": "2026-07-20T10:35:00.000Z",
"updatedAt": "2026-07-20T10:35:05.000Z"
}
}
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 sameknowledgeBaseName, 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
Name of the knowledge base. Reusing an existing name adds the files to that knowledge base.
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.curl --location 'https://api.weya.live/backend/api/knowledgeBase/createKnowledgeBase' \
--header 'x-api-key: YOUR_API_KEY' \
--form 'knowledgeBaseName="Customer Support KB"' \
--form 'description="Knowledge base for customer support queries"' \
--form 'files=@"/path/to/FAQ.pdf"' \
--form 'files=@"/path/to/Pricing.pdf"'
Response
{
"status": true,
"code": 200,
"message": "Files uploaded successfully, vectorDbCollection updated",
"errorMessage": null,
"data": {
"_id": "687b1c2ab7c7d3f123456789",
"organizationId": "64e5f12345abcdef00000001",
"knowledgeBaseName": "Customer Support KB",
"description": "Knowledge base for customer support queries",
"bucketUrl": "https://…/",
"vectorDbCollection": "kb_customer_support_1a2b3c",
"status": "PENDING",
"createdAt": "2026-07-20T10:35:00.000Z",
"updatedAt": "2026-07-20T10:35:05.000Z"
}
}
Name of the search index built from the files. A video agent uses it as
rag.vectorDBCollection.Always
PENDING; it isn’t updated. A successful response with a vectorDbCollection means the files were indexed.Error Handling
Errors returnstatus: false, with the reason in errorMessage.
- 400 Bad Request –
knowledgeBaseName is required,No files uploaded,File exceeds the 10MB per-file limit, orYou 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}andknowledgeBase: ["<knowledge base _id>"].
Was this page helpful?

