---
title: "POST /v1/{+parent}/orgPolicyViolationsPreviews"
method: POST
path: "/v1/{+parent}/orgPolicyViolationsPreviews"
tags: ["organizations"]
---

# POST /v1/{+parent}/orgPolicyViolationsPreviews

`POST /v1/{+parent}/orgPolicyViolationsPreviews`

CreateOrgPolicyViolationsPreview creates an OrgPolicyViolationsPreview for the proposed changes in the provided OrgPolicyViolationsPreview.OrgPolicyOverlay. The changes to OrgPolicy are specified by this `OrgPolicyOverlay`. The resources to scan are inferred from these specified changes.

## Path parameters

- `parent` string, required

## Query parameters

- `orgPolicyViolationsPreviewId` string

## Request body

- GoogleCloudPolicysimulatorV1OrgPolicyViolationsPreview — OrgPolicyViolationsPreview is a resource providing a preview of the violations that will exist if an OrgPolicy change is made. The list of violations are modeled as child resources and retrieved via a ListOrgPolicyViolations API call. There are potentially more OrgPolicyViolations than could fit in an embedded field. Thus, the use of a child resource instead of a field.
  - `violationsCount` integer — Output only. The number of OrgPolicyViolations in this `OrgPolicyViolationsPreview`. This count may differ from `resource_summary.noncompliant_count` because each OrgPolicyViolation is specific to a resource **and** constraint. If there are multiple constraints being evaluated (i.e. multiple policies in the overlay), a single resource may violate multiple constraints.
  - `resourceCounts` GoogleCloudPolicysimulatorV1OrgPolicyViolationsPreviewResourceCounts — A summary of the state of all resources scanned for compliance with the changed OrgPolicy.
    - `compliant` integer — Output only. Number of scanned resources with zero violations.
    - `errors` integer — Output only. Number of resources that returned an error when scanned.
    - `noncompliant` integer — Output only. Number of scanned resources with at least one violation.
    - `scanned` integer — Output only. Number of resources checked for compliance. Must equal: unenforced + noncompliant + compliant + error
    - `unenforced` integer — Output only. Number of resources where the constraint was not enforced, i.e. the Policy set `enforced: false` for that resource.
  - `customConstraints` string[] — Output only. The names of the constraints against which all `OrgPolicyViolations` were evaluated. If `OrgPolicyOverlay` only contains `PolicyOverlay` then it contains the name of the configured custom constraint, applicable to the specified policies. Otherwise it contains the name of the constraint specified in `CustomConstraintOverlay`. Format: `organizations/{organization_id}/customConstraints/{custom_constraint_id}` Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms`
  - `createTime` string, google-datetime — Output only. Time when this `OrgPolicyViolationsPreview` was created.
  - `overlay` GoogleCloudPolicysimulatorV1OrgPolicyOverlay — The proposed changes to OrgPolicy.
    - `policies` GoogleCloudPolicysimulatorV1OrgPolicyOverlayPolicyOverlay[] — Optional. The OrgPolicy changes to preview violations for. Any existing OrgPolicies with the same name will be overridden in the simulation. That is, violations will be determined as if all policies in the overlay were created or updated.
      - `policy` GoogleCloudOrgpolicyV2Policy — Defines an organization policy that is used to specify constraints for configurations of Google Cloud resources.
        - `dryRunSpec` GoogleCloudOrgpolicyV2PolicySpec — Defines a Google Cloud policy specification that is used to specify constraints for configurations of Google Cloud resources.
          - `inheritFromParent` boolean — Determines the inheritance behavior for this policy. If `inherit_from_parent` is true, policy rules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this policy becomes the new root for evaluation. This field can be set only for policies that configure list constraints.
          - `etag` string — An opaque tag indicating the current version of the policySpec, used for concurrency control. This field is ignored if used in a `CreatePolicy` request. When the policy is returned from either a `GetPolicy` or a `ListPolicies` request, this entity tag (ETag) indicates the version of the current policySpec to use when executing a read-modify-write loop. When the policy is returned from a `GetEffectivePolicy` request, the ETag will be unset.
          - `rules` GoogleCloudOrgpolicyV2PolicySpecPolicyRule[] — In policies for boolean constraints, the following requirements apply: - There must be exactly one policy rule where a condition is unset. - Boolean policy rules with conditions must set `enforced` to the opposite of the policy rule without a condition. - During policy evaluation, policy rules with conditions that are true for a target resource take precedence.
            - `allowAll` boolean — Setting this to true means that all values are allowed. This field can be set only in policies for list constraints.
            - `denyAll` boolean — Setting this to true means that all values are denied. This field can be set only in policies for list constraints.
            - `values` GoogleCloudOrgpolicyV2PolicySpecPolicyRuleStringValues — A message that holds specific allowed and denied values. This message can define specific values and subtrees of the Resource Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that are allowed or denied. This is achieved by using the `under:` and optional `is:` prefixes. The `under:` prefix is used to denote resource subtree values. The `is:` prefix is used to denote specific values, and is required only if the value contains a ":". Values prefixed with "is:" are treated the same as values with no prefix. Ancestry subtrees must be in one of the following formats: - `projects/` (for example, `projects/tokyo-rain-123`) - `folders/` (for example, `folders/1234`) - `organizations/` (for example, `organizations/1234`) The `supports_under` field of the associated `Constraint` defines whether ancestry prefixes can be used.
              - …
            - `condition` GoogleTypeExpr — Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
              - …
            - `parameters` object — Optional. Required for managed constraints if parameters are defined. Passes parameter values when policy enforcement is enabled. Ensure that parameter value types match those defined in the constraint definition. For example: ``` { "allowedLocations" : ["us-east1", "us-west1"], "allowAll" : true } ```
            - `enforce` boolean — If `true`, then the policy is enforced. If `false`, then any configuration is acceptable. This field can be set in policies for boolean constraints, custom constraints and managed constraints.
          - `reset` boolean — Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` must be set to false.
          - `updateTime` string, google-datetime — Output only. The time stamp this was previously updated. This represents the last time a call to `CreatePolicy` or `UpdatePolicy` was made for that policy.
        - `spec` GoogleCloudOrgpolicyV2PolicySpec — Defines a Google Cloud policy specification that is used to specify constraints for configurations of Google Cloud resources.
          - `inheritFromParent` boolean — Determines the inheritance behavior for this policy. If `inherit_from_parent` is true, policy rules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this policy becomes the new root for evaluation. This field can be set only for policies that configure list constraints.
          - `etag` string — An opaque tag indicating the current version of the policySpec, used for concurrency control. This field is ignored if used in a `CreatePolicy` request. When the policy is returned from either a `GetPolicy` or a `ListPolicies` request, this entity tag (ETag) indicates the version of the current policySpec to use when executing a read-modify-write loop. When the policy is returned from a `GetEffectivePolicy` request, the ETag will be unset.
          - `rules` GoogleCloudOrgpolicyV2PolicySpecPolicyRule[] — In policies for boolean constraints, the following requirements apply: - There must be exactly one policy rule where a condition is unset. - Boolean policy rules with conditions must set `enforced` to the opposite of the policy rule without a condition. - During policy evaluation, policy rules with conditions that are true for a target resource take precedence.
            - `allowAll` boolean — Setting this to true means that all values are allowed. This field can be set only in policies for list constraints.
            - `denyAll` boolean — Setting this to true means that all values are denied. This field can be set only in policies for list constraints.
            - `values` GoogleCloudOrgpolicyV2PolicySpecPolicyRuleStringValues — A message that holds specific allowed and denied values. This message can define specific values and subtrees of the Resource Manager resource hierarchy (`Organizations`, `Folders`, `Projects`) that are allowed or denied. This is achieved by using the `under:` and optional `is:` prefixes. The `under:` prefix is used to denote resource subtree values. The `is:` prefix is used to denote specific values, and is required only if the value contains a ":". Values prefixed with "is:" are treated the same as values with no prefix. Ancestry subtrees must be in one of the following formats: - `projects/` (for example, `projects/tokyo-rain-123`) - `folders/` (for example, `folders/1234`) - `organizations/` (for example, `organizations/1234`) The `supports_under` field of the associated `Constraint` defines whether ancestry prefixes can be used.
              - …
            - `condition` GoogleTypeExpr — Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
              - …
            - `parameters` object — Optional. Required for managed constraints if parameters are defined. Passes parameter values when policy enforcement is enabled. Ensure that parameter value types match those defined in the constraint definition. For example: ``` { "allowedLocations" : ["us-east1", "us-west1"], "allowAll" : true } ```
            - `enforce` boolean — If `true`, then the policy is enforced. If `false`, then any configuration is acceptable. This field can be set in policies for boolean constraints, custom constraints and managed constraints.
          - `reset` boolean — Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` must be set to false.
          - `updateTime` string, google-datetime — Output only. The time stamp this was previously updated. This represents the last time a call to `CreatePolicy` or `UpdatePolicy` was made for that policy.
        - `etag` string — Optional. An opaque tag indicating the current state of the policy, used for concurrency control. This entity tag (ETag) is computed by the server based on the value of other fields, and may be sent on update and delete requests to ensure the client has an up-to-date value before proceeding.
        - `name` string — Immutable. The resource name of the policy. Must be one of the following forms, where `constraint_name` is the name of the constraint that this policy configures: * `projects/{project_number}/policies/{constraint_name}` * `folders/{folder_id}/policies/{constraint_name}` * `organizations/{organization_id}/policies/{constraint_name}` For example, `projects/123/policies/compute.disableSerialPortAccess`. Note: `projects/{project_id}/policies/{constraint_name}` is also an acceptable name for API requests, but responses will return the name using the equivalent project number.
        - `alternate` GoogleCloudOrgpolicyV2AlternatePolicySpec — Similar to PolicySpec but with an extra 'launch' field for launch reference. The PolicySpec here is specific for dry-run.
          - `launch` string — Reference to the launch that will be used while audit logging and to control the launch. Set only in the alternate policy.
          - `spec` GoogleCloudOrgpolicyV2PolicySpec — Defines a Google Cloud policy specification that is used to specify constraints for configurations of Google Cloud resources.
            - `inheritFromParent` boolean — Determines the inheritance behavior for this policy. If `inherit_from_parent` is true, policy rules set higher up in the hierarchy (up to the closest root) are inherited and present in the effective policy. If it is false, then no rules are inherited, and this policy becomes the new root for evaluation. This field can be set only for policies that configure list constraints.
            - `etag` string — An opaque tag indicating the current version of the policySpec, used for concurrency control. This field is ignored if used in a `CreatePolicy` request. When the policy is returned from either a `GetPolicy` or a `ListPolicies` request, this entity tag (ETag) indicates the version of the current policySpec to use when executing a read-modify-write loop. When the policy is returned from a `GetEffectivePolicy` request, the ETag will be unset.
            - `rules` GoogleCloudOrgpolicyV2PolicySpecPolicyRule[] — In policies for boolean constraints, the following requirements apply: - There must be exactly one policy rule where a condition is unset. - Boolean policy rules with conditions must set `enforced` to the opposite of the policy rule without a condition. - During policy evaluation, policy rules with conditions that are true for a target resource take precedence.
              - …
            - `reset` boolean — Ignores policies set above this resource and restores the `constraint_default` enforcement behavior of the specific constraint at this resource. This field can be set in policies for either list or boolean constraints. If set, `rules` must be empty and `inherit_from_parent` must be set to false.
            - `updateTime` string, google-datetime — Output only. The time stamp this was previously updated. This represents the last time a call to `CreatePolicy` or `UpdatePolicy` was made for that policy.
      - `policyParent` string — Optional. The parent of the policy we are attaching to. Example: "projects/123456"
    - `customConstraints` GoogleCloudPolicysimulatorV1OrgPolicyOverlayCustomConstraintOverlay[] — Optional. The OrgPolicy CustomConstraint changes to preview violations for. Any existing CustomConstraints with the same name will be overridden in the simulation. That is, violations will be determined as if all custom constraints in the overlay were instantiated. Only a single custom_constraint is supported in the overlay at a time. For evaluating multiple constraints, multiple `GenerateOrgPolicyViolationsPreview` requests are made, where each request evaluates a single constraint.
      - `customConstraintParent` string — Optional. Resource the constraint is attached to. Example: "organization/987654"
      - `customConstraint` GoogleCloudOrgpolicyV2CustomConstraint — A custom constraint defined by customers which can *only* be applied to the given resource types and organization. By creating a custom constraint, customers can apply policies of this custom constraint. *Creating a custom constraint itself does NOT apply any policy enforcement*.
        - `actionType` 'ACTION_TYPE_UNSPECIFIED' | 'ALLOW' | 'DENY' — Allow or deny type.
        - `displayName` string — One line display name for the UI. The max length of the display_name is 200 characters.
        - `updateTime` string, google-datetime — Output only. The last time this custom constraint was updated. This represents the last time that the `CreateCustomConstraint` or `UpdateCustomConstraint` methods were called.
        - `resourceTypes` string[] — Immutable. The resource instance type on which this policy applies. Format will be of the form : `/` Example: * `compute.googleapis.com/Instance`.
        - `description` string — Detailed information about this custom policy constraint. The max length of the description is 2000 characters.
        - `name` string — Immutable. Name of the constraint. This is unique within the organization. The name must be of the form: * `organizations/{organization_id}/customConstraints/{custom_constraint_id}` Example: `organizations/123/customConstraints/custom.createOnlyE2TypeVms` The max length is 71 characters and the minimum length is 1. Note that the prefix `organizations/{organization_id}/customConstraints/custom.` is not counted.
        - `condition` string — A Common Expression Language (CEL) condition which is used in the evaluation of the constraint. For example: `resource.instanceName.matches("(production|test)_(.+_)?[\d]+")` or, `resource.management.auto_upgrade == true` The max length of the condition is 1000 characters.
        - `methodTypes` string[] — All the operations being applied for this constraint.
  - `name` string — Output only. The resource name of the `OrgPolicyViolationsPreview`. It has the following format: `organizations/{organization}/locations/{location}/orgPolicyViolationsPreviews/{orgPolicyViolationsPreview}` Example: `organizations/my-example-org/locations/global/orgPolicyViolationsPreviews/506a5f7f`
  - `state` 'PREVIEW_STATE_UNSPECIFIED' | 'PREVIEW_PENDING' | 'PREVIEW_RUNNING' | 'PREVIEW_SUCCEEDED' | 'PREVIEW_FAILED' — Output only. The state of the `OrgPolicyViolationsPreview`.

## Response `200`

Successful response

---

[API](https://skmtc.net/google/apis/policysimulator.md) · [All operations](https://skmtc.net/google/apis/policysimulator/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/google/policysimulator/revisions/785150f95241/schema)
