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

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

Refines an existing playbook definition using Gemini AI based on a natural language prompt. Use this method to add steps, modify conditions, or adjust the logic of a playbook through conversational instructions.

### HTTP request

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

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 update the playbook for. Format: projects/{project}/locations/{location}/instances/{instance} |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "prompt": string, "playbook": { object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/ApiWorkflowDefinitionDataModel`) }, "hashedUserId": string } ``` |

| Fields ||
|---|---|
| `prompt` | `string` Required. The user prompt to generate the playbook. |
| `playbook` | ``object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/ApiWorkflowDefinitionDataModel`)`` Optional. The edited playbook. |
| `hashedUserId` | `string` Optional. A hashed identifier of the user initiating the playbook generation request. |

### Response body

LegacyPlaybookAiUpdateResponse is a response for editing a playbook with Gemini.

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

| JSON representation |
|---|
| ``` { "instance": string, "changeRequests": [ { object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiUpdate#ChangeRequest`) } ], "playbook": { object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/ApiWorkflowDefinitionDataModel`) }, "correlationId": string, "metadata": { object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/PlaybooksAiServiceGenerationResponseMetadata`) } } ``` |

| Fields ||
|---|---|
| `instance` | `string` Required. The instance to generate the playbook for. Format: projects/{project}/locations/{location}/instances/{instance} |
| `changeRequests[]` | ``object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiUpdate#ChangeRequest`)`` Required. The list of change requests. |
| `playbook` | ``object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/ApiWorkflowDefinitionDataModel`)`` Optional. The edited playbook. |
| `correlationId` | `string` Optional. The correlation id of the request. |
| `metadata` | ``object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/PlaybooksAiServiceGenerationResponseMetadata`)`` Optional. Metadata for the response. |

### 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).

## ChangeRequest

Represents a change request.

| JSON representation |
|---|
| ``` { "type": string, "changeId": string, "involvedSteps": { object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiUpdate#InvolvedSteps`) }, "step": { object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/ApiWorkflowStepDataModel`) }, "trigger": { object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/ApiWorkflowTriggerDataModel`) } } ``` |

| Fields ||
|---|---|
| `type` | `string` Required. The type of the change request. |
| `changeId` | `string` Required. The unique identifier of the change request. |
| `involvedSteps` | ``object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/projects.locations.instances.legacyPlaybooks/legacyAiUpdate#InvolvedSteps`)`` Required. The list of involved steps. |
| `step` | ``object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/ApiWorkflowStepDataModel`)`` Optional. The step of the playbook. |
| `trigger` | ``object (`https://docs.cloud.google.com/chronicle/docs/reference/rest/v1alpha/ApiWorkflowTriggerDataModel`)`` Optional. The trigger of the playbook. |

## InvolvedSteps

Represents the involved steps in a change request.

| JSON representation |
|---|
| ``` { "afterStepInstance": string, "conditionBranchIndex": string, "affectedStepInstanceName": string } ``` |

| Fields ||
|---|---|
| `afterStepInstance` | `string` Optional. The step's instance name that we should put our new step after |
| `conditionBranchIndex` | `string` Optional. If step instance that is the parent of this step is a flow step, which condition index to put it on |
| `affectedStepInstanceName` | `string` Optional. The affected step instance name, IE the replaced / changed instance name. This depends on the action that is happenning |