Method: projects.setIamPolicy

Sets the IAM access control policy for the specified Project. Overwrites any existing policy.

The following constraints apply when using setIamPolicy():

  • Project does not support allUsers and allAuthenticatedUsers as members in a Binding of a Policy.

  • The owner role can be granted only to user and serviceAccount.

  • Service accounts can be made owners of a project directly without any restrictions. However, to be added as an owner, a user must be invited via Cloud Platform console and must accept the invitation.

  • A user cannot be granted the owner role using setIamPolicy(). The user must be granted the owner role using the Cloud Platform Console and must explicitly accept the invitation.

  • Invitations to grant the owner role cannot be sent using setIamPolicy(); they must be sent only using the Cloud Platform Console.

  • Membership changes that leave the project without any owners that have accepted the Terms of Service (ToS) will be rejected.

  • If the project is not part of an organization, there must be at least one owner who has accepted the Terms of Service (ToS) agreement in the policy. Calling setIamPolicy() to remove the last ToS-accepted owner from the policy will fail. This restriction also applies to legacy projects that no longer have owners who have accepted the ToS. Edits to IAM policies will be rejected until the lack of a ToS-accepting owner is rectified.

  • This method will replace the existing policy, and cannot be used to append additional IAM settings.

Note: Removing service accounts from policies or changing their roles can render services completely inoperable. It is important to understand how the service account is being used before removing or updating its roles.

Authorization requires the Google IAM permission resourcemanager.projects.setIamPolicy on the project

HTTP request


The URL uses Google API HTTP annotation syntax.

Path parameters



REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.

Request body

The request body contains data with the following structure:

JSON representation
  "policy": {
  "updateMask": string,


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 Cloud Platform services (such as Projects) might reject them.


string (FieldMask format)

OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: paths: "bindings, etag" This field is only used by Cloud IAM.

A comma-separated list of fully qualified names of fields. Example: "user.displayName,photo".

Response body

If successful, the response body contains an instance of Policy.

Authorization Scopes

Requires one of the following OAuth scopes:


For more information, see the Auth Guide.

Send feedback about...

Google Cloud Resource Manager
Google Cloud Resource Manager