Access policy YAML reference
The YAML syntax for managing P0 access policies in the YAML editor, the Access policies API, or Terraform.
This is the YAML behind access policies — the format the YAML editor takes directly, and the same shape used by the Access policies API and the P0 Terraform provider (Manage P0 policies and settings as code).
If you prefer to view and edit policies using our web UI or for a more in-depth explanation of Policy functionality, see Configuring access policies. This page is the syntax-only companion for the users who manage policies as YAML.

Structure of a policy configuration
A policy configuration is a collection of access policies, expressed as a YAML array. You only have one policy configuration active at any given time, but that one configuration can hold as many individual access policies as you want — you don't need to separate different rule types into different configurations.
Here's an example policy configuration you can copy into your app as a starting point:
Structure of a rule
Each entry in the array is a rule with three parts: a Requestor (Identity: who is asking), a Resource (what they want), and an Approval array (Action: how the request is routed). The sections below give the YAML for each part.
Requestor
The first part of a rule matches who makes the request. There are four requestor types. The comments provide the P0 Web UI equivalent term.
"Any"
Matches all requestors. Useful for global rules like fall-back restrictions on sensitive resources.
"Group"
Matches any requestor who is a member of a group in your IdP. Supports Google Workspace, Microsoft Entra ID, and Okta.
All three of type, groups, and effect are required, and no other keys are accepted. The group's own fields sit under groups, not directly on the rule.
groups: A list of one or more groups. Each entry needs all three of
id,label, anddirectory.effect:
keepmatches requestors who are a member of at least one of the listed groups.removematches requestors who are a member of none of them.id: For Google Workspace, the group email address (for example,
engineering@yourco.com). For Entra, the Entra ID group's UUID. For Okta, the group ID found in the URL of the group's page in the admin console — see Okta docs.label: Any friendly human-readable name; P0 suggests using the same name shown in your directory.
directory:
workspacefor Google Workspace,oktafor Okta,entra-idfor Entra ID. Useazure-adonly if you are on P0's legacy Entra ID integration, which the app labels "Entra ID (Legacy)".
"User"
Matches only a specific user, identified by their email address.
"Agentic"
Matches requests made by AI agents through the P0 AI Gateway, part of P0 Runtime Access for AI, based on the combination of the agent that is acting and whoever it is acting for. See Agentic access policies for the actor and subject rule types and examples.
Resource
The second part of a rule is the resource it applies to.
"Any"
Matches all resources. Useful when you want to route access for a particular user regardless of what resource or service they are requesting.
"Integration"
Matches a specific type of access request — for example, routing all AWS requests to your DevOps team, or restricting GCP to a select group.
service:
gcloudfor Google Cloud,awsfor AWS,azurefor Microsoft Azure,snowflakefor Snowflake,sshfor SSH.accessType (optional): The access type within the service the rule applies to, or
anyto match requests of any access type. Defaults toanyif omitted.
Filters
Filters apply the rule only to the service components that match the filtering condition.
Each filter's name refers to the type of the requested object. For instance, when service is aws, the filter named policy only allows requesting policies whose ARNs match the pattern. Filters are independent when the access type is omitted or set to any: a filter you don't specify leaves that object type unaffected.
Each filter has three potential properties:
effect — how the filter is applied.
keep — retains objects that match the pattern as requestable.
remove — retains only objects that do not match the pattern.
removeAll — disables the object type entirely.
To allow all objects of a type, omit the filter altogether.
key — which property of the object to match; only applies when
effectiskeeporremove.pattern — a regex pattern matched against the specified property; only applies when
effectiskeeporremove.
A filter's behavior can depend on the requested access type. For example, the Google Cloud role filter limits requestable roles on a role request, but limits the roles requestable on a resource on a resource request. Set the rule's accessType to make which one you mean explicit.
The following table summarizes valid filter name / key combinations. For details, see AWS filtering, Microsoft Azure filtering, Google Cloud filtering, and SSH filtering.
aws
tag
<tag key>
Only filters policies and permission sets. AWS managed policies can't be tagged.
group
name
Filters IAM group names
permission-set
arn | name
Filters Identity Center permission sets
policy
arn
Filters policies with matching ARNs
resource
arn | name | service
Filters resource requests based on the resource ARN, the resource name, or the service the resource belongs to.
azure
subscription
id
Filters requests at a subscription level
resource
id | name
Filters requests based on what resource is requested
role
id | name
Filters requests based on the role requested
azure-ad|okta
group
id | label
Filters directory groups
gcloud
permission
id
Filters IAM permissions
role
id
Filters IAM roles based on full ID (for example, the ID for "Owner" is roles/owner)
resource
name | type | full-resource-name
Filters resource requests based on the resource name, resource type, or the full resource name.
snowflake
role
name
Filters roles
k8s
resource
kind | name | namespace
Filters resources
role
name
Filters roles and cluster roles
cluster
name
Filters clusters based on the cluster name specified when installed in P0
ssh
provider
id
Filters by cloud provider (aws, gcloud, azure, or self-hosted)
destination
arn | name | full-resource-name
Filters by instance identifier
group
name
Filters by SSH group name
parent
id
Filters by parent resource ID (AWS account ID, GCP project ID, or Azure subscription ID)
region
id
Filters by AWS region, GCP zone, or Azure region
sudo
(boolean)
Filters by whether sudo privileges are requested
Filters are not available for AWS or GCP resource-level grants, nor for Snowflake SQL grants.
The following example covers each possible access type in the AWS service: it excludes all permission sets and policies containing "FullAccess", only allows AWS policies and permission sets tagged P0Grantable: true, and denies requesting any AWS groups.
Approval
The final part of a rule is the approval (In the UI it is referred to as an action). Unlike the requestor and resource parts, approval is an array of actions, referring to the people, groups, or services that can approve (or deny) a request. When several approvers match, approval from any one of them is enough.
"p0"
Routes approvals to the people designated as "Security Reviewers" on the Settings page of your app. The options key is optional — see options.
"Group"
Routes approval to members of a group in your IdP. The shape matches a group requestor rule (Requestor): type, groups, and effect are all required, and the group's own fields sit under groups. Note that options stays on the rule, beside groups.
effect:
keeproutes approval to members of the listed groups.removeroutes it to everyone who is a member of none of them.groups, id, label, directory: as in a group requestor rule (Requestor).
labelis printed in approval notifications.options: See options.
"Manager approval"
Routes approval to the person named in the requestor's IdP profile — their manager.
directory: selects the IdP to read the requestor's profile from.
profileProperty (optional): overrides which profile attribute holds the approver's email. Defaults to the directory's manager attribute.
options: See options.
"Auto"
Automatically approves matching requests when the requestor is on-call.
integration:
pagerduty,incidentio, orgrafana-irm. For PagerDuty, P0 checks the escalation policies configured on the integration page. For Incident.io, P0 checks the schedules selected on the integration settings page (Selecting schedules). For Grafana IRM, P0 checks the teams selected on the integration page (Selecting teams).options: Optional; only
requireReasonapplies. See options.
"Escalation"
Routes approval to users currently on-call for the specified services, schedules, or teams. Combined with other approval rules, it lets on-call users approve requests that have been escalated.
integration:
pagerduty,incidentio, orgrafana-irm. For PagerDuty, on-call status comes from the escalation policies of the configured services, and an incident is created against them when the request is escalated. For Incident.io, on-call status comes from the listed schedule IDs. For Grafana IRM, on-call status comes from the first step of each listed team's direct-paging escalation chain, and P0 pages those teams when the request is escalated.services: List of PagerDuty service IDs, Incident.io schedule IDs, or Grafana IRM team IDs.
options: See options.
"Always allowed"
Access is always granted automatically.
options: Optional; only
requireReasonapplies. See options.
"Deny"
Denies all matching requests. This supersedes other matching rules: if at least one deny rule matches, the request is denied.
options
The optional options object tunes an approval action. Not every type accepts every field — the YAML for each type above shows which apply.
allowOneParty:
truelets the requestor approve their own requests for this flow. Defaults tofalse.requireReason:
truerequires the requestor to specify a reason when submitting. Defaults tofalse.breakGlassApprover:
truedesignates the approver as a break-glass approver for SSH "all" access requests. Defaults tofalse. See Break glass access.
maxDuration
Give an approval action a maxDuration and it matches only requests whose duration is at or below that limit. A longer request falls through to another matching action that allows it, or is shortened to the longest any matching action permits.
time is a whole number, and unit is one of m (minutes), h (hours), d (days), or w (weeks). The action maximum can't exceed your organization's access duration limits, set in your just-in-time settings (Just-in-time settings API).
For example, this policy auto-approves short requests and sends longer ones to a human:
A request of 8 hours or less matches the Always allowed action and is approved automatically. A longer request doesn't fit that action's maximum, so it falls through to the p0 action, which has no maxDuration and routes to a Security Reviewer.
Worked scenarios
Each scenario below is the YAML equivalent of the matching walkthrough in Configuring access policies. Adapt the group identifiers, account IDs, and service names to your own organization.
Route requests by team
Route your engineering team's requests to the SRE team, and your data team's Snowflake requests to Data Ops.
Restrict access to production resources
Block requests to the production AWS account while allowing development (self-approval) and staging (peer approval, reason required).
Auto-approve on-call engineers
Auto-approve requests from engineers currently on-call, and route everyone else to the SRE team.
Different rules by AWS account
Development account (123456789) allows one-party approvals, staging (234567891) allows peer approvals but no one-party approvals, and production (345678912) requires a manager approver represented by an Okta group. This assumes an AWS Identity Center setup where resource filters allow requesting customer-managed policies in specific accounts, enforced by an ARN match that includes the account ID. Permission sets are implicitly allowed because the permission-set access type filter is not defined.
Approve by manager or service owner
Allow either the requestor's manager or the service owner to approve requests.
Require a reason for a specific resource type
Make a reason mandatory for AWS requests while leaving everything else self-approvable.
Exclude cluster-admin and restrict to the default namespace (Kubernetes)
Exclude the cluster-admin role and only allow requests in the default namespace.
Allow Google Cloud roles but not permissions
Let users request Google Cloud roles while denying direct permission requests.
Deny specific roles while allowing others
Deny requests for the Owner role while allowing all other Google Cloud roles.
Last updated