Upload files to give your agent context, and download files it produces.
The Files API lets you supply context to a Session — code repositories, configuration, reference docs, and so on. The Agent can read these files to understand the task.
Response:
Uploading multiple files:
After uploading, use the Resources API to mount the file on a specific Session:
Request body — send a single file resource:
To attach multiple files after Session creation, call the endpoint once per file.
Files with
For non-downloadable files, requests to
Filtering by
A file the Agent generates in a Session reaches the client in these steps:
For the endpoints, see List files and Download file content.
Q: How long are uploaded files retained? A: Files are retained until you explicitly delete them via
Workflow
1
Upload file
POST /api/v1/cloud/files — upload text-based content.2
Mount on Session
POST /api/v1/cloud/sessions/{session_id}/resources — attach the uploaded file to the Session.3
Agent uses it
The Agent reads the file's contents during the Session and completes the task.
Upload a File
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
file | binary | Yes | File contents |
name | string | No | Custom filename |
Use the File object's
downloadable field to decide whether /content is available.curl Upload Example
Mount on a Session
After uploading, use the Resources API to mount the file on a specific Session:
curl Mount Example
Download a File
Files with "downloadable": true can be downloaded:
/content return 403 Forbidden.
Inspect File Metadata
List Files
scope_id is supported for Session-scoped files.
Delivering and retrieving session outputs
A file the Agent generates in a Session reaches the client in these steps:
- The Agent writes the file under
/data/in the sandbox withWrite - The Agent calls
DeliverArtifactsto deliver it as a File - The event stream emits
agent.artifact_deliveredwithfile_id,original_filename,size, andcontent_type - The client retrieves the file through the Files API
- Only files with
downloadableset totruecan be downloaded. - A file can take a few seconds after delivery to appear in the list.
- The Agent may also return the result directly in its reply. Clients should handle both cases.
- To evaluate outputs against acceptance criteria, see Outcome Evaluation.
End-to-End Example
FAQ
Q: How long are uploaded files retained? A: Files are retained until you explicitly delete them via DELETE /api/v1/cloud/files/{file_id}. A file that is still referenced by an active Session cannot be deleted — remove or detach the Session first.
Q: Can I attach files when creating a Session? A: Yes. Pass file resources in the resources field when creating the Session. See Sessions — Attach Resources at Creation.
Q: Why can't I download some files? A: For security, some files are only available for the Agent's internal use. To export results, use files whose File object returns "downloadable": true.
Q: Which file formats are supported? A: The upload API accepts text-based files. Code, configuration, and plain-text reference documents work best.
