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

# Cancel a session

> Stop a running session.

Cancels a session that is still active. The agent is stopped and the session transitions to `interrupted` status. Cancelling a [`queued`](/computer-use-agents/observe-and-steer#queued-sessions) session dequeues it immediately, without it ever starting, and cancelling a session that already finished is a harmless no-op. Cancellation can't be undone: use [pause](/computer-use-agents/sessions/pause) if you want to resume later.

**Returns** `204 No Content` on success.

***

## Path parameters

<ParamField path="id" type="string" required>
  The session ID to cancel.
</ParamField>

***

## Examples

<CodeGroup>
  ```bash CLI theme={null}
  hai sessions cancel "$SESSION_ID" --yes
  ```

  ```bash cURL theme={null}
  curl -X DELETE https://agp.eu.hcompany.ai/api/v2/sessions/$SESSION_ID \
    -H "Authorization: Bearer $HAI_API_KEY"
  ```

  ```python Python theme={null}
  from hai_agents import Client

  client = Client()

  client.sessions.cancel_session(session_id)
  ```

  ```typescript TypeScript theme={null}
  import { HaiAgentsClient } from "hai-agents";

  const client = new HaiAgentsClient();

  await client.sessions.cancelSession({ id: sessionId });
  ```
</CodeGroup>

***

## When to cancel vs. pause

| Action                    | Effect                           | Can resume? | Frees quota? |
| ------------------------- | -------------------------------- | ----------- | ------------ |
| **Cancel** (`DELETE`)     | Stops the agent, terminal state  | No          | Yes          |
| **Pause** (`POST /pause`) | Halts the agent, preserves state | Yes         | No           |

Use cancel when:

* The task is no longer needed
* You want to free a concurrency slot immediately
* The agent is stuck or producing unhelpful output

Use [pause](/computer-use-agents/sessions/pause) when:

* You want to review progress before continuing
* You need to provide input later but not right now

***

## Errors

| Status | Cause                                        |
| ------ | -------------------------------------------- |
| `404`  | Session not found, or you don't have access. |
