Skip to main content
POST
/
api
/
knowledge-base
# 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"
{
  "success": true,
  "message": "File 'manual.pdf' uploaded and processing started",
  "data": {
    "documentation_id": "doc_a1b2c3d4e5f6",
    "name": "Product Manual",
    "type": "file",
    "message_id": "msg_abc123def456"
  }
}
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.

Headers

X-API-Key
string
required
Your API key for authentication.
X-Organization-Id
string
required
The organization ID.

Permissions

  • kb:create (admin, agent_manager)

Request Body (Form Data)

name
string
required
The name of the document (1-200 characters).
file
file
The file to upload (e.g., PDF, DOCX, TXT). Required if text is not provided.
Max file size: 50MB
text
string
Raw text content. Required if file is not provided.
agent_id
string
Optional agent ID to immediately attach this document to after creation.

Response

success
boolean
Indicates if the request was successful.
message
string
Human-readable success message.
data
object
Created document metadata.
# 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

400
object
Must provide either file or text, not both or neither.
404
object
Agent not found (if agent_id provided).