# Cancel a session

`POST /o/{org}/sessions/{session}/cancel`

Ends the run and releases its sandbox. No body is read.

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `org` | path | string | yes | The org's slug or id. A caller with no role in the org gets `404`. |
| `session` | path | string | yes | The session's full id (`execution_id`). |

## Example request

```bash
curl -X POST "https://api.prix.dev/o/$RUSH_ORG/sessions/$SESSION_ID/cancel" \
  -H "Authorization: Bearer $RUSH_API_KEY"
```

```typescript
const org = process.env.RUSH_ORG;
const sessionId = process.env.SESSION_ID;

const res = await fetch(`https://api.prix.dev/o/${org}/sessions/${sessionId}/cancel`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.RUSH_API_KEY}`,
  },
});

console.log(res.status, await res.json());
```

```python
import os

import requests

org = os.environ["RUSH_ORG"]
session_id = os.environ["SESSION_ID"]

res = requests.post(
    f"https://api.prix.dev/o/{org}/sessions/{session_id}/cancel",
    headers={"Authorization": f"Bearer {os.environ['RUSH_API_KEY']}"},
)

print(res.status_code, res.json())
```

## Responses

### 202

The session as `GET` reads it, `status` `cancelled`, or `cancelling` while the sandbox is still being released; it reads `cancelled` from then on.

- `execution_id` (string, required): The session id.
- `org_id` (string, required): The org as the request's path named it.
- `project_id` (string, optional): The Project the console ran the session in.
- `status` (string, required, one of `queued`, `allocating`, `running`, `paused`, `input_required`, `needs_review`, `completed`, `failed`, `cancelling`, `cancelled`, `expired`): `paused` is a resumable session parked between turns; `needs_review` finished without the proof it was asked for; `cancelling` appears only in the `202` answer to a cancel whose sandbox is still being released; `GET` reads `cancelled` once it is.
- `harness` (string, optional): `claude`, `codex` or `opencode`.
- `agent_id` (string, optional): The saved agent the session was started from, if any.
- `model` (string, optional)
- `effort` (string, optional)
- `result` (string, optional): The agent's final answer for the last finished turn, in full.
- `error` (object, optional)
  - `code` (string, required)
  - `message` (string, required)
- `repo_owner` (string, optional)
- `repo_name` (string, optional)
- `branch` (string, optional)
- `pr_url` (string, optional)
- `input_tokens` (integer, optional)
- `output_tokens` (integer, optional)
- `cache_read_tokens` (integer, optional)
- `cache_write_tokens` (integer, optional)
- `total_tokens` (integer, optional): Uncached input plus cache writes plus output.
- `reasoning_tokens` (integer, optional)
- `total_cost_usd` (number, optional)
- `tool_calls_count` (integer, optional)
- `turns_count` (integer, optional)
- `artifacts` (array of object, optional): Every file the agent saved to `/workspace/.rush/artifacts/`. `url` downloads it with no credential until `url_expires_at`, an hour after the read; read the session again for a fresh link. `GET …/artifacts/{name}` with the key also downloads it.
  - `name` (string, required)
  - `mime_type` (string, required)
  - `url` (string, required): A signed https link to the file.
  - `url_expires_at` (string, required)
- `attachments` (array of object, optional): The files the session was started or followed up with.
  - `id` (string, required)
  - `name` (string, required)
  - `mime_type` (string, required)
- `created_at` (string, optional)
- `completed_at` (string, optional)

### 401

No bearer, an unknown, revoked or expired one, or an API key on a route keys cannot call.

### 404

No such resource for the caller, including one that exists in an org the caller cannot see.

### 409

The session already finished (`RUN_STATE_CONFLICT`).

### 503

The runtime did not confirm the cancel (`CANCELLATION_UNCONFIRMED`). Read the session, then retry.

## Example response (202)

```json
{
  "execution_id": "3f9c2a71d04b8e65",
  "org_id": "acme",
  "status": "cancelling",
  "harness": "claude",
  "created_at": "2026-10-09T00:56:44.205Z"
}
```
