Skip to content

Files

A file is either a document you upload for an agent to read during a session, or an output an agent writes during a session. Upload a file, then attach it when you create a session. Each upload is stored in the Context app, in the Drive of the user who owns the API key.

The agent writes the files it produces to /mnt/session/outputs/, as on Anthropic’s API. To get them, list files with scope_id set to the session’s ID, then download each one. They stay listed after you archive the session.

Deleting a file is permanent: it can’t be restored through this API or the app. You can delete only files you uploaded. Files a session produced can’t be deleted or attached to another session. You can’t delete a file attached to a session that isn’t archived. The request returns 400. Archive the session first.

Endpoints

EndpointWhat it does
POST /v1/filesUploads one file to the Drive of the user who owns the key.
GET /v1/filesLists the files this key or its owner uploaded, or the files a session produced, newest first.
GET /v1/files/{file_id}Returns a file’s metadata.
GET /v1/files/{file_id}/contentReturns a file’s content exactly as it was uploaded or as a session wrote it.
DELETE /v1/files/{file_id}Permanently deletes an uploaded file.

The file object

FieldTypeDescription
idstringThe file’s ID. An uploaded file’s ID is a UUID. A file a session produced has an ID that starts with sesnfile_. Treat both as opaque.
typestringAlways file.
filenamestringThe name sent with the upload. For a file a session produced, this is its path in the session’s output folder, such as charts/q3.csv.
mime_typestringThe media type sent with the upload, or application/octet-stream if none was sent.
size_bytesintegerThe size in bytes, or 0 if the size wasn’t recorded.
created_atstringWhen the file was uploaded or written, as an RFC 3339 timestamp.
downloadablebooleanAlways true.
scopeobjectThe session that produced the file, as {type: "session", id}, where id is the session’s ID. Uploaded files have no scope field.
{
"id": "329409ba-f288-4b44-9c73-14a18150edee",
"created_at": "2026-10-21T01:41:11.028Z",
"filename": "cities.csv",
"mime_type": "text/csv",
"size_bytes": 46,
"type": "file",
"downloadable": true
}

Differences from Anthropic’s API

This API follows Anthropic’s Managed Agents API, with these differences:

  • Upload accepts expires_in_seconds from 3600 to 7776000, but doesn’t apply it. Files don’t expire, and the file object has no expires_at.
  • List files doesn’t support ids. Sending it returns 400.
  • A list response holds at most 100 files per page. Anthropic’s API allows up to 1,000.
  • An upload can be as large as your deployment’s upload limit, which defaults to 5 GiB. Anthropic’s limit is 500 MB.
  • The files a session produced can’t be deleted or attached to another session through this API.
  • List files also accepts after_id and before_id, and returns has_more, first_id and last_id, which Anthropic’s list response doesn’t include.
  • Deleting a file that a session still uses returns 400. See Delete a file.

For every difference in one place, see Coming from Anthropic’s API.