# POST /api/v2/automation-runs/{automation_run}/actions/cancel

Cancel a waiting automation run

- MCP id: automation-runs.actions.cancel
- Scope: api:write:automations
- Scope: api:write:project_automations
- Scope: api:write:customer_automations
- Permission: automations::update
- Needs the automations feature on your organisation
- Rate cost: 1 unit, write bucket. A write costs the same whatever `view` you ask for.
- Cache-Control: private, no-store

Stops a run that waits, such as at a Wait step or for a run of another automation it started: it ends as `skipped`, and its waiting step names who cancelled it.

A run that is not waiting answers `409` `not_waiting`. Cancelling takes the right to change the run's automation. The declared permission is `automations::update`; for a project or customer automation, the `project_automations` or `customer_automations` permission of the same action applies instead.

## Parameters
- automation_run (integer or string, path): The AutomationRun's numeric id. Or its uuid, matching `[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}`.
- view (string, optional): Which field set to render.
- X-Request-Id (header, optional): A correlation id of your own. It is recorded in our logs next to the server's request id but never returned: the response header always carries the server's id. A value that does not match the pattern is discarded silently, never rejected.
- If-Match (header, optional): The ETag a write is conditional on. A stale validator is 412 precondition-failed.
- Idempotency-Key (header, optional): A caller-chosen key that makes this POST safe to retry. Replaying it returns the original response with Idempotency-Replayed: true.

## Response 200
- id (integer, required): Unique identifier.
- uuid (string ≤ 36, required): The run's public id, which a webhook's answer hands the sender. Reads the same as `id` in the path.
- automation_id (integer, required): The automation that ran.
- automation_version_id (integer or null, required): The version of the flow the run started with. `null` once that version is gone.
- status (string, required): `pending` until a worker picks it up, `running`, `waiting` (such as at a Wait step), and finally `completed`, `failed`, `halted` (a step stopped it), `skipped` (not started, such as while switched off) or `throttled` (over a limit).
- mode (string, required): `live` for a run its trigger started, `test` for one an editor started to try the flow out.
- trigger_kind (string ≤ 20, required): What started it: `record` (a record event), `schedule`, `date`, `manual`, `webhook` or `automation` (a step of another automation).
- trigger_event (string or null, required): For a run a record event started, which event.
- record_type (string or null ≤ 255, required): The record type the run started on, such as `work_item`; `null` without a record.
- record_id (string or null ≤ 255, required): The key of that record. Shown to every reader, as the run page shows it.
- record_title (string or null, required): The record's title, only when the reader may see the record.
- context_id (integer or null, required): For an automation of every project or customer, the one the run happened in.
- parent_run_id (integer or null, required): The run of another automation whose step started this one, when the reader may see that automation.
- triggered_by_id (integer or null, required): Who started it, by hand or with the change that set it off.
- run_as_id (integer or null, required): Whose permissions its steps used: the automation's owner, or the editor for a test.
- attempts (integer, required): How often a worker took the run up, retries included.
- started_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): When the first step began.
- finished_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): When it ended; `null` while it is not finished.
- duration_ms (integer or null, required): How long it ran, in milliseconds.
- resume_at (timestamp (YYYY-MM-DDThh:mm:ssZ) or null, required): While it waits, when it carries on at the latest.
- failure_reason (string or null, required): Why it failed, halted or was skipped. Record data appears in it only when `reveals_data` is true.
- reveals_data (boolean, required): Whether you may see what the run worked with: for a run on a record, whether you may see that record; otherwise, whether you may change the automation. Without it, `inputs`, `changes` and the steps' `input` and `output` are empty and messages carry no record data.
- inputs (object or null, required, detail only): What the person who started it filled in, by input name. `null` when `reveals_data` is false.
- changes (object, required, detail only): For a run a change started, the fields that changed, each `{label, old, new}`, without the fields you may not read. Empty unless you may see the record.
- created_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): When the run was started.
- updated_at (timestamp (YYYY-MM-DDThh:mm:ssZ), required): Last-write timestamp; use for incremental sync.
- automation (Ref or AutomationSummary, required): The automation that ran.
- version (Ref or AutomationVersionSummary or null, required): The version of the flow the run started with.
- triggered_by (Ref or UserSummary or null, required): Who started it.
- run_as (Ref or UserSummary or null, required): Whose permissions its steps used.
- steps_count (integer ≥ 0, required): How many step executions the run recorded.
- links (AutomationRunLinks, required)
  - self (url, required): The canonical URI of this record.
  - steps (url, required): What each step of the run did.

## Errors
- 403 forbidden-by-policy | insufficient-permission | insufficient-token-scope: Forbidden.
- 409 idempotency-key-in-flight | idempotency-key-reused | state-conflict: Conflict.
- 412 precondition-failed: Precondition failed.
- 400 idempotency-key-required | invalid-cursor | invalid-query-parameter | malformed-request | unsupported-parameter: Bad request.
- 401 token-expired | unauthenticated: Unauthenticated.
- 404 endpoint-not-found | resource-not-found: Not found.
- 406 not-acceptable: Not acceptable.
- 429 rate-limit-exceeded: Too many requests.
- 500 internal-error: Server error.
- 503 tenant-unavailable: Service unavailable.

## Example
```bash
curl -X POST \
  'https://<your-url>/api/v2/automation-runs/1/actions/cancel' \
  -H 'Authorization: Bearer <token>' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: <key>' \
  -d '{}'
```
