Docs
Live demo
POST/api/v2/policies/plan-preview
access:manageAPI token

Generate a preview of what a policy would do without creating it. Returns operations and resource diffs.

Pass rules or template_name, not both (400).

Request body application/json · PlanPreviewRequest

Plan preview request

Required2 of 13 fields
subject_idstringrequired
target_idstringrequired
Optional11 fields
database_selectorDatabaseSelectorRequest
3 fields
modestringrequired
allexplicitpattern
databasesarray of string
patternstring
descriptionstring

Policy description for the created policy. Valid only with rules.

include_nested_groupsboolean

For a group subject, include leaf members of known nested groups when the preview is applied. Omitted or false limits a new rule to direct members.

kubernetes_namespacesarray of string

Typed placement of the previewed Kubernetes rule. Required for a shared_by_template_v1 template preview. For an inline-rules preview it must match the namespaces referenced by the rules.

rulesarray of PolicyRuleRequest

Inline rules for a direct-policy preview (accessTemplateSplit stage 2c-2). Exactly one of rules or template_name must be provided. The preview promises a creation. An existing policy for the subject/target pair is a conflict.

2 fields
permissionsarray of stringrequired
min items 1
resourcesarray of stringrequired
min items 1
metadatamap of string → any

Policy metadata for the created policy (e.g. future_objects, apply_default_privileges), mirroring POST /policies. Valid only with rules.

namestring

Policy name for the created policy. Valid only with rules.

target_account_link_idstring

Target account link the created policy binds to, mirroring POST /policies. Valid only with rules.

template_namestring

Template mode. Exactly one of rules or template_name must be provided.

template_varsmap of string → any
template_versioninteger
min 1

Responses

200

OK

PlanPreviewResponse · 10 fields
changesarray of OperationChange
5 fields
actionstring

create, update, delete, no-op

descriptionstring

Human-readable change description

resource_typestring

role, grant, policy, k8s-resource

sqlstring

SQL statement (if applicable)

targetstring

Target resource (role name, database, etc.)

created_atstring
dry_runboolean

Always true for plan preview

expires_atstring
operationsarray of OperationChange
5 fields
actionstring

create, update, delete, no-op

descriptionstring

Human-readable change description

resource_typestring

role, grant, policy, k8s-resource

sqlstring

SQL statement (if applicable)

targetstring

Target resource (role name, database, etc.)

plan_idstring

Legacy fields for /:id/plan endpoint (old flow)

preview_idstring

Fields for plan-preview endpoint (new flow)

resource_diffsarray of ResourceDiff
5 fields
actionstring
addressstring
aftermap of string → any
beforemap of string → any
resource_typestring
2 fields
by_actionmap of string → integer

{"create": 5, "update": 2, "delete": 1}

total_changesinteger
warningsarray of string
422

Unprocessable Entity - a rule cannot be executed on the target as written (for example a privilege on an object level that does not take it). Detail and field_errors name the fix. Also when Future objects stay on while a PostgreSQL row names its objects by name or by a name mask, field_errors then names the switch Also when Principal doesn't manage the target of the rule or template (before v7.3 that answer was 403 authorization.denied).

Common errors: 400 401 403 404 409 413 429 503 504. They mean the same for every operation, see Errors.

↑ ↓ to moveEnter to openEsc to close