---
title: "Agent runs"
description: "Start an agent on a set of files. Then answer its sign-offs and human steps over the API."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cloudraker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent runs

An [agent](https://docs.cloudraker.com/paperwork/capabilities/agents) 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:

```
GET  /v1/agents                                     agents you can run
GET  /v1/agents/:id                                 one agent: steps, actions, gates
POST /v1/agent-runs                                 start a run
GET  /v1/agent-runs/:id                             where it is, accepts ?wait=
POST /v1/agent-runs/:id/approvals/:approvalId       approve or reject a step
POST /v1/agent-runs/:id/tasks/:taskId/complete      mark a human step done
```

## Pick an agent

```bash
curl https://api.cloudraker.com/v1/agents \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY"
```

```jsonc
{
  "object": "list",
  "data": [
    {
      "object": "agent",
      "id": "01JQ8ZKMRT4V6WXYZ0ABCDEFGH",
      "name": "Client intake",
      "version": 7,
      "tasks": [
        { "id": "task-1", "title": "Extract the intake fields", "executor": "agent", "dependsOn": [] },
        { "id": "task-2", "title": "Countersign the engagement letter", "executor": "human", "dependsOn": ["task-1"] }
      ],
      "actions": [{ "name": "Sign document", "approval": "before" }]
      // …description, updatedAt
    }
  ]
}
```

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

```bash
curl -X POST "https://api.cloudraker.com/v1/agent-runs?wait=60" \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "01JQ8ZKMRT4V6WXYZ0ABCDEFGH",
    "files": [{ "url": "https://example.com/intake.pdf", "name": "intake.pdf" }],
    "metadata": { "caseId": "42" },
    "webhook": { "url": "https://example.com/hooks/cloudraker" }
  }'
```

| Field | Type | What it does |
|---|---|---|
| `agent` | string | **Required.** The agent id from `GET /v1/agents`. |
| `files[]` | array of `{url, name?, processing?}` or `{id}`, 1–200 | **Required.** `{url}` registers and fetches the file. `{id}` reuses a file from [`POST /v1/files`](https://docs.cloudraker.com/paperwork/developers/files); the API does not parse it twice. |
| `metadata` | object | Your own key/values, echoed back on every read of the run. Max 10 KB. Carry your `caseId` here to avoid a lookup table. |
| `webhook` | `{url}` or `{id}` | Where to deliver this run's events. See [Webhooks](https://docs.cloudraker.com/paperwork/developers/webhooks#agent-runs). |

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.

| Outcome | Response |
|---|---|
| Finished inside the window | `200` with the full run |
| Files still being prepared | `202` with `status: "queued"` |
| Still working at the cap | `202` with `{object, id, status, statusUrl}` |
| Blocked on a person | `202` right away, `status: "waiting"` |

```json
{
  "object": "agent_run",
  "id": "agr_01KYD1J8QW2RN4T6VXZ0ABCDEF",
  "status": "waiting",
  "statusUrl": "/v1/agent-runs/agr_01KYD1J8QW2RN4T6VXZ0ABCDEF"
}
```

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.

> **Warning**
>
> **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.


```bash
curl -X POST https://api.cloudraker.com/v1/agent-runs \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "agent": "string",
  "files": [
    {
      "url": "http://example.com"
    }
  ]
}'
```

## Poll the run

```bash
curl "https://api.cloudraker.com/v1/agent-runs/agr_01KYD1J8QW2RN4T6VXZ0ABCDEF?wait=60" \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY"
```

`?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.

```jsonc
{
  "object": "agent_run",
  "id": "agr_01KYD1J8QW2RN4T6VXZ0ABCDEF",
  "agent": { "id": "01JQ8ZKMRT4V6WXYZ0ABCDEFGH", "name": "Client intake", "version": 7 },
  "status": "waiting",
  "waiting": { "approvals": 1, "tasks": 0, "summary": "Waiting on a sign-off for Sign document." },
  "progress": { "tasks": { "total": 2, "completed": 1 } },
  "tasks": [
    {
      "id": "task-1",
      "title": "Extract the intake fields",
      "executor": "agent",
      "status": "completed",
      "summary": "Read 14 fields from intake.pdf.",
      "completedAt": "2026-07-29T09:41:02.117Z"
    },
    {
      "id": "task-2",
      "title": "Countersign the engagement letter",
      "executor": "human",
      "status": "pending",
      "summary": null,
      "completedAt": null
    }
  ],
  "approvals": [
    {
      "id": "7c1e9f42-3b0d-4a5e-8f61-2d9c4b7ae013",
      "kind": "before",
      "action": "Sign document",
      "requestedAt": "2026-07-29T09:41:05.902Z",
      "rationale": "Ready to send the engagement letter for signature.",
      "files": [{ "id": "a04d6597-4e34-4a99-94ea-964c289a4c68", "name": "engagement-letter.pdf" }],
      "params": { "signers": [{ "name": "Jane Doe", "email": "jane@example.com" }] }
    }
  ],
  "statusUrl": "/v1/agent-runs/agr_01KYD1J8QW2RN4T6VXZ0ABCDEF",
  "metadata": { "caseId": "42" },
  "createdAt": "2026-07-29T09:40:58.004Z",
  "expiresAt": "2026-08-05T09:40:58.004Z"
}
```

| Field | What it is |
|---|---|
| `status` | One of `queued`, `processing`, `waiting`, `paused`, `completed`, `failed`, `cancelled`, `expired`. See the [status table](https://docs.cloudraker.com/paperwork/capabilities/agents#run-statuses). |
| `waiting` | Present while `status` is `waiting`. Counts outstanding approvals and human steps, with a one-line `summary`. |
| `paused` | Present while `status` is `paused`, with `reason: "model_error"` or `"system_error"`. Not a failure. |
| `tasks[]` | The step ledger: `executor`, `status`, and the `summary` the agent recorded when the step closed. |
| `approvals[]` | Sign-offs that block the run, oldest first, with the proposed `params` and `files`. |
| `progress.tasks` | `{total, completed}`. |
| `result` | The agent's closing summary, on a finished run. |
| `output.files[]` | Files attached during step completion. Each `url` is signed and valid for about one hour. |
| `error` | `{code, message}`, present whenever `status` is `failed`. |
| `incomplete` | `true` on a `completed` run that still had outstanding work. |
| `expiresAt` | The run's deadline, about seven days out. Past it, an unfinished run parks permanently. |


```bash
curl -X GET https://api.cloudraker.com/v1/agent-runs/id \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY"
```

## Decide an approval

Read the outstanding sign-offs from `approvals[]`. Then answer one by id:

```bash
curl -X POST "https://api.cloudraker.com/v1/agent-runs/agr_01KYD1J8QW…/approvals/7c1e9f42-3b0d-4a5e-8f61-2d9c4b7ae013?wait=60" \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "decision": "approve" }'
```

```json
{
  "object": "agent_run_approval",
  "id": "7c1e9f42-3b0d-4a5e-8f61-2d9c4b7ae013",
  "kind": "before",
  "action": "Sign document",
  "status": "approved",
  "requestedAt": "2026-07-29T09:41:05.902Z",
  "decidedAt": "2026-07-29T09:42:11.508Z",
  "note": null,
  "run": {
    "id": "agr_01KYD1J8QW2RN4T6VXZ0ABCDEF",
    "status": "waiting",
    "statusUrl": "/v1/agent-runs/agr_01KYD1J8QW2RN4T6VXZ0ABCDEF"
  }
}
```

`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.

| Field | What it does |
|---|---|
| `decision` | **Required.** `approve` or `reject`. |
| `note` | ≤ 4000 characters. **Required on `reject`.** A rejection without one is a `400`. |
| `params` | Replaces the inputs the agent proposed, for a `before` gate. |
| `files` | Replaces the files for the step. Up to 200 file ids, from [`POST /v1/files`](https://docs.cloudraker.com/paperwork/developers/files) or the run's own inputs. |

`params` and `files` together must stay under 1 MiB. A second decision on the same approval is a `409`. The first answer stands.

```bash
# reject, with the reason
-d '{ "decision": "reject", "note": "Wrong signer — resend to the CFO." }'

# approve, but fix the inputs first
-d '{ "decision": "approve", "params": { "signers": [{ "name": "Ada Byron", "email": "ada@example.com" }] } }'
```

> **Note**
>
> An API key has no person behind it. The run records your organization's key as the actor, not a named individual.


```bash
curl -X POST https://api.cloudraker.com/v1/agent-runs/id/approvals/approvalId \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "decision": "approve"
}'
```

## 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:

```bash
curl -X POST "https://api.cloudraker.com/v1/agent-runs/agr_01KYD1J8QW…/tasks/task-2/complete?wait=60" \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "note": "Client signed; scan attached.", "files": ["a04d6597-4e34-4a99-94ea-964c289a4c68"] }'
```

```json
{
  "object": "agent_run_task",
  "id": "task-2",
  "title": "Countersign the engagement letter",
  "executor": "human",
  "status": "completed",
  "summary": "Client signed; scan attached.",
  "completedAt": "2026-07-29T09:44:37.221Z",
  "run": {
    "id": "agr_01KYD1J8QW2RN4T6VXZ0ABCDEF",
    "status": "completed",
    "statusUrl": "/v1/agent-runs/agr_01KYD1J8QW2RN4T6VXZ0ABCDEF"
  }
}
```

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`.

| Situation | Response |
|---|---|
| The step's `executor` is `agent` | `422`. Only human steps are completable. |
| Its `dependsOn` steps aren't finished | `409`. |
| It is already done | `409`. |


```bash
curl -X POST https://api.cloudraker.com/v1/agent-runs/id/tasks/taskId/complete \
  -H "Authorization: Bearer $CLOUDRAKER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "note": "string",
  "files": [
    "string"
  ]
}'
```

## End to end

The whole loop, with a webhook that does the waiting:

1. **Start the run**

   `POST /v1/agent-runs` with `{agent, files: [{url}], metadata, webhook: {url}}` → `202`, `status: "queued"`. Keep the `agr_` id.
2. **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.
3. **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[]`.
4. **Answer it**

   `POST /v1/agent-runs/:id/approvals/:approvalId` with `{"decision": "approve"}`. The response's `run.status` shows what the run did next.
5. **A human step opens**

   `agent_run.task_ready` arrives with the step's `id` and `title`. This is the one item a person must do.
6. **Close it**

   `POST /v1/agent-runs/:id/tasks/:taskId/complete` with a `note` and any `files`. `agent_run.completed` follows, carrying `result`, `progress`, and `output`.

## What this surface does not have

- **No list.** There is no `GET /v1/agent-runs`. Hold the `agr_` id from create, or tag runs with `metadata` you 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 and `keep` behavior on [Runs](https://docs.cloudraker.com/paperwork/developers/runs) does not apply here. An agent run's inputs are persistent files, and the run has no `ttl`.

## Restrict a key to its own runs

By default, any API key in your organization can read and control every agent run in the organization. This includes runs started by a different key.

Ask your account team to turn on the `v1_scoped_runs` organization setting. Once it is on, each key sees only the runs it created. A call against a run from another key returns a `404`, the same response as an unknown id.

> **Note**
>
> This setting is opt-in today and becomes the default in a future release. Turn it on now to check your integration against the new behavior before it is required.

Two things stay unaffected:

- A run that predates the setting has no recorded owner. It stays visible to every key in the organization.
- A session token for a human administrator is never scoped. An administrator sees every run.

## Next steps

[**Agents**](https://docs.cloudraker.com/paperwork/capabilities/agents)

What an agent is: the step ledger, the approval gates, the statuses.


[**Webhooks**](https://docs.cloudraker.com/paperwork/developers/webhooks#agent-runs)

The five `agent_run.*` events and how to verify a delivery.


[**Files**](https://docs.cloudraker.com/paperwork/developers/files)

Register a document once and pass it to a run by id.


[**Errors**](https://docs.cloudraker.com/paperwork/developers/errors)

The error envelope and which codes are worth retrying.

Source: https://docs.cloudraker.com/paperwork/developers/agent-runs/index.mdx
