Stay organized with collections
Save and categorize content based on your preferences.
Sets the IAM access control policy for the specified project, in the
format projects/{ProjectIdOrNumber} e.g. projects/123. CAUTION: 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. 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 to a user, serviceAccount, or a group that
is part of an organization. For example, group@myownpersonaldomain.com
could be added as an owner to a project in the myownpersonaldomain.com
organization, but not the examplepetstore.com organization. + 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
using the 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. + 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. If the project is part of an
organization, you can remove all owners, potentially making the
organization inaccessible. + Calling this method requires enabling the
App Engine Admin API.
Arguments
Parameters
resource
string
REQUIRED: The resource for which the policy is being specified. See the operation documentation for the appropriate value for this field.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Method: googleapis.cloudresourcemanager.v3.projects.setIamPolicy\n\nSets the IAM access control policy for the specified project, in the\nformat `projects/{ProjectIdOrNumber}` e.g. projects/123. CAUTION: This\nmethod will replace the existing policy, and cannot be used to append\nadditional IAM settings. Note: Removing service accounts from policies\nor changing their roles can render services completely inoperable. It is\nimportant to understand how the service account is being used before\nremoving or updating its roles. The following constraints apply when\nusing `setIamPolicy()`: + Project does not support `allUsers` and\n`allAuthenticatedUsers` as `members` in a `Binding` of a `Policy`. + The\nowner role can be granted to a `user`, `serviceAccount`, or a group that\nis part of an organization. For example, group@myownpersonaldomain.com\ncould be added as an owner to a project in the myownpersonaldomain.com\norganization, but not the examplepetstore.com organization. + Service\naccounts can be made owners of a project directly without any\nrestrictions. However, to be added as an owner, a user must be invited\nusing the Cloud Platform console and must accept the invitation. + A\nuser cannot be granted the owner role using `setIamPolicy()`. The user\nmust be granted the owner role using the Cloud Platform Console and must\nexplicitly accept the invitation. + Invitations to grant the owner role\ncannot be sent using `setIamPolicy()`; they must be sent only using the\nCloud Platform Console. + If the project is not part of an organization,\nthere must be at least one owner who has accepted the Terms of Service\n(ToS) agreement in the policy. Calling `setIamPolicy()` to remove the\nlast ToS-accepted owner from the policy will fail. This restriction also\napplies to legacy projects that no longer have owners who have accepted\nthe ToS. Edits to IAM policies will be rejected until the lack of a\nToS-accepting owner is rectified. If the project is part of an\norganization, you can remove all owners, potentially making the\norganization inaccessible. + Calling this method requires enabling the\nApp Engine Admin API.\n\nArguments\n---------\n\nRaised exceptions\n-----------------\n\nResponse\n--------\n\nIf successful, the response contains an instance of [`Policy`](https://cloud.google.com/workflows/docs/reference/googleapis/cloudresourcemanager/v3/Overview#Policy).\n\nSubworkflow snippet\n-------------------\n\nSome fields might be optional or required.\nTo identify required fields, refer to the [API documentation](https://cloud.google.com/resource-manager/reference/rest/v3/projects/setIamPolicy). \n\n### YAML\n\n```yaml\n- setIamPolicy:\n call: googleapis.cloudresourcemanager.v3.projects.setIamPolicy\n args:\n resource: ...\n body:\n policy:\n auditConfigs: ...\n bindings: ...\n etag: ...\n version: ...\n updateMask: ...\n result: setIamPolicyResult\n```\n\n### JSON\n\n```json\n[\n {\n \"setIamPolicy\": {\n \"call\": \"googleapis.cloudresourcemanager.v3.projects.setIamPolicy\",\n \"args\": {\n \"resource\": \"...\",\n \"body\": {\n \"policy\": {\n \"auditConfigs\": \"...\",\n \"bindings\": \"...\",\n \"etag\": \"...\",\n \"version\": \"...\"\n },\n \"updateMask\": \"...\"\n }\n },\n \"result\": \"setIamPolicyResult\"\n }\n }\n]\n```"]]