# End the session and release the browser

> End the session and release the browser: CustomDomain™ API reference in the cloud browser group. Covers parameters, request body, responses and error codes.

Source: https://docs.customdomain.ai/docs/api-reference/cloud-browser/cancelBrowserSession

## `POST https://api.customdomain.ai/v1/browser-sessions/{sid}:cancel`

Idempotent: a session that is already over answers its own state. During `applying` it stops at the next change boundary, never inside a change. A `navigator.sendBeacon` cannot set headers, so this route (and `:event`) also accepts the token in the body, as `{"token": "..."}` with a content type of `text/plain` or JSON.

### Authentication

`browserSession`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `sid` | path | string | yes | The cloud browser session id, `bs_` and 32 hex characters. |

### Request body (JSON)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `token` | string | no | The session token, when it cannot be sent as a header. |

### Responses

| Status | Description |
| --- | --- |
| `200` | The state the session is in. |
| `401` | Error envelope: {code, title, details}. |
| `404` | Error envelope: {code, title, details}. |

### `200` response body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `state` | string | no |  |

The full specification is served at `GET https://api.customdomain.ai/v1/openapi.json`.
