Simulate a policy decision
Policy simulation answers “would this exact request be allowed?” against a specific policy version, without affecting live traffic. Use it to validate a change before publishing, or to understand why a real call was denied.
Simulate a decision
Section titled “Simulate a decision”Provide the principal, action, resource, and context — the same four inputs Cedar evaluates — and get back the decision, the matched rule, and the policy version.
- Open Access → Policies, then open the policy version you want to test.
- Set the user/agent, client surface, environment, server/tool, and credential mode, then run the simulation.
- The result shows allow/deny, the matched rule, and the policy version evaluated.
curl -X POST "$GATEWAY/v1/policies/simulate" \
-H "authorization: Bearer $TOKEN" \
-H "content-type: application/json" \
--data '{
"schemaVersion": "gateway.policy-simulation/v1",
"simulationId": "sim_contract_read_001",
"actor": {
"tenantId": "tenant_sales",
"environmentId": "prod",
"clientSurfaceId": "external-chat",
"agentId": "sales-contract-agent"
},
"target": {
"environmentId": "prod",
"serverId": "legal-contract-review",
"toolId": "contract_read"
},
"candidatePolicyVersion": "cedar-policy-v3-draft",
"credentialMode": "service_account"
}'simulatePolicy in the API reference →gatewayctl simulate-policy \
--user user_ada --agent sales-contract-agent \
--client-surface external-chat --environment prod \
--server legal-contract-review --tool contract_read \
--policy-version cedar-policy-v3 --format jsonEvery gatewayctl verb accepts --format text|json.
Diagnose a denial
Section titled “Diagnose a denial”When a real call is denied, turn its stable machine reason into a human‑readable diagnosis — the matched (or missing) rule, the policy version, and safe context, with no payloads or secrets.
- Open Investigate → Deny diagnostics.
- Paste the machine reason (or open the denied audit event) to see the diagnosis and the rule that produced it.
curl -X POST "$GATEWAY/v1/deny-diagnostics" \
-H "authorization: Bearer $TOKEN" \
-H "content-type: application/json" \
--data '{"reason_code": "invalid_auth_context"}'createDenyDiagnosticsBundle in the API reference →gatewayctl diagnose-deny invalid_auth_contextEvery gatewayctl verb accepts --format text|json.
Compare a draft with the active policy
Section titled “Compare a draft with the active policy”When reviewing a draft, include activePolicyVersion with the version it would replace. The
candidate remains the decision at the top level. The response also includes baseline, the
active version’s outcome, and changed, which is true only when the two decisions differ.
Both versions require policy.validate access on their owner teams. If the active version cannot
be compiled for simulation, the API returns 422 with
policy_simulation_baseline_compile_failed; it never reports a missing baseline as no change.
Without activePolicyVersion, the response remains the single-outcome shape.
Type set in Geist, Source Serif 4, and Departure Mono.