# Cancel run

`POST /v1/automations/{automationId}/runs/{id}/cancel`

Takes one person out of an automation. Emails already sent are not recalled.

Needs the scope: `automations:write`

## Path parameters

- `id` (string, required): The id of the item. Up to 64 characters.
- `automationId` (string, required): The id of the automation. Up to 64 characters.

## Returns

- `object` ("automation_run"): Always `automation_run`.
- `id` (string): The id of the run.
- `automationId` (string): The id of the automation.
- `version` (integer): The version of the automation the run follows.
- `email` (string): The address of the person.
- `contactId` (string | null): The id of their contact, or `null` for a bare address.
- `status` (string): Where the run stands: `running`, `waiting`, `completed`, `exited`, `failed` or `canceled`. One of: `running`, `waiting`, `completed`, `exited`, `failed`, `canceled`.
- `stepId` (string | null): The id of the step it is at, or `null` once it has ended.
- `source` (string): What started it: the name of the event, or `schedule`, `date`, `manual` or `test`.
- `test` (boolean): `true` for a test run.
- `reason` (string | null): Why it ended before the end of its path, or `null`. One of: `exit_step`, `goal`, `unsubscribed`, `contact_deleted`, `automation_deleted`, `automation_stopped`, `missing_variable`, `send_refused`, `step_failed`, `canceled`.
- `detail` (string): More about how it ended. Empty while it is going on.
- `wakeAt` (string | null): When a waiting run goes on, or `null`.
- `startedAt` (string): When the run started.
- `finishedAt` (string | null): When it ended, or `null`.
- `data` (Record<string, unknown>): The data of what started it.
- `steps` (object[]): What each step did, oldest first.
- `steps[].id` (string): The id of the step.
- `steps[].kind` (string): What the step does. One of: `send_email`, `delay`, `wait_until`, `wait_for_event`, `condition`, `branch`, `split`, `update_contact`, `delete_contact`, `add_to_audience`, `remove_from_audience`, `webhook`, `send_event`, `exit`.
- `steps[].name` (string): The name of the step.
- `steps[].outcome` (string): What happened: `sent`, `done`, `waiting`, `waited`, `yes`, `no`, `skipped` or `failed`. One of: `sent`, `done`, `waiting`, `waited`, `yes`, `no`, `skipped`, `failed`.
- `steps[].detail` (string): More about it, such as why it failed. Often empty.
- `steps[].emailId` (string | null): The id of the email it sent, or `null`.
- `steps[].at` (string): When it happened.

## Example

cURL:

```bash
curl -X POST "$OPENSEND_API_URL/v1/automations/auto_welcome/runs/run_02/cancel" \
  -H "Authorization: Bearer $OPENSEND_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'
```

TypeScript:

```ts
await opensend.runs.cancel('run_02', {
  automationId: 'auto_welcome',
})
```

CLI:

```bash
opensend runs cancel run_02 --automation-id auto_welcome
```

MCP:

```json
{
  "name": "runs_cancel",
  "arguments": {
    "automationId": "auto_welcome",
    "id": "run_02"
  }
}
```

Answer:

```json
{
  "object": "automation_run",
  "id": "run_02",
  "automationId": "auto_welcome",
  "version": 1,
  "email": "alan@example.com",
  "contactId": null,
  "status": "canceled",
  "stepId": null,
  "source": "user.signed_up",
  "test": false,
  "reason": "canceled",
  "detail": "Cancelled by a person.",
  "wakeAt": null,
  "startedAt": "2026-11-26T09:30:00.000Z",
  "finishedAt": "2026-11-27T09:30:00.000Z",
  "data": {
    "first_name": "Alan",
    "plan": "pro"
  },
  "steps": [
    {
      "id": "welcome",
      "kind": "send_email",
      "name": "Welcome to Acme",
      "outcome": "sent",
      "detail": "",
      "emailId": null,
      "at": "2026-11-26T09:30:00.000Z"
    },
    {
      "id": "wait_open",
      "kind": "delay",
      "name": "Delay",
      "outcome": "waiting",
      "detail": "",
      "emailId": null,
      "at": "2026-11-26T09:30:00.000Z"
    }
  ]
}
```
