> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qoder.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel a session turn

> Cancel the current running turn for a Forward session.

`POST /api/v1/forward/sessions/{session_id}/cancel`

Requests cancellation of the current turn. If no turn is running, the endpoint returns success without starting a cancellation.

## Headers

| Header            | Required | Description                                   |
| ----------------- | -------- | --------------------------------------------- |
| `Authorization`   | Yes      | `Bearer <PAT>`                                |
| `Idempotency-Key` | No       | Optional idempotency key for unsafe requests. |

## Path parameters

| Parameter    | Type   | Required | Description |
| ------------ | ------ | -------- | ----------- |
| `session_id` | string | Yes      | Session ID. |

## Example request

```bash theme={null}
curl -s -X POST 'https://api.qoder.com/api/v1/forward/sessions/sess_xxx/cancel' \
  -H "Authorization: Bearer $QODER_PAT"
```

## Example response

**HTTP 202 Accepted**

```json theme={null}
{
  "id": "sess_xxx",
  "type": "session",
  "status": "canceling"
}
```

## Response fields

| Field    | Type   | Description                                |
| -------- | ------ | ------------------------------------------ |
| `id`     | string | Session ID.                                |
| `type`   | string | Always `session`.                          |
| `status` | string | `canceling` when cancellation is accepted. |

## Errors

| HTTP | Type                   | Code                      | Trigger                                 |
| ---- | ---------------------- | ------------------------- | --------------------------------------- |
| 401  | `authentication_error` | `authentication_required` | PAT invalid or expired.                 |
| 404  | `not_found_error`      | `session_not_found`       | Session does not exist.                 |
| 409  | `conflict_error`       | `session_archived`        | Session is archived.                    |
| 502  | `api_error`            | `runtime_unavailable`     | Runtime session service is unavailable. |

## Notes

* `202 Accepted` means a cancellation was requested.
* `200 OK` means there was no currently running turn to cancel.
* Confirm completion through Event Stream or by polling Session status.

## Related

<CardGroup cols={2}>
  <Card title="Stream session events" icon="radio" href="/cloud-agents/api/forward/sessions/stream-events" />

  <Card title="Send session events" icon="paper-plane" href="/cloud-agents/api/forward/sessions/send-events" />
</CardGroup>
