Overview
When your agent needs to upload files to a website — such as submitting a PDF to a form, attaching a document to an email, or uploading an image to a CMS — you can provide files using the file upload API. Files are uploaded first, then referenced byfileId when starting a task.
This is a two-step process:
- Upload files to get
fileIdreferences - Attach files (an array of
fileIdstrings) to a task so the agent can use them
Step 1: Upload Files
Upload one or more files using the/files/upload endpoint. Files are sent as multipart form data.
Endpoint: POST /files/upload
Authentication: Required
Uploading Multiple Files
You can upload multiple files in a single request by repeating thefiles field:
Upload Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the upload succeeded |
files | array | Array of uploaded file metadata |
files[].fileId | string | Unique identifier to reference the file in tasks |
files[].originalName | string | Original filename as uploaded |
files[].size | number | File size in bytes |
Step 2: Attach Files to a Task
Once you havefileId values, include them in the files array at the task level when starting a task. All three task endpoints accept file references:
Using /start/run-task
Using /start/start-session
Includefiles inside the initialTask object:
Using /start/send-message
Includefiles in the message object when sending a newTask action:
Complete Example
Here’s a full workflow that uploads a PDF and instructs the agent to submit it to a website:Endpoint Reference
File IDs Across Endpoints
| Endpoint | Field | Location |
|---|---|---|
POST /files/upload | files (multipart) | Form data |
POST /start/run-task | files | Request body (task-level) |
POST /start/start-session | files | Inside initialTask object |
POST /start/send-message | files | Inside message object |
Best Practices
Upload Before Starting the Task
Always upload files first and wait for thefileId response before creating a task. File uploads are separate from task execution — the agent cannot access files that haven’t been uploaded yet.
Use Descriptive Task Instructions
Tell the agent what to do with the files and where to upload them:Combine with Other Parameters
File uploads work alongside all other task parameters — secrets, structured output, webhooks, and more:Related Guides
Related Guides