- [HTTP request](https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#body.request_body)
- [Response body](https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#body.response_body)
  - [JSON representation](https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#body.CancelSessionResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#body.aspect)
- [IAM Permissions](https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#body.aspect_1)
- [CancelResult](https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#CancelResult)
- [Try it!](https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#try-it)

Cancels an in-progress automation session.

This RPC returns immediately and cancellation proceeds asynchronously. If the session is already finished, this RPC will have no effect.

### HTTP request

`POST https://devicerun.googleapis.com/v1alpha/{name=projects/*/locations/*/sessions/*}:cancel`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `name` | `string` Required. The name of the session. Format: "projects/{project}/locations/{location}/sessions/{session}" It takes the form `projects/{project}/locations/{location}/sessions/{session}`. |

### Request body

The request body must be empty.

### Response body

Response of the cancel session request.

If successful, the response body contains data with the following structure:

| JSON representation |
|---|
| ``` { "cancelResult": enum (`https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#CancelResult`) } ``` |

| Fields ||
|---|---|
| `cancelResult` | ``enum (`https://docs.cloud.google.com/developer-device-platform/reference/device-run/rest/v1alpha/projects.locations.sessions/cancel#CancelResult`)`` The result of the request. |

### Authorization scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

### IAM Permissions

Requires the following [IAM](https://docs.cloud.google.com/iam/docs) permission on the `name` resource:

- `devicerun.sessions.delete`

For more information, see the [IAM documentation](https://docs.cloud.google.com/iam/docs).

## CancelResult

The result of the request.

| Enums ||
|---|---|
| `CANCEL_RESULT_UNSPECIFIED` | Unspecified cancel result. |
| `SESSION_MARKED_AS_CANCELLED` | The session is marked as cancelled, but has not finished yet. |
| `SESSION_FINISHED` | The session is finished, either by itself or by the cancel request. |