# Cancel a run

POST /v1/sessions/{session_id}/runs/{run_id}/cancel: Request cancellation of an active run.

POST<code>/v1/sessions/&#123;session_id&#125;/runs/&#123;run_id&#125;/cancel</code>

Request cancellation of an active run. Cancellation is asynchronous: follow the event stream for `run_cancelled` or read the run until its status is terminal.

Generated from the Platform API specification on 2026-09-04.

## Path parameters

| Parameter | Type | Description |
|---|---|---|
| `session_id` | string | The session, as returned by Create a session. |
| `run_id` | string | The run, as returned by Start a run. |

## Headers

| Header | Required | Description |
|---|---|---|
| `Authorization` | yes | `Bearer` plus a short-lived OAuth access token issued for the Tanomis API audience. Backends obtain tokens with an [organization automation client](/guides/run/authenticate-your-backend); the CLI's human login is not an application credential. |
| `X-Organization-ID` | yes | The `organization_id` from the workspace projection you selected in `GET /v1/me/workspaces`. |
| `X-Workspace-Tenant-ID` | yes | The nested `tenant_id` from the same projection. A header cannot widen what the token grants. Some single-workspace or self-hosted environments take `X-Tenant-ID` instead, as supplied by their administrator. |

## Responses

| Status | Meaning |
|---|---|
| `202` | Cancellation was requested. |
| `404` | No such run in this session. |
| `409` | The run is already terminal. |

## Request

```bash
curl -X POST "https://api.tanomis.com/v1/sessions/ses_7d4f9c/runs/run_a12bc3/cancel" \
  -H "Authorization: Bearer $TANOMIS_TOKEN" \
  -H "X-Organization-ID: $TANOMIS_ORG" \
  -H "X-Workspace-Tenant-ID: $TANOMIS_WORKSPACE"
```

```python
import httpx

response = httpx.post(
    f"https://api.tanomis.com/v1/sessions/{session_id}/runs/{run_id}/cancel",
    headers={
        "Authorization": f"Bearer {token}",
        "X-Organization-ID": organization_id,
        "X-Workspace-Tenant-ID": tenant_id,
    },
)
response.raise_for_status()
result = response.json()
```

```typescript
const response = await fetch(`https://api.tanomis.com/v1/sessions/${sessionId}/runs/${runId}/cancel`, {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${token}`,
    "X-Organization-ID": organizationId,
    "X-Workspace-Tenant-ID": tenantId,
  },
});
if (!response.ok) throw new Error(`${response.status} ${await response.text()}`);
const result = await response.json();
```

## Response

```json title="202 Accepted"
{
  "id": "run_a12bc3",
  "session_id": "ses_7d4f9c",
  "status": "running",
  "started_at": "2026-09-02T11:43:02Z"
}
```
