- [HTTP request](https://docs.cloud.google.com/gemini-enterprise-cx/cx-agent-studio/reference/rest/v1/projects.locations.apps.assistantSessions/cancelAssistantTurn#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/gemini-enterprise-cx/cx-agent-studio/reference/rest/v1/projects.locations.apps.assistantSessions/cancelAssistantTurn#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/gemini-enterprise-cx/cx-agent-studio/reference/rest/v1/projects.locations.apps.assistantSessions/cancelAssistantTurn#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/gemini-enterprise-cx/cx-agent-studio/reference/rest/v1/projects.locations.apps.assistantSessions/cancelAssistantTurn#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/gemini-enterprise-cx/cx-agent-studio/reference/rest/v1/projects.locations.apps.assistantSessions/cancelAssistantTurn#body.response_body)
  - [JSON representation](https://docs.cloud.google.com/gemini-enterprise-cx/cx-agent-studio/reference/rest/v1/projects.locations.apps.assistantSessions/cancelAssistantTurn#body.CancelAssistantTurnResponse.SCHEMA_REPRESENTATION)
- [Authorization scopes](https://docs.cloud.google.com/gemini-enterprise-cx/cx-agent-studio/reference/rest/v1/projects.locations.apps.assistantSessions/cancelAssistantTurn#body.aspect)
- [IAM Permissions](https://docs.cloud.google.com/gemini-enterprise-cx/cx-agent-studio/reference/rest/v1/projects.locations.apps.assistantSessions/cancelAssistantTurn#body.aspect_1)

Cancels the assistant session's in-flight turn, if any: the explicit user stop for a turn running detached from any stream. A cancel landing on a task that does not host the turn preempts it through the session turn epoch instead, ending it within one lease renewal.

### HTTP request

`POST https://ces.googleapis.com/v1/{name=projects/*/locations/*/apps/*/assistantSessions/*}:cancelAssistantTurn`

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

### Path parameters

| Parameters ||
|---|---|
| `name` | `string` Required. The assistant session whose in-flight turn to cancel. |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "turnId": string } ``` |

| Fields ||
|---|---|
| `turnId` | `string` Optional. The turn to cancel; empty cancels whichever turn is running. A cancel naming a turn that is no longer the running one is a no-op. |

### Response body

Response for assistantSessions.cancelAssistantTurn.

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

| JSON representation |
|---|
| ``` { "cancelled": boolean } ``` |

| Fields ||
|---|---|
| `cancelled` | `boolean` Whether an in-flight turn was found and asked to stop (directly on this task, or through an epoch preemption for a turn hosted elsewhere). |

### Authorization scopes

Requires one of the following OAuth scopes:

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

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

### IAM Permissions

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

- `ces.assistantSessions.get`

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