Agent runs
Start an agent on a set of files. Then answer its sign-offs and human steps over the API.
An agent is a multi-step automation with built-in human sign-off. An agent run (agr_…) is one execution of an agent. These six routes are the whole surface:
Pick an agent
Read tasks[] and actions[] before you start. They tell you which steps come back as human work, and which actions stop for a sign-off. GET /v1/agents/:id returns the same shape for one agent.
Start a run
There is no ttl. Files you pass by URL join your reusable corpus, and no deadline purges them. A run can wait days on a person.
What comes back
The call holds open for up to ?wait= seconds (default 60, max 120, 0 returns immediately). It releases early when the run finishes or blocks on a person.
The 202 is not an error. You get the run id either way. Send an idempotency-key header to make retries safe. A replay returns the original run with an idempotent-replay: true response header.
Poll a queued run. File preparation can take minutes for scans or long audio. A read of the run starts it once the files are ready. A run that has not started reports nothing. A webhook alone leaves it queued forever. Once the run starts, events arrive as they happen.
Poll the run
?wait= (0–120, default 0 here) holds the request until the run finishes or blocks on a person. A loop of long polls then costs one request per minute, not one per second.
Decide an approval
Read the outstanding sign-offs from approvals[]. Then answer one by id:
run.status tells you whether the run moved on, finished, or blocked on the next item. ?wait= holds the request while the run resumes work.
params and files together must stay under 1 MiB. A second decision on the same approval is a 409. The first answer stands.
An API key has no person behind it. The run records your organization’s key as the actor, not a named individual.
Complete a human step
Your steps are the entries in tasks[] with executor: "human" and status: "ready". When you close one, all dependent work releases:
Both body fields are optional. Send {} if you have neither. note is ≤ 2000 characters. files is up to 20 ids that you registered or that the run holds. They appear in the run’s output.files.
End to end
The whole loop, with a webhook that does the waiting:
Start the run
POST /v1/agent-runs with {agent, files: [{url}], metadata, webhook: {url}} → 202, status: "queued". Keep the agr_ id.
Poll once to pick it up
GET /v1/agent-runs/:id?wait=60. This read starts a queued run once its files are ready. Events flow from this point.
A sign-off is requested
agent_run.approval_requested arrives. The event is minimal by design. Re-read the run and take the params and files from approvals[].
Answer it
POST /v1/agent-runs/:id/approvals/:approvalId with {"decision": "approve"}. The response’s run.status shows what the run did next.
What this surface does not have
- No list. There is no
GET /v1/agent-runs. Hold theagr_id from create, or tag runs withmetadatayou know. - No cancel, no delete. An agent run runs until it finishes, parks, or reaches
expiresAt. - Not in
GET /v1/runs. That list holds capability runs only (extract_run,parse_run, …). The TTL andkeepbehavior on Runs does not apply here. An agent run’s inputs are persistent files, and the run has nottl.