Skip to main content
Pulumi logo Pulumi logo
  1. Docs
  2. Reference
  3. REST API Docs
  4. Policy Groups

Policy Groups

    Policy Groups are collections of policy packs that can be applied to stacks to enforce governance rules. The Policy Groups API allows you to create, manage, and apply policy groups to stacks.

    List Policy Groups

    ▼
    GET /api/orgs/{orgName}/policygroups

    Returns a list of all Policy Groups for the organization. Policy Groups define which Policy Packs are enforced on which stacks, with configurable enforcement levels (advisory, mandatory, or disabled) per pack. Every organization has a default Policy Group, and additional groups can be created to apply different policy sets to different environments (e.g., stricter enforcement in production).

    Request Parameters

    • orgName string path required
      The organization name

    Responses

    200 OK
    • policyGroups array[AppPolicyGroupSummary] required
      List of policy groups
    • ↳ name string required
      The unique name of the policy group.
    • ↳ isOrgDefault boolean required
      Whether this is one of the organization’s default policy groups. The default stacks group applies to every stack not in another group; the default accounts group applies to every Insights account not in another group.
    • ↳ numStacks integer required
      Number of stacks assigned to this policy group.
    • ↳ numAccounts integer optional
      Number of cloud accounts assigned to this policy group.
    • ↳ entityType enum required
      Deprecated: a legacy label set when the policy group was created. It does not restrict which entities the group holds; mode does.
      Values: stacks, accounts
    • ↳ mode enum required
      The enforcement mode of the policy group.
      Values: audit, preventative
    • ↳ numEnabledPolicyPacks integer required
      Number of policy packs currently enabled in this group.
    Errors: 404 Organization not found

    New Policy Group

    ▼
    POST /api/orgs/{orgName}/policygroups

    Creates a new Policy Group for an organization. Policy Groups define which Policy Packs are enforced on which stacks or cloud accounts, with configurable enforcement levels (advisory, mandatory, or disabled) per pack. This allows different policy strictness for different environments, such as advisory-only in development and mandatory in production.

    Request Parameters

    • orgName string path required
      The organization name

    Request Body

    • name string required
      The name of the new policy group. Up to 100 characters, made up of letters, numbers, hyphens, underscores, periods, or spaces, and may not begin or end with a space.
    • entityType enum optional
      Deprecated: a legacy label, stacks or accounts. When mode is omitted it picks the mode (accounts → audit, stacks → preventative). When this is omitted, it is derived from mode. It does not restrict which entities the group can hold.
      Values: stacks, accounts
    • mode enum optional
      The enforcement mode for the policy group (audit or preventative). The mode decides what the group can hold: an audit group holds stacks and Insights accounts, a preventative group holds stacks only. Required unless the deprecated entityType is sent. Fixed at creation; it cannot be changed later.
      Values: audit, preventative
    • agentPoolId string optional
      Agent pool ID for policy evaluation. Defaults to Pulumi hosted pool if not specified.
    • stackMatchRule PermissionBooleanExpression optional
      Preview: a stack match rule to create the group with, a boolean expression over stack tags. Requires the tag-based policy groups feature.
    • accountMatchRule PermissionBooleanExpression optional
      Preview: an account match rule to create the group with, a boolean expression over Insights account tags. Requires the tag-based policy groups feature; not allowed on preventative groups.

    Responses

    204 No Content
    Errors: 400 Invalid or missing mode, invalid entity type, invalid Policy Group name, invalid stack or account match rule, or an account match rule on a preventative Policy Group 404 Organization not found 409 Policy Group already exists

    Get Policy Group

    ▼
    GET /api/orgs/{orgName}/policygroups/{policyGroup}

    Returns the details of a specific Policy Group, including the list of Policy Packs applied to it and their enforcement levels (advisory, mandatory, or disabled), as well as the stacks and cloud accounts added to the group. Policy Groups enable targeted policy enforcement by associating sets of policies with specific infrastructure resources.

    Request Parameters

    • orgName string path required
      The organization name
    • policyGroup string path required
      The policy group name

    Responses

    200 OK
    Schema: PolicyGroup
    • name string required
      The name of the policy group.
    • isOrgDefault boolean required
      True if this is either the default stacks or default accounts policy group for the organization.
    • entityType enum required
      Deprecated: a legacy label set when the policy group was created. It does not restrict which entities the group holds; mode does.
      Values: stacks, accounts
    • mode enum required
      The enforcement mode for the policy group (audit or preventative).
      Values: audit, preventative
    • stacks array[AppPulumiStackReference] required
      The stacks added to this policy group individually, with addStack.
    • ↳ name string required
      The name
    • ↳ routingProject string required
      The routing project
    • appliedPolicyPacks array[AppPolicyPackMetadata] required
      List of policy packs that are applied to this policy group.
    • ↳ name string required
      The name
    • ↳ displayName string required
      The display name
    • ↳ version integer required
      The version number
    • ↳ versionTag string required
      The version tag
    • ↳ config map[string]object optional
      The configuration that is to be passed to the Policy Pack. This map ties Policies with their configuration.
    • ↳ environments array[string] optional
      References to ESC environments to use for this policy pack.
    • accounts array[string] required
      The Insights accounts added to this policy group individually, with addInsightsAccount.
    • agentPoolId string optional
      Agent pool ID for audit policy evaluation. Defaults to Pulumi hosted pool if not specified.
    • stackMatchRule PermissionBooleanExpression optional
      Preview: the stack match rule, a boolean expression over stack tags. Stacks whose tags satisfy it are members of the group alongside the stacks added individually. Absent when the group has no rule.
    • ↳ __type string required
    • accountMatchRule PermissionBooleanExpression optional
      Preview: the account match rule, a boolean expression over Insights account tags. Accounts whose tags satisfy it are members of the group alongside the accounts added individually. Absent when the group has no rule.
    • ↳ __type string required
    Errors: 404 Organization or Policy Group not found

    Update Policy Group

    ▼
    PATCH /api/orgs/{orgName}/policygroups/{policyGroup}

    Updates a Policy Group’s configuration. This multi-purpose endpoint supports several operations in a single request via different body fields:

    • newName: rename the policy group
    • addStack / removeStack: add or remove stacks (with name and routingProject fields)
    • addPolicyPack / removePolicyPack: add or remove policy packs (with name, version, versionTag, and optional config)
    • addInsightsAccount / removeInsightsAccount: add or remove Insights accounts
    • stackMatchRule / removeStackMatchRule: replace or remove the stack match rule
    • accountMatchRule / removeAccountMatchRule: replace or remove the account match rule

    Sending a match rule and its remove field in one request is rejected with a 400 error. Setting a match rule on one of the organization’s default Policy Groups is refused, and an account match rule is also refused on preventative Policy Groups. An invalid rule is rejected with a 400 error, and no other operation in the same request is applied.

    Enforcement levels for policy packs are advisory, mandatory, or disabled.

    An organization’s default Policy Groups cannot be renamed: sending newName for the default stack Policy Group or the default accounts Policy Group returns a 400 error, and no other operation in the same request is applied.

    A Policy Group’s enforcement mode (audit or preventative) is fixed when the group is created and cannot be changed here. To use a different mode, create a new Policy Group.

    Request Parameters

    • orgName string path required
      The organization name
    • policyGroup string path required
      The policy group name

    Request Body

    • agentPoolId string optional
      Agent pool ID for audit policy evaluation. Set to empty string to clear, omit to leave unchanged.
    • newName string optional
      The new name to assign to the policy group. Up to 100 characters, made up of letters, numbers, hyphens, underscores, periods, or spaces, and may not begin or end with a space. Rejected with a 400 error for an organization’s default Policy Groups, which cannot be renamed.
    • addStack AppPulumiStackReference optional
      A stack to add to the policy group.
    • stackMatchRule PermissionBooleanExpression optional
      Preview: a stack match rule, a boolean expression over stack tags, that replaces the policy group’s current rule. Omit to leave the rule unchanged. Setting a rule requires the tag-based policy groups feature and is refused on the organization’s default policy groups.
    • removeStack AppPulumiStackReference optional
      A stack to remove from the policy group. Only stacks added with addStack can be removed.
    • removeStackMatchRule boolean optional
      Preview: set to true to remove the policy group’s stack match rule. Cannot be combined with stackMatchRule in the same request. Removing the rule is always allowed.
    • accountMatchRule PermissionBooleanExpression optional
      Preview: an account match rule, a boolean expression over Insights account tags, that replaces the policy group’s current rule. Omit to leave the rule unchanged. Setting a rule requires the tag-based policy groups feature and is refused on the organization’s default policy groups and on preventative groups.
    • addPolicyPack AppPolicyPackMetadata optional
      A policy pack to enable for the policy group.
    • removeAccountMatchRule boolean optional
      Preview: set to true to remove the policy group’s account match rule. Cannot be combined with accountMatchRule in the same request. Removing the rule is always allowed.
    • removePolicyPack AppPolicyPackMetadata optional
      A policy pack to disable for the policy group.
    • addInsightsAccount AppInsightsAccountReference optional
      An Insights account to add to the policy group.
    • removeInsightsAccount AppInsightsAccountReference optional
      An Insights account to remove from the policy group. Only accounts added with addInsightsAccount can be removed.

    Responses

    204 No Content
    Errors: 400 Bad Request, such as an invalid new name or an attempt to rename a default Policy Group 404 Organization, Policy Group, Stack, Account, or Policy Pack not found 409 Conflict: the stack or account is a member only through the Policy Group's stack or account match rule and cannot be removed individually

    Delete Policy Group

    ▼
    DELETE /api/orgs/{orgName}/policygroups/{policyGroup}

    Deletes a Policy Group from an organization. A Policy Group defines which Policy Packs are enforced on which stacks, with configurable enforcement levels (advisory, mandatory, or disabled) per pack. The organization’s default Policy Group cannot be deleted. Deleting a Policy Group removes all policy enforcement associations for the stacks that were assigned to it.

    Request Parameters

    • orgName string path required
      The organization name
    • policyGroup string path required
      The policy group name

    Responses

    204 No Content
    Errors: 400 Cannot delete the default Policy Group 404 Organization or Policy Group not found

    List Policy Group Accounts

    ▼
    Preview. This endpoint is in preview and may change without notice.
    GET /api/orgs/{orgName}/policygroups/{policyGroup}/accounts

    Lists one page of a policy group’s member Insights accounts that the caller can access, with how each became a member. Keep requesting until continuationToken is null.

    Request Parameters

    • orgName string path required
      The organization name
    • policyGroup string path required
      The policy group name
    • continuationToken string query optional
      Continuation token from a previous page
    • count integer query optional
      Accounts per page, 1-500. Defaults to 500.
    • source string query optional
      Only members with this source. Omit for all members.

    Responses

    200 OK
    • accounts array[PolicyGroupAccount] required
      The member accounts on this page that the caller can access, ordered by an internal account identifier.
    • ↳ id string required
      The account ID.
    • ↳ name string required
      The account name.
    • ↳ source enum required
      How the account became a member of the policy group.
      Values: explicit, rule
    • ↳ tags map[string]string required
      The account’s tags. Team-access tags are left out.
    • continuationToken string optional
      Continuation token for the next page. Omitted when there are no more results.
    Errors: 400 Invalid source, count, or continuation token 404 Organization or Policy Group not found

    Batch Update Policy Group

    ▼
    PATCH /api/orgs/{orgName}/policygroups/{policyGroup}/batch

    BatchUpdatePolicyGroup applies multiple update operations to the Policy Group efficiently. Each operation in the list uses the same fields as UpdatePolicyGroupRequest. Operations are grouped by type (adds, removes) and processed in batches for efficiency. For agentPoolId and for each match rule, the last request in the list that sets or removes it applies.

    Request Parameters

    • orgName string path required
      The organization name
    • policyGroup string path required
      The policy group name

    Request Body

    Responses

    204 No Content
    Errors: 400 Bad Request 404 Organization, Policy Group, Stack, Account, or Policy Pack not found 409 Conflict: the stack or account is a member only through the Policy Group's stack or account match rule and cannot be removed individually

    List Policy Group Stacks

    ▼
    Preview. This endpoint is in preview and may change without notice.
    GET /api/orgs/{orgName}/policygroups/{policyGroup}/stacks

    Lists one page of a policy group’s member stacks that the caller can access, with how each became a member. Keep requesting until continuationToken is null.

    Request Parameters

    • orgName string path required
      The organization name
    • policyGroup string path required
      The policy group name
    • continuationToken string query optional
      Continuation token from a previous page
    • count integer query optional
      Stacks per page, 1-500. Defaults to 500.
    • source string query optional
      Only members with this source. Omit for all members.

    Responses

    200 OK
    • stacks array[PolicyGroupStack] required
      The member stacks on this page that the caller can access, ordered by an internal stack identifier.
    • ↳ name string required
      The stack name.
    • ↳ routingProject string required
      The project the stack belongs to.
    • ↳ source enum required
      How the stack became a member of the policy group.
      Values: explicit, rule
    • ↳ tags map[string]string required
      The stack’s tags, including built-in ones such as vcs:repo. Team-access tags are left out.
    • continuationToken string optional
      Continuation token for the next page. Omitted when there are no more results.
    Errors: 400 Invalid source, count, or continuation token 404 Organization or Policy Group not found

    Preview Account Match Rule

    ▼
    Preview. This endpoint is in preview and may change without notice.
    POST /api/orgs/{orgName}/policygroups/accountmatchrule/preview

    Evaluates an account match rule without saving it, returning one page of the Insights accounts it matches with their tags, and on the first page how many accounts it matches out of the total. Only accounts the caller can access are listed or counted. Keep requesting until continuationToken is null.

    Request Parameters

    • orgName string path required
      The organization name
    • continuationToken string query optional
      Continuation token from a previous page
    • count integer query optional
      Accounts per page, 1-500. Defaults to 500.

    Request Body

    • accountMatchRule PermissionBooleanExpression required
      The match rule, a boolean expression over account tags.
    • search string optional
      Only list accounts whose name contains this text, ignoring case. The counts are not narrowed.

    Responses

    200 OK
    • accounts array[AccountMatchRulePreviewAccount] required
      The matching accounts on this page that the caller can access, ordered by name, so a parent account comes before its child accounts.
    • ↳ id string required
      The account ID.
    • ↳ name string required
      The account name.
    • ↳ tags map[string]string required
      The account’s tags. Team-access tags are left out.
    • matchedCount integer optional
      The number of accounts the caller can access that the rule matches. Set on the first page only.
    • totalCount integer optional
      The number of live accounts in the organization the caller can access. Set on the first page only.
    • continuationToken string optional
      Continuation token for the next page. Omitted when there are no more results.
    Errors: 400 Invalid rule, count, or continuation token, or tag-based policy groups are not enabled 404 Organization not found

    Get Policy Group Metadata

    ▼
    GET /api/orgs/{orgName}/policygroups/metadata

    Returns high-level policy protection metrics for an organization, including the number of stacks protected by policy enforcement, the total number of Policy Groups, and overall policy coverage statistics.

    Request Parameters

    • orgName string path required
      The organization name

    Responses

    200 OK
    • ProtectedStacks integer required
      Number of unique stacks in any policy group (preventative or audit). Deprecated: Use PreventativeStacks and AuditStacks for breakdown by mode
    • ProtectedStackResources integer required
      Number of resources in unique stacks in any policy group (preventative or audit). Deprecated: Use PreventativeStackResources and AuditStackResources for breakdown by mode
    • PreventativeStacks integer required
      Number of stacks in preventative policy groups
    • PreventativeStackResources integer required
      Number of resources in stacks in preventative policy groups
    • AuditStacks integer required
      Number of stacks in audit policy groups
    • AuditStackResources integer required
      Number of resources in stacks in audit policy groups
    • TotalStacks integer required
      Total number of stacks in the organization
    • TotalStackResources integer required
      Total number of resources in all stacks
    • ProtectedAccounts integer required
      Number of accounts in policy groups
    • ProtectedAccountResources integer required
      Number of resources in accounts in policy groups
    • TotalAccounts integer required
      Total number of accounts in the organization
    • TotalAccountResources integer required
      Total number of resources in all accounts
    Errors: 404 Organization not found

    Preview Stack Match Rule

    ▼
    Preview. This endpoint is in preview and may change without notice.
    POST /api/orgs/{orgName}/policygroups/stackmatchrule/preview

    Evaluates a stack match rule without saving it, returning one page of the stacks it matches with their tags, and on the first page how many stacks it matches out of the total. Only stacks the caller can access are listed or counted. Keep requesting until continuationToken is null.

    Request Parameters

    • orgName string path required
      The organization name
    • continuationToken string query optional
      Continuation token from a previous page
    • count integer query optional
      Stacks per page, 1-500. Defaults to 500.

    Request Body

    • stackMatchRule PermissionBooleanExpression required
      The match rule, a boolean expression over stack tags.
    • search string optional
      Only list stacks whose project or stack name contains this text, ignoring case. Text of the form project/stack narrows both parts. The counts are not narrowed.

    Responses

    200 OK
    • stacks array[StackMatchRulePreviewStack] required
      The matching stacks on this page that the caller can access, ordered by an internal stack identifier.
    • ↳ name string required
      The stack name.
    • ↳ routingProject string required
      The project the stack belongs to.
    • ↳ tags map[string]string required
      The stack’s tags, including built-in ones such as vcs:repo. Team-access tags are left out.
    • matchedCount integer optional
      The number of stacks the caller can access that the rule matches. Set on the first page only.
    • totalCount integer optional
      The number of stacks in the organization the caller can access. Set on the first page only.
    • continuationToken string optional
      Continuation token for the next page. Omitted when there are no more results.
    Errors: 400 Invalid rule, count, or continuation token, or tag-based policy groups are not enabled 404 Organization not found

      The infrastructure platform for humans and agents.