API reference

Runs API

REST endpoints to start an AI agent run, list and inspect runs, stream their events as server-sent events and cancel them, with all request fields.

Start runs, follow them and read their results. Every endpoint on this page works with member and admin keys. See runs for the lifecycle and limits.

Start a run

POST/v1/runs
Creates a run and queues it. Send either a prompt or the name of a saved workflow.
Body
promptstring
The task. Required unless workflow is set; with a workflow, it replaces the saved prompt. Up to 128 KiB.
inputany JSON
Data for the task, passed to the agent as JSON. Up to 1 MiB.
workflowstring
Name of a saved workflow. Other definition fields you send override the saved ones.
modelstring
Model ID. Defaults to default_model from GET /v1/models.
filesarray
Up to 32 entries, each {"file": "<id or name>", "path": "..."} or {"path": "...", "content": "..."}. See files.
connectionsobject
Up to 16 connections, keyed by the name the agent sees. Each is {"ref": "<saved name>"} with optional allowed_methods or allowed_tools, or an inline definition. See connections.
descriptionstring
What the run does, for people and agents. Up to 500 characters. Harmless on an inline run; with a workflow it replaces the saved description.
input_schemaobject
A JSON Schema that input must match; a mismatch returns 400 with the path and reason, such as input.city: required. With a workflow, it replaces the saved schema. See describing inputs and outputs.
output_schemaobject
A JSON Schema that the run's output must match; a mismatch ends the run failed. With a workflow, it replaces the saved schema. See describing inputs and outputs.
timeout_secondsinteger
1 to 3600. Default 300.
shellboolean
Lets the agent run shell commands and write files in its working directory. Default true. The shell has no network access: web requests go through web, and pip or npm cannot download packages. Python 3.14 with common packages is preinstalled (GET /v1/me lists them); any other Python package can come as a wheel in files, installed with pip install --no-index and the wheel's path as listed in the agent's task.
webboolean | object
Lets the agent fetch pages, call public APIs and search through Ephemeral. true, or { "allow": [domains], "search": false } to limit it. Default off. Fetches follow each site's robots.txt, including its rules for every crawler (User-agent: *); a refused fetch reaches the agent as an error, not as an empty page. See web access.
zero_data_retentionboolean
Records nothing of the run's content: no stored events, no definition, and an output that is returned once. Hosted runs cost more. See zero data retention. Default false.
max_cost_microsinteger
Budget, 1 to 100,000,000. Defaults to default_max_cost_micros from GET /v1/me. On the hosted service it must cover the run fee plus the compute charge for the full timeout (10% more for zero data retention); a smaller budget is refused with 400 and a budget object that gives the figures. See budgets.
callbackobject
{"url": "...", "secret": "..."} for a signed request when the run ends. See callbacks. A run cannot have both callback and notify.
notifyobject
{"connection": "team-chat", "path": "/hooks/ephemeral", "on": "failure"}. When the run has finished and its cost is final, Ephemeral posts JSON to the saved HTTP connection, with the connection's credentials: {"event": "run.finished", "run": {…}, "text": "one line"}, with the headers X-Ephemeral-Event and X-Ephemeral-Run. The connection must allow POST. path is relative to its URL. on is always (default) or failure. Failed deliveries are retried with backoff. See being told when a run ends.
outputsstring[]
Up to 20 paths of files to save when the run ends, each relative to the agent's working directory or absolute under /tmp/. Each is saved as an organization file named runs/<run id>/<path>, at most 10 MiB each and 25 MiB per run. A missing file becomes an output_missing event; the run does not fail. A run without a shell writes them with the save_output tool. See outputs.
statestring
The name of a state store. The agent reads and writes it with state_get, state_set, state_delete and state_list. Writes it makes count toward the run's cost.
Headers
Idempotency-Keystring
Optional, up to 200 characters. A repeated key returns the existing run with 200.
Terminal
curl $EPHEMERAL_URL/v1/runs \
  -H "Authorization: Bearer $EPHEMERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: 7d0f3c1e-6a52-4b8e-9f21-0c4d5e6a7b89" \
  -d '{
    "workflow": "investigate-payment",
    "input": { "payment_id": "pay_123" },
    "max_cost_micros": 500000
  }'

The response is 202 Accepted with the new run object. A request that fails validation returns 400 and creates nothing. On the hosted service, 402 means your available credits do not cover the budget.

The run object

