- Assistants
- Upload Document to Assistant
Assistants
Upload Document to Assistant
curl --request POST \
--url https://app.backboard.io/api/assistants/{assistant_id}/documents \
--header 'X-API-Key: <api-key>' \
--header 'authorization: <authorization>' \
--header 'x_session_token: <x_session_token>' \
--form 'file=@/path/to/file'Upload a document to an assistant for Retrieval-Augmented Generation (RAG). Documents attached to an assistant are available across all threads created with that assistant, providing shared context and knowledge.
Supported File Types
Documents: PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX Text/Data: TXT, CSV, MD, MARKDOWN, JSON, JSONL, XML Code: PY, JS, TS, JSX, TSX, HTML, CSS, CPP, C, H, JAVA, GO, RS, RB, PHP, SQL Images: PNG, JPG, JPEG, WEBP, GIF, BMP, TIFF, TIF
Code Examples
Python
JavaScript (Node.js)
cURL
import requests
# Your API credentials
API_KEY = "your_api_key_here"
BASE_URL = "https://app.backboard.io/api"
# Assistant ID from your created assistant
assistant_id = "your_assistant_id_here"
# Upload a document to the assistant
with open("knowledge_base.pdf", "rb") as file:
response = requests.post(
f"{BASE_URL}/assistants/{assistant_id}/documents",
headers={"X-API-Key": API_KEY},
files={"file": ("knowledge_base.pdf", file, "application/pdf")}
)
# Check response
if response.status_code == 200:
document = response.json()
print(f"Document uploaded: {document['document_id']}")
print(f"Status: {document['status']}")
print(f"File size: {document['file_size_bytes']} bytes")
else:
print(f"Error: {response.status_code} - {response.text}")
Important Notes
Documents uploaded to an assistant are available to all threads created with that assistant. This is useful for providing common knowledge or reference materials that the assistant should always have access to.
The document will be processed asynchronously. The status field will show “processing” initially and change to “completed” when the document is ready for use in conversations.
You can upload multiple documents to an assistant to build a comprehensive knowledge base. Use the List Assistant Documents endpoint to see all documents associated with an assistant.
Large files may take longer to process. Processing time varies based on file size and content type. For image/video generation inputs, see Image Tool and Video Tool.
Authorizations
Query Parameters
Body
File
Response
200
422
Successful Response
Document Id
Filename
DocumentStatus
pending, processing, indexed, error Created At
Metadata
Status Message
Summary
Updated At
curl --request POST \
--url https://app.backboard.io/api/assistants/{assistant_id}/documents \
--header 'X-API-Key: <api-key>' \
--header 'authorization: <authorization>' \
--header 'x_session_token: <x_session_token>' \
--form 'file=@/path/to/file'