- [HTTP request](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores/setIamPolicy#body.HTTP_TEMPLATE)
- [Path parameters](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores/setIamPolicy#body.PATH_PARAMETERS)
- [Request body](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores/setIamPolicy#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores/setIamPolicy#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores/setIamPolicy#body.response_body)
- [Authorization scopes](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores/setIamPolicy#body.aspect)
- [IAM Permissions](https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores/setIamPolicy#body.aspect_1)

Sets the IAM access control policy for a `https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/v1/projects.locations.collections.dataStores#DataStore`. A `NOT_FOUND` error is returned if the resource does not exist.

**Important:** When setting a policy directly on a DataStore resource, the only recommended roles in the bindings are: `roles/discoveryengine.admin` `roles/discoveryengine.agentspaceAdmin` `roles/discoveryengine.viewer` `roles/discoveryengine.agentspaceViewer` `roles/discoveryengine.user` `roles/discoveryengine.agentspaceUser` Attempting to grant any other role will result in a warning in logging.

### HTTP request

Choose an endpoint:
global us   
`POST https://discoveryengine.googleapis.com/v1/{resource=projects/*/locations/*/collections/*/dataStores/*}:setIamPolicy`

<br />

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

### Path parameters

| Parameters ||
|---|---|
| `resource` | `string` REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resourceNames) for the appropriate value for this field. |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "policy": { object (`https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/Shared.Types/Policy`) } } ``` |

| Fields ||
|---|---|
| `policy` | ``object (`https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/Shared.Types/Policy`)`` REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/generative-ai-app-builder/docs/reference/rest/Shared.Types/Policy`.

### Authorization scopes

Requires one of the following OAuth scopes:

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

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

- `discoveryengine.dataStores.setIamPolicy`

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