---
title: "Cancel an agent run"
---

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

# Cancel an agent run

Path: CloudRaker Paperwork API › Agents

`POST /v1/agent-runs/{id}/cancel`

Stops a run permanently. Work it already completed is retained.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `id` (`cancelAgentRun.path.id`; string, required)
  - minLength 1

## Query parameters

- `wait` (`cancelAgentRun.query.wait`; integer, optional) — How many seconds to hold the request open. Releases early the moment the run finishes **or** blocks on a person. Maximum 120; `0` returns immediately.
  - min 0; max 120; default `60`

## Header parameters

- `idempotency-key` (`cancelAgentRun.header.idempotency-key`; string, optional) — Retries with the same key replay the first applied mutation.
  - minLength 1; maxLength 255

## Request body

_Optional._

An optional reason for cancelling.

- `reason` (`cancelAgentRun.reason`; string, optional)
  - minLength 1; maxLength 4000

## Example request

```json
{}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url 'https://api.cloudraker.com/v1/agent-runs/<id>/cancel' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{}'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/v1/agent-runs/<id>/cancel';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/v1/agent-runs/<id>/cancel"

payload = {}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

The cancelled run state.

#### Example

```json
{
  "object": "agent_run_control",
  "action": "steer",
  "run": {
    "id": "string",
    "status": "queued",
    "statusUrl": "string"
  }
}
```

- `object` (`cancelAgentRun.response.200.object`; string, required)
- `action` (`cancelAgentRun.response.200.action`; string, required)
  - one of `"steer"`, `"pause"`, `"resume"`, `"cancel"`
- `run` (`cancelAgentRun.response.200.run`; object, required)
  - `id` (`cancelAgentRun.response.200.run.id`; string, required)
  - `status` (`cancelAgentRun.response.200.run.status`; string, required) — Where the agent run is in its life. | Status | Meaning | | --- | --- | | `queued` | Accepted; its files are still being prepared | | `processing` | The agent is working | | `waiting` | Blocked on a person — see `waiting`, `approvals` and `tasks[]` | | `paused` | Stopped short of finishing and resumable; not a failure | | `completed` | Finished; `result` and `output` are populated | | `failed` | Finished without producing a result | | `cancelled` | Stopped on request | | `expired` | Reached its `expiresAt` without finishing | `completed`, `failed`, `cancelled` and `expired` are terminal. A `completed` run that still had outstanding work also carries `incomplete: true`.
    - one of `"queued"`, `"processing"`, `"waiting"`, `"paused"`, `"completed"`, `"failed"`, `"cancelled"`, `"expired"`
  - `statusUrl` (`cancelAgentRun.response.200.run.statusUrl`; string, required)

### 400

Validation Error

#### Example

```json
{
  "success": false,
  "error": [
    null
  ],
  "data": null
}
```

- `success` (`cancelAgentRun.response.400.success`; boolean, required)
  - one of `false`
- `error` (`cancelAgentRun.response.400.error`; array<unknown>, required)
- `data` (`cancelAgentRun.response.400.data`; unknown, required)

### 401

Missing or invalid credentials.

#### Example

```json
{
  "code": "string",
  "message": "string",
  "retryable": true,
  "requestId": "string",
  "docUrl": "string"
}
```

- `code` (`cancelAgentRun.response.401.code`; string, required)
- `message` (`cancelAgentRun.response.401.message`; string, required)
- `retryable` (`cancelAgentRun.response.401.retryable`; boolean, required)
- `requestId` (`cancelAgentRun.response.401.requestId`; string, required)
- `docUrl` (`cancelAgentRun.response.401.docUrl`; string, optional)

### 403

The credential is valid but cannot administer this organization.

#### Example

```json
{
  "code": "string",
  "message": "string",
  "retryable": true,
  "requestId": "string",
  "docUrl": "string"
}
```

- `code` (`cancelAgentRun.response.403.code`; string, required)
- `message` (`cancelAgentRun.response.403.message`; string, required)
- `retryable` (`cancelAgentRun.response.403.retryable`; boolean, required)
- `requestId` (`cancelAgentRun.response.403.requestId`; string, required)
- `docUrl` (`cancelAgentRun.response.403.docUrl`; string, optional)

### 404

Unknown run id.

### 409

The run cannot be cancelled in its current state.

### 429

Rate limited. The `/v1` API allows at least **67 requests per minute per organization** (about 1,000 requests per 15 minutes) — a guaranteed floor, enforced per edge location, so a geographically spread caller may get more. Wait for the `Retry-After` interval and retry — the error is `retryable`.

#### Example

```json
{
  "code": "rate_limited",
  "message": "string",
  "retryable": true,
  "requestId": "string",
  "docUrl": "string"
}
```

- `code` (`cancelAgentRun.response.429.code`; string, required)
  - one of `"rate_limited"`
- `message` (`cancelAgentRun.response.429.message`; string, required)
- `retryable` (`cancelAgentRun.response.429.retryable`; boolean, required)
  - one of `true`
- `requestId` (`cancelAgentRun.response.429.requestId`; string, required)
- `docUrl` (`cancelAgentRun.response.429.docUrl`; string, optional)


Source: https://docs.cloudraker.com/paperwork/api/agents/cancel-agent-run/index.md
