Evaluate OPA/Rego policies via the OPA REST API

domain: openpolicyagent.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Start the OPA server with opa run --server (optionally specifying a bundle or policy directory with -b or a policy file argument); by default it listens on port 8181
  2. Load policies by bundling them (opa build) and configuring OPA to pull from a bundle server, or by POSTing Rego policy text to /v1/policies/POLICY_ID to upload individual policies at runtime
  3. Evaluate a policy decision by sending a POST to /v1/data/PACKAGE/RULE with a JSON body containing an input object; the response body's result field contains the policy decision
  4. Structure your Rego package hierarchy to mirror your authorization model (e.g., authz.allow, authz.deny) so that callers have a stable, predictable query path
  5. Use partial evaluation or the compile API (/v1/compile) to push policy decisions to the edge or to generate query plans for performance-sensitive paths
  6. Configure OPA's decision log plugin to emit structured log entries of every query and decision to your SIEM or logging pipeline for audit purposes

Known gotchas

Related routes

Write an OPA Rego policy using partial evaluation to pre-compute allowed resource sets for a given principal
openpolicyagent.org · 6 steps · unrated
Define OPA Rego policy unit tests and run them with opa test
openpolicyagent.org · 6 steps · unrated
Build and run unit tests for OPA Rego policies using opa test with coverage
openpolicyagent.org · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans