- [HTTP request](https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiGenerateByAlert#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiGenerateByAlert#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiGenerateByAlert#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiGenerateByAlert#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiGenerateByAlert#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiGenerateByAlert#body.aspect)
- [IAM Permissions](https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiGenerateByAlert#body.aspect_1)

**Full name**: projects.locations.instances.legacyPlaybooks.legacyAiGenerateByAlert

Generates a tailored playbook definition designed to respond to a specific security alert. Use this method to create automated investigation and remediation logic that is contextually relevant to a detected threat.

### HTTP request

`POST https://{endpoint}/v1alpha/{instance}/legacyPlaybooks:legacyAiGenerateByAlert`

Where `{endpoint}` is one of the [supported service endpoints](https://docs.cloud.google.com/chronicle/docs/reference/rest#rest_endpoints).

### Path parameters

| Parameters ||
|---|---|
| `instance` | `string` Required. The instance to generate the playbook for. Format: projects/{project}/locations/{location}/instances/{instance} |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "caseId": string, "alertId": string, "hashedUserId": string, "forceRefreshData": boolean, "isFirstRequest": boolean } ``` |

| Fields ||
|---|---|
| `caseId` | `string (https://developers.google.com/discovery/v1/type-format format)` Required. The case ID to which the alert belongs. |
| `alertId` | `string` Required. The alert identifier. |
| `hashedUserId` | `string` Optional. A hashed identifier of the user initiating the playbook generation request. |
| `forceRefreshData` | `boolean` Optional. Indicates whether to force refresh of contextual data prior to generation. |
| `isFirstRequest` | `boolean` Optional. Indicates whether this is the first request in the playbook generation flow. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/LegacyPlaybookAiGenerationByAlertResult`.

### Authorization scopes

Requires one of the following OAuth scopes:

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

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 `instance` resource:

- `chronicle.legacyPlaybooks.update`

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