API reference

Files API

REST endpoints to upload, list, download, rename and delete the files that agent runs can mount read-only, with size limits and fields.

Upload files to your organization and manage them. Member and admin keys can use every endpoint on this page. See files for how runs mount them.

The file object

idstring
File ID, such as file_9c41d2a07be35f1e8a6c0d4b9e2f7a13.
namestring
Relative path used as the file's name, such as guides/refunds.md.
sizeinteger
Size in bytes.
content_typestring
Detected from the file's contents, made precise by its name's extension where the contents cannot tell, such as office documents, CSV, Markdown and JSON.
created_attimestamp
When it was uploaded or saved.
sourcestring
upload, or output for a file a run saved.
run_idstring
For an output file, the run that saved it.
run_pathstring
For an output file, the path the run named in outputs.
keepboolean
Whether the file is kept whatever the retention policy says.
expires_attimestamp | null
When the file will be deleted, by its own setting or the policy. null keeps it.

Upload a file

POST/v1/files
Stores a file of up to 1 MiB. Send it as multipart/form-data.
Form fields
filefilerequired
The file contents.
namestring
The name to store it under. Defaults to the uploaded file name. Must be a relative path of up to 240 characters.
expires_in_daysinteger
Delete the file after this many days, 1 to 3650.
keepboolean
Set to true to keep the file whatever the retention policy says.
curl $EPHEMERAL_URL/v1/files \
  -H "Authorization: Bearer $EPHEMERAL_API_KEY" \
  -F file=@refunds.md \
  -F name=guides/refunds.md

The response is 201 Created with the file object. Uploading again under an existing name adds a new file with a new ID; the older upload is kept.

JSON
{
  "id": "file_9c41d2a07be35f1e8a6c0d4b9e2f7a13",
  "name": "guides/refunds.md",
  "size": 18234,
  "content_type": "text/plain; charset=utf-8",
  "created_at": "2026-10-03T08:02:17.553Z"
}

List files

GET/v1/files
Returns every file, newest first: uploads and the files runs saved. Without cursor, a list of the newest limit files. With cursor, one page with items and next_cursor; pass next_cursor as cursor, with the same filters, for the next page, until it is empty.
Query
run_idstring
Only the files this run saved.
sourcestring
upload or output.
prefixstring
Only files whose name starts with this, such as runs/run_abc/.
limitinteger
At most 1,000, the default.
cursorstring
Empty for the first page, then the next_cursor of the previous page.

Download a file

GET/v1/files/{id}
Returns the raw contents as an attachment, with the stored content type. You can pass a name instead of an ID to get the latest upload with that name.
Terminal
curl $EPHEMERAL_URL/v1/files/file_9c41d2a07be35f1e8a6c0d4b9e2f7a13 \
  -H "Authorization: Bearer $EPHEMERAL_API_KEY" -o refunds.md

Change a file

PATCH/v1/files/{id}
Renames a file or changes when it is deleted. Takes an ID.
Body
namestring
The new name. A relative path of up to 240 characters.
expires_in_daysinteger
Delete the file this many days from now.
expires_attimestamp
Delete the file at this time.
keepboolean
true keeps the file whatever the policy says.
use_policyboolean
true drops the file's own expiry and keep setting, so the retention policy decides.

The response is the file object. Workflows that refer to the file by its old name stop finding it, while references by ID keep working.

Delete a file

DELETE/v1/files/{id}
Deletes one upload and its contents and returns 204 No Content. Takes an ID.

Queued runs that reference the file fail when they start, and later runs that name it fail at creation with 400. If an older upload with the same name exists, references by name resolve to that one instead.

Storage and retention

GET/v1/storage
Returns what the organization stores and what it costs.
usageobject
files, file_bytes, state_entries, state_bytes, stores and total_bytes.
policyobject
output_file_days, upload_file_days and state_days, each a number of days or null for no limit.
limitsobject
The limits that apply.
billingobject
Hosted service only: storage_micros_per_gb_month, state_write_micros, owed_micros, owed_since and delete_after (when something is owed), unbilled_writes, unbilled_storage_micros, charged_last_30_days_micros and writes_refused.
PUT/v1/storage/policy
Sets the retention policy. Owners and admins only. Each field you give is 1 to 3,650 days, or null to keep; a field you leave out keeps its current value. It applies to what is stored now as well as later; older items are deleted within minutes. A file's own expiry or keep setting, and an entry's ttl_seconds, take precedence.
Terminal
curl -X PUT $EPHEMERAL_URL/v1/storage/policy \
  -H "Authorization: Bearer $EPHEMERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"output_file_days": 30, "upload_file_days": null, "state_days": 90}'

On the hosted service, GET /v1/me also returns storage_micros_per_gb_month and state_write_micros, and storage_owed_micros when anything is owed. While $0.01 or more is owed, saving files, run outputs and state is refused with 402. See storage billing.

State

Key-value stores that runs share. See state for the idea. A store name is letters, digits, dot, dash and underscore; a key is up to 512 bytes of text, URL-encoded in the path; a value is any JSON up to 1 MiB.

GET/v1/state
Lists the stores: {"items": [{ "store", "entries", "bytes", "updated_at" }]}.
GET/v1/state/{store}
Lists a store's entries in key order, without values. Query: prefix, cursor and limit. Returns {"store", "items": [{ "store", "key", "version", "size", "created_at", "updated_at", "expires_at" }], "has_more", "next_cursor"}.
DELETE/v1/state/{store}
Deletes the whole store and returns {"deleted_entries": 12}.
GET/v1/state/{store}/entries/{key}
Returns the entry with its value and version.
PUT/v1/state/{store}/entries/{key}
Writes an entry.
Body
valueany JSONrequired
The value, up to 1 MiB.
ttl_secondsinteger
Delete the entry after this many seconds.
if_versioninteger
Write only if the entry is at this version. 0 means only if it does not exist. A mismatch returns 409.
DELETE/v1/state/{store}/entries/{key}
Deletes an entry. ?if_version= deletes it only at that version.
GET/v1/state/{store}/entry?key=
The same as the three entry endpoints above, with the URL-encoded key in the key query parameter instead of the path: GET, PUT and DELETE take the same bodies and give the same answers. Use it for keys that contain slashes, or two in a row, such as URLs.

Each write costs $0.01 per 1,000 writes on the hosted service; reads are free.

esc

Nothing matches “”.