canonical: https://jentic.com/apis/azure.com/azure-policy-states

# Microsoft Azure PolicyStatesClient

Jentic publishes the only available OpenAPI specification for PolicyStatesClient, keeping it validated and agent-ready. The Azure Policy Insights states API exposes 18 query and summary endpoints under Microsoft.PolicyInsights for retrieving the current compliance state of resources against assigned policies. Use it to query compliance state at management group, subscription, resource group, individual resource, policy assignment, policy definition, or policy set definition scope, and to retrieve aggregated compliance summaries that power compliance dashboards and alerting.

## For AI agents

Query current Azure Policy compliance state and summaries at any scope (management group, subscription, resource group, resource, assignment, definition) through 18 OData query endpoints.

## Scope

Does not author policies, manage assignments, or return historical evaluation events - use for querying current compliance state and aggregated compliance summaries only.

## Capabilities

- Query compliance state for every resource in a subscription against every assigned policy
- Summarise compliance state at any scope to count compliant and non-compliant resources
- Filter compliance state by policy assignment, definition, or set definition
- Retrieve compliance state for a single resource for use in admission and gate workflows
- Walk compliance state at management group scope for cross-subscription dashboards
- Aggregate compliance counts by resource type or policy for executive reporting
- Detect non-compliant resources to feed remediation tickets or workflows

## Use cases

### Compliance Dashboard Backend

Power a compliance dashboard by calling the summarize endpoints at the appropriate scope. The summary returns compliant and non-compliant resource counts per policy assignment, per definition, and overall, which is enough to render a traffic-light dashboard without iterating individual resources. For drilldowns the dashboard then queries the per-resource state endpoint with filters matching the cell the user clicked.

Example prompt: Call the policyStates 'latest' summarize endpoint at the production subscription, return the total compliant and non-compliant counts, and break the non-compliant count down by policy assignment

### Remediation Workflow Trigger

Detect non-compliance and trigger remediation. A scheduled query against the latest compliance state, filtered to specific policy assignments, returns the list of resources that need fixing. The agent can pipe these resource IDs into ServiceNow tickets, an automated remediation runbook, or PolicyTrackedResources deployIfNotExists evaluation, closing the loop between detection and fix.

Example prompt: Query latest policyStates filtered to policyAssignmentName='require-encryption' and complianceState='NonCompliant', and create a ticket for each returned resource ID

### Pre-Deployment Compliance Gate

Before promoting an environment, call the per-resource compliance state for every resource in the target resource group. If any resource is non-compliant the promotion is blocked until the policy violation is resolved. The OData filter on policyAssignmentId allows the gate to focus on a defined set of critical policies rather than the full assignment list, keeping the gate fast and predictable.

Example prompt: Query latest policyStates at resource group 'staging-api', filter to a critical policy assignment list, and return the deployment block decision (block if any NonCompliant)

### AI Agent Compliance Monitor

An AI agent supporting a security or governance team can monitor compliance state through Jentic. The agent searches by intent ('list non-compliant azure resources'), Jentic returns the latest policyStates queryResults operation with its OData filter schema, and the agent executes the call with managed Azure credentials. Summary calls for executive reporting follow the same intent-driven flow.

Example prompt: Search Jentic for 'list non-compliant Azure resources', load the policyStates queryResults schema, and execute it for the production subscription with complianceState='NonCompliant'

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | /subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults | Query compliance state at subscription scope |
| POST | /subscriptions/{subscriptionId}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize | Summarise compliance counts at subscription scope |
| POST | /providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults | Query compliance state at management group scope |
| POST | /providers/{managementGroupsNamespace}/managementGroups/{managementGroupName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesSummaryResource}/summarize | Summarise compliance counts at management group scope |
| POST | /subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyAssignments/{policyAssignmentName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults | Query compliance state for a specific policy assignment |
| POST | /subscriptions/{subscriptionId}/providers/{authorizationNamespace}/policyDefinitions/{policyDefinitionName}/providers/Microsoft.PolicyInsights/policyStates/{policyStatesResource}/queryResults | Query compliance state for a specific policy definition |
| GET | /providers/Microsoft.PolicyInsights/operations | List Microsoft.PolicyInsights provider operations |

## Key resources

- **PolicyStates** — Query current compliance state for resources against assigned policies
- **Summary** — Aggregated compliance counts per scope, assignment, or definition
- **Operations** — List Microsoft.PolicyInsights provider operations

## Why Jentic

- **Setup:** Wiring the PolicyStatesClient by hand means getting an Azure AD token from login.microsoftonline.com, sending every request to management.azure.com with the right preview api-version, and deciding between queryResults and summarize across several scope-specific paths yourself. Through Jentic you install once, import PolicyStatesClient from the API Directory, store the Azure AD credential once, and your agent calls it.
- **Permission scoping:** This API puts the scope in the URL path (subscription, management group, policy assignment, or definition) while the query filters travel in the request body, so limit the agent to the operations it needs, such as querying current compliance state or summarizing at a subscription scope. You choose those operations, so a management-group summarize call is not included unless you add it.
- **Credential handling:** Your Azure AD credential is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'list non-compliant Azure resources' or 'summarize Azure compliance', and Jentic returns the matching scope-specific operation with its input schema so the agent does not pick between queryResults and summarize by hand.

## Related APIs

- **Azure Policy Events** — Query historical evaluation events alongside current compliance state.
- **Azure Policy** — Author and assign the policies this API reports compliance against.
- **Azure Policy Tracked Resources** — List resources modified by deployIfNotExists or modify policies.
- **Azure Policy Metadata** — Look up regulatory descriptions for the policies whose state this API reports.

## FAQ

### Why is there no official OpenAPI spec for PolicyStatesClient?

Microsoft Azure does not publish an OpenAPI specification. Jentic generates and maintains this spec so that AI agents and developers can call PolicyStatesClient via structured tooling. It is validated against the live API and kept up to date. Get started with Jentic One, the self-hosted execution layer.

### What authentication does the Azure Policy States API use?

It uses Azure Active Directory OAuth 2.0 against https://management.azure.com/ with the user_impersonation scope. The caller needs Reader on Microsoft.PolicyInsights at the queried scope. Jentic stores service principal credentials encrypted and issues short-lived bearer tokens at execution time.

### Can I get a compliance summary at management group scope through this API?

Yes. POST to /providers/Microsoft.Management/managementGroups/{name}/providers/Microsoft.PolicyInsights/policyStates/latest/summarize. The response returns compliant and non-compliant resource counts aggregated across every subscription beneath the management group.

### What are the rate limits for the Policy States API?

Azure Resource Manager applies subscription-level throttling at roughly 1,200 reads per hour. Compliance state results can be large; use $top and $skiptoken pagination, and prefer summarize endpoints over queryResults when only counts are needed.

### How do I list non-compliant resources through Jentic?

Run pip install jentic and search for 'list non-compliant Azure resources'. Jentic returns the policyStates 'latest' queryResults operation; load its schema and execute it with $filter=complianceState eq 'NonCompliant' at the desired scope.

### What is the difference between latest and a date-pinned policyStates resource?

policyStates/latest returns the most recent evaluation result for each resource and is what dashboards typically query. Date-pinned values like policyStates/default return the state as recorded for a particular evaluation cycle, useful for reproducing a historical snapshot or investigating a specific evaluation.

### Can I limit what my agent is allowed to do with the Azure Policy States API?

Yes. Because you run Jentic One yourself, your own rules decide which of this API's operations the agent may call, so you can allow only querying current compliance state or summarizing counts and leave everything else out. Scope lives in the URL path here (subscription, management group, policy assignment, or policy definition), so you can grant a subscription-scope summarize while withholding a management-group summarize the agent has no reason to run. The Azure AD credential is held by your own instance and injected only for the operations you permit, never exposed to the agent.
