Create a knowledge base document from a file upload or text content. This triggers an asynchronous processing job to index the content.
This endpoint accepts multipart/form-data for file uploads. For text documents, you can use JSON.
Your API key for authentication.
Permissions
kb:create (admin, agent_manager)
Request Body (Form Data)
The name of the document (1-200 characters).
The file to upload (e.g., PDF, DOCX, TXT). Required if text is not provided.
Max file size: 50MB
Raw text content. Required if file is not provided.
Optional agent ID to immediately attach this document to after creation.
Response
Indicates if the request was successful.
Human-readable success message.
Created document metadata.
Unique document identifier.
Document type (file or text).
SQS message ID for the processing job.
# Using multipart/form-data
curl -X POST "https://api.getbutter.ai/api/knowledge-base" \
-H "X-API-Key: <YOUR_API_KEY>" \
-H "X-Organization-Id: <YOUR_ORG_ID>" \
-F "name=Product Manual" \
-F "file=@/path/to/manual.pdf" \
-F "agent_id=agent_abc123"
{
"name": "FAQ Content",
"text": "Q: What are your hours? A: We're open 9-5...",
"agent_id": "agent_abc123"
}
{
"success": true,
"message": "File 'manual.pdf' uploaded and processing started",
"data": {
"documentation_id": "doc_a1b2c3d4e5f6",
"name": "Product Manual",
"type": "file",
"message_id": "msg_abc123def456"
}
}
Errors
Must provide either file or text, not both or neither.
Agent not found (if agent_id provided).