Skip to main content

Overview

The Uploads API provides endpoints to upload, list, and delete files for specific threads. Uploaded files are stored in thread-specific directories and can be accessed by AI agents. Certain file types (PDF, Office documents) are automatically converted to markdown.

Upload Files

POST /api/threads/{thread_id}/uploads

Upload multiple files to a thread’s uploads directory

Path Parameters

string
required
The thread ID to upload files to

Request Body

Multipart form data with one or more files:
file[]
required
List of files to upload (multipart/form-data)

Response

boolean
required
Whether the upload was successful
array
required
List of uploaded file information
string
required
Success message with upload count

Example Request

Example Response

Auto-Conversion to Markdown

The following file types are automatically converted to markdown using markitdown:
  • .pdf - PDF documents
  • .ppt, .pptx - PowerPoint presentations
  • .xls, .xlsx - Excel spreadsheets
  • .doc, .docx - Word documents
Both the original file and the converted markdown file are saved and accessible.

Error Responses

Bad Request
No files provided or invalid filename
Internal Server Error
Upload failed

Security

  • Filenames are sanitized to prevent path traversal attacks
  • Only the filename component is used (directory paths are stripped)
  • Files with unsafe names (., .., containing / or \) are rejected

List Uploaded Files

GET /api/threads/{thread_id}/uploads/list

List all files in a thread’s uploads directory

Path Parameters

string
required
The thread ID to list files for

Response

array
required
List of files with metadata
integer
required
Total number of files

Example Request

Example Response

Empty Directory

If no files have been uploaded:

Delete Uploaded File

DELETE /api/threads/{thread_id}/uploads/{filename}

Delete a file from a thread’s uploads directory

Path Parameters

string
required
The thread ID
string
required
The filename to delete

Response

boolean
required
Whether the deletion was successful
string
required
Success message

Example Request

Example Response

Error Responses

Forbidden
Access denied (path traversal attempt)
Not Found
File not found
Internal Server Error
Deletion failed

File Storage

Directory Structure

Virtual Paths

Files are accessible to AI agents via virtual paths:
Agents can read and process these files using their file tools.

Sandbox Synchronization

For non-local sandboxes (e.g., E2B), files are automatically synced:
  1. Upload: Files are saved to host storage and synced to sandbox
  2. Agent Access: Agents read files from sandbox virtual paths
  3. Source of Truth: Host storage remains the source of truth

Use Cases

Upload Files from Frontend

List and Display Files

Delete File

Access Uploaded Files

After uploading, files can be accessed via:
  1. Artifacts API: GET /api/threads/{thread_id}/artifacts/mnt/user-data/uploads/{filename}
  2. Agent Tools: Agents can read files using their virtual paths

Artifacts API

Access uploaded files

Gateway Overview

Learn about the Gateway API