Documentation

Knowledge Base API

Upload PDFs to the knowledge base and attach them to agents so the LLM can use your content during conversations. All endpoints require Authorization: Bearer YOUR_JWT. The examples below already point at your backend root — just swap in your JWT. See the Knowledge Base guide for usage.

List knowledge base files

Returns files uploaded by the authenticated user. Response includes data.files (array of file objects with id, file_name, file_size, etc.).

GET /api/v1/knowledge_base/list
curl -X GET "https://bkbharatai.blutec.ai/api/v1/knowledge_base/list" \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json"

Check file upload capability

Call before uploading to check if the file size and type are allowed. Body: file_size (bytes), file_type (e.g. pdf).

POST /api/v1/knowledge_base/can_upload
curl -X POST "https://bkbharatai.blutec.ai/api/v1/knowledge_base/can_upload" \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{
  "file_size": 1048576,
  "file_type": "pdf"
}'

Upload file to knowledge base

Upload a PDF to the knowledge base. Body: file_data (required, base64-encoded file content), filename (required, must end with .pdf).

POST /api/v1/knowledge_base/create (cURL)
curl -X POST "https://bkbharatai.blutec.ai/api/v1/knowledge_base/create" \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{"file_data":"BASE64_ENCODED_FILE_CONTENT","filename":"sample.pdf"}'

Python (same contract: file_data + filename):

Python
import base64

file_path = "sample.pdf"
file_name = "sample.pdf"

with open(file_path, "rb") as file:
    file_data = base64.b64encode(file.read()).decode("utf-8")

# POST to https://bkbharatai.blutec.ai/api/v1/knowledge_base/create with JSON body:
# {"file_data": file_data, "filename": file_name}
response = requests.post(
    "https://bkbharatai.blutec.ai/api/v1/knowledge_base/create",
    headers={"Authorization": "Bearer YOUR_JWT", "Content-Type": "application/json"},
    json={"file_data": file_data, "filename": file_name}
)
print(response.json())

Attach files to agent

Attach one or more knowledge base files to an agent. Body: file_ids (array of file IDs), agent_id, and optional when_to_use (description of when the agent should use this content).

POST /api/v1/knowledge_base/attach
curl -X POST "https://bkbharatai.blutec.ai/api/v1/knowledge_base/attach" \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{
  "file_ids": [123, 456],
  "agent_id": "789",
  "when_to_use": "When you need to answer questions about product specs."
}'

Detach files from agent

Remove files from an agent. Body: file_ids (array), agent_id.

POST /api/v1/knowledge_base/detach
curl -X POST "https://bkbharatai.blutec.ai/api/v1/knowledge_base/detach" \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{
  "file_ids": [123, 456],
  "agent_id": "789"
}'

Delete file from knowledge base

Permanently delete a file. You can only delete files you own. Body: file_id.

POST /api/v1/knowledge_base/delete
curl -X POST "https://bkbharatai.blutec.ai/api/v1/knowledge_base/delete" \
  -H "Authorization: Bearer YOUR_JWT" \
  -H "Content-Type: application/json" \
  -d '{
  "file_id": 123
}'

Response and errors

Success responses use success: true and data where applicable. Errors return success: false and message. 403 is returned if you do not own the agent or file.