idstring
Run ID, such as run_4abb0f420c6623a12d2889610eb67284.
statusstring
reserving, queued, starting, running, succeeded, failed, cancelled, timed_out or interrupted.
outputstring
The agent's final answer. Omitted until there is one. Up to 1 MiB; a longer answer is cut there and an output_truncated event says so.
errorstring
Why the run did not succeed. For a failed run it carries the reason, such as Worker failed: Model request failed: …. External actions may have completed.. A run whose sandbox could not be started says so and that no run fee was charged, and can be retried. A zero-data-retention run's error stays generic. Omitted when empty.
workflowstring
The saved workflow the run was started from, when one was.
workflow_versioninteger
The version of that workflow the run used.
progressobject
The agent's latest report from its report_progress tool: message, percent and at. Not set for zero-data-retention runs.
filesarray
The files the run saved, once it has finished: id, name, path, size and content_type. See files a run saves.
modelstring
The model the run uses: the one you named, else the saved workflow's, else the default. Present even when you named none. Omitted for zero-data-retention runs.
created_attimestamp
When the run was created.
started_attimestamp
When it left the queue. Omitted before that.
finished_attimestamp
When it reached a final status. Omitted before that.
max_cost_microsinteger
The run's budget.
cost_microsinteger
Cost so far. Provisional until billing_pending is false on a finished run. Omitted when zero.
billing_pendingboolean
Whether the cost still has to be settled.
schedule_idstring
The schedule that started the run, when one did.
queue_reasonstring
While a run is queued: organization_limit when your organization already has its most runs in progress, capacity when every worker is busy. Omitted otherwise, and in run lists.
zero_data_retentionboolean
true for a zero-data-retention run.
surcharge_percentinteger
The surcharge rate, for zero-data-retention runs on the hosted service.
run_fee_microsinteger
The run fee, present once the run's worker has started. Part of cost_micros. Omitted when zero.
markup_percentinteger
The percentage added to model calls, fixed when the run was accepted. Omitted when zero.
markup_microsinteger
The part of cost_micros added by that percentage. Omitted when zero.
surcharge_microsinteger
The part of cost_micros added by the zero-data-retention surcharge. Omitted when zero.
output_availableboolean
Zero-data-retention runs only: whether the output is still held for retrieval.
output_expires_attimestamp
Zero-data-retention runs only: when a held output is deleted if nobody has read it.
JSON
{
  "id": "run_4abb0f420c6623a12d2889610eb67284",
  "status": "succeeded",
  "output": "The card issuer declined pay_123 for insufficient funds. The processor had no incidents. Ask the customer to retry or use another card.",
  "model": "anthropic/claude-haiku-5.5",
  "created_at": "2026-10-03T09:14:05.118Z",
  "started_at": "2026-10-03T09:14:05.402Z",
  "finished_at": "2026-10-03T09:14:41.877Z",
  "max_cost_micros": 500000,
  "cost_micros": 14390,
  "billing_pending": false
}

List runs

GET/v1/runs
Returns runs, newest first.
Query
limitinteger
1 to 100. Turns on paginated responses.
cursorstring
The next_cursor from the previous page.
statusstring
Return only runs with this status.
schedulestring
Return only runs started by this schedule.
GET /v1/runs?limit=2&status=failed
{
  "items": [
    { "id": "run_91c0…", "status": "failed", "error": "Worker failed: Model request failed: the provider is overloaded. External actions may have completed.", "created_at": "2026-10-03T08:51:12.004Z", "max_cost_micros": 500000, "cost_micros": 61200, "billing_pending": false },
    { "id": "run_3fd2…", "status": "failed", "error": "Credit reservation failed", "created_at": "2026-10-02T17:20:44.390Z", "max_cost_micros": 500000, "billing_pending": false }
  ],
  "next_cursor": "eyJvIjoib3JnXzVlMmIi…"
}

Without limit or cursor, the response is a plain array of the 100 most recent matching runs. See pagination.

Get a run

GET/v1/runs/{id}
Returns the run object. Poll this until the status is final, or use events or a callback.

Start a batch of runs

POST/v1/batches
Starts up to 100 runs of the same definition, one for each input, in one request.

The body is a run request without input: a prompt or a workflow and any other run fields, given once for every run. Every input is checked against the input_schema before any run starts. If one fails, no run starts and the 400 response lists each failure in errors, with its index and a reason such as inputs[3].url: required.

Body
inputsarray
1 to 100 items, one per run, in order: {"input": ..., "model": "...", "idempotency_key": "..."}. idempotency_key is optional and replaces the one derived from the batch's key. model is optional and runs that input with another model, so one batch can compare models on the same task; when the runs use more than one model, the batch summary gains by_model with each model's runs, statuses, cost and whether it is final.
max_total_cost_microsinteger
Optional. Refuses the batch when the number of runs times max_cost_micros is above it, so the batch can never cost more. It is a check, not a shared budget: each run keeps its own cap.
Headers
Idempotency-Keystring
Optional, up to 190 characters. A repeated key returns the existing batch with 200. Each input without its own key gets the key followed by : and its index.
Terminal
curl $EPHEMERAL_URL/v1/batches \
  -H "Authorization: Bearer $EPHEMERAL_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: payments-2026-11-30" \
  -d '{
    "workflow": "investigate-payment",
    "max_cost_micros": 500000,
    "inputs": [
      { "input": { "payment_id": "pay_123" } },
      { "input": { "payment_id": "pay_124" } }
    ]
  }'
JSON
{
  "batch_id": "bat_0c6e2f1a9b8d4c7e5f3a2b1c0d9e8f7a",
  "created_at": "2026-11-30T09:00:00.000Z",
  "run_ids": ["run_4abb0f420c6623a12d2889610eb67284", "run_91c0e5d2a7b34f18c6d09e2b5a7f3c41"],
  "model": "anthropic/claude-haiku-5.5",
  "summary": {
    "total": 2,
    "finished": 0,
    "by_status": { "queued": 2 },
    "total_cost_micros": 120000,
    "cost_final": false,
    "pending_run_ids": ["run_4abb0f420c6623a12d2889610eb67284", "run_91c0e5d2a7b34f18c6d09e2b5a7f3c41"]
  }
}

The response is 202 Accepted. Each run is an ordinary run: it has its own budget, is billed on its own and waits in the queue when your organization already has its most runs in progress. Check that limit and your credit with GET /v1/me first. On the hosted service, 402 means your available credits do not cover every run's budget, and nothing starts. If the runs cannot all be admitted (for example, a budget that your credits no longer cover), the response says which input failed in failed_index and lists the runs already started in admitted_run_ids. Retrying with the same Idempotency-Key keeps them and starts the rest.

Get a batch

GET/v1/batches/{id}
Returns the batch with its run objects in input order, as run lists show them, and the summary. total_cost_micros is final when cost_final is true: every run has finished and its billing has settled. Until then pending_run_ids lists the runs to wait for.

Stream events

GET/v1/runs/{id}/events
A server-sent event stream. It replays every recorded event, then sends new ones as they happen. When the run is final it sends done with the run object and closes.
Headers
Last-Event-IDinteger
Resume after this event ID, for example when reconnecting after a dropped connection.
Text
: connected

id: 88412
event: status
data: {"id":88412,"type":"status","data":{"status":"running"},"created_at":"2026-10-03T09:14:05.431Z"}

id: 88415
event: worker_started
data: {"id":88415,"type":"worker_started","data":{"runtime":"pi","mode":"pi","shell":false},"created_at":"2026-10-03T09:14:07.906Z"}

id: 88419
event: tool_start
data: {"id":88419,"type":"tool_start","data":{"tool":"http_0","id":"call_1","arguments":{"method":"GET","path":"/payments/pay_123"}},"created_at":"2026-10-03T09:14:10.215Z"}

id: 88431
event: result
data: {"id":88431,"type":"result","data":{"output":"The card issuer declined pay_123 for insufficient funds."},"created_at":"2026-10-03T09:14:41.702Z"}

event: done
data: {"id":"run_4abb0f420c6623a12d2889610eb67284","status":"succeeded", …}

Each message's data is an event object with id, type, data and created_at, except done, which carries the run object. Lines starting with a colon are comments; a heartbeat comment is sent every 15 seconds. The event types are listed under event types. Disconnecting does not cancel the run.

Terminal
curl -N $EPHEMERAL_URL/v1/runs/run_4abb0f420c6623a12d2889610eb67284/events \
  -H "Authorization: Bearer $EPHEMERAL_API_KEY"

Read events as JSON

GET/v1/runs/{id}/events?format=json
Returns a page of the recorded events instead of the stream, oldest first.
Query
afterinteger
Return events after this event ID. Default 0. Pass next_after from the previous page.
limitinteger
1 to 500. Default 100.
typestring
Only events of this type. Repeat it or separate types with commas.
max_string_bytesinteger
Cut every longer string in an event to this many bytes.
max_bytesinteger
The most bytes in a page. Default 1 MiB.
JSON
{
  "run_id": "run_91c0…",
  "status": "failed",
  "events": [
    { "id": 88415, "type": "worker_error", "data": { "message": "Model request failed: the provider is overloaded" }, "created_at": "2026-10-03T08:51:40.210Z" }
  ],
  "next_after": 88415,
  "has_more": false
}

While has_more is true, call again with after set to next_after. The MCP tool get_run_events wraps this endpoint.

Estimate the cost of runs

POST/v1/estimates
Estimates what a number of runs of one task will cost, before you start them. Nothing is started or charged.
Body
workflowstring
The name of a saved workflow. Give a workflow or a prompt.
promptstring
An inline prompt.
modelstring
A model ID. Defaults to the workflow's or the default model.
runsinteger
How many runs. 1 to 10,000. Default 1.
max_cost_microsinteger
The cap each run would have. Default default_max_cost_micros.
zero_data_retentionboolean
Whether the runs would be zero-data-retention runs, which keep no history to estimate from.

The answer holds runs, model, basis (the workflow or prompt, matched_runs, succeeded and since), per_run (typical_micros, high_micros, min_seen_micros, max_seen_micros and cap_micros), total (typical_micros, high_micros and cap_micros), typical_seconds and a note. Typical is the median and high the 90th percentile of your settled runs of the same workflow or prompt with the same model, still within the retention window. With no history, only the cap is known. The MCP tool is estimate_cost.

Cancel a run

POST/v1/runs/{id}/cancel
Cancels a run that is reserving, queued, starting or running, and returns the run object. A run that has already finished is returned unchanged.
Cancelling stops the worker. It does not undo anything the agent already did through a connection.

Delete a run

DELETE/v1/runs/{id}
Permanently deletes a finished run before its retention ends: its events, output, error and definition are deleted at once, and the run is no longer found. A run that has not finished is refused with 409: cancel it first. What the run cost stays charged. The files it saved stay in your files unless you add ?delete_files=true. The MCP tool is delete_runs, for up to 100 runs at once; in the dashboard, use Delete on the run's page.

Read a run definition

GET/v1/runs/{id}/definition
Returns the definition the run actually used, prepared for review before running it again.
JSON
{
  "request": {
    "prompt": "Find out why this payment failed. Follow the playbook.",
    "model": "anthropic/claude-haiku-5.5",
    "files": [{ "file": "file_9c41d2a07be35f1e8a6c0d4b9e2f7a13", "path": "playbook.md" }],
    "connections": {
      "payments": { "ref": "payments-api", "allowed_methods": ["GET"] },
      "crm": { "type": "http", "url": "https://api.example.com", "allowed_methods": ["GET"] }
    },
    "timeout_seconds": 120,
    "shell": false,
    "max_cost_micros": 500000,
    "input": { "payment_id": "pay_123" }
  },
  "requires_credentials": ["crm"]
}

request is the resolved definition. File names are replaced by the IDs that were used, and a workflow's saved fields are filled in. The workflow name and callback are left out. Saved connections keep only their reference and allowlists. Inline connections lose their credentials and any secrets in their URL.

requires_credentials lists inline connections that need credentials or their original URL restored. To run it again, add those back, choose a new max_cost_micros, and send the request to POST /v1/runs. Saved connection references are resolved again at that point, and the request fails if a referenced file or connection has been deleted.

The definition keeps your prompt, input and inline file contents as sent. Do not place secrets in them.

Zero data retention runs

Zero data retention covers what Ephemeral records about a run: its events, output and definition. Files and state a run is told to save are your storage, kept as your retention settings say.

A run with zero_data_retention returns its output once. The first GET /v1/runs/{id} after it finishes includes output and deletes it; later reads omit it and report output_available: false. When the run has a callback, the callback delivers the output, and GET leaves it in place until then. An undelivered output is deleted after at most an hour.

The event stream works while the run works and for a few minutes afterwards. GET /v1/runs/{id}/definition returns 410, and run lists never include output. On the hosted service cost_micros includes the surcharge, and the budget must cover it.

esc

Nothing matches “”.