- Threads
- Upload Document to Thread
Threads
Upload Document to Thread
curl --request POST \
--url https://app.backboard.io/api/threads/{thread_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 be attached to a specific thread for Retrieval-Augmented Generation (RAG). The document will be processed, indexed, and made available for the assistant to reference when responding to messages in this thread.
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"
# Thread ID from your created thread
thread_id = "your_thread_id_here"
# Upload a document to the thread
with open("document.pdf", "rb") as file:
response = requests.post(
f"{BASE_URL}/threads/{thread_id}/documents",
headers={"X-API-Key": API_KEY},
files={"file": ("document.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']}")
else:
print(f"Error: {response.status_code} - {response.text}")
Important Notes
The document will be processed asynchronously. Check the status field in the response. It will be “processing” initially and change to “completed” when ready for use.
You can check the processing status of your document using the Get Document Status endpoint with the returned document_id.
Large files may take longer to process. The API supports files up to 50MB in size.
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/threads/{thread_id}/documents \
--header 'X-API-Key: <api-key>' \
--header 'authorization: <authorization>' \
--header 'x_session_token: <x_session_token>' \
--form 'file=@/path/to/file'