Open Policy Agent (OPA) REST API
OPA provides policy-based control for cloud native environments. The following *endpoints* (such as PUT /v1/policies) provide reference documentation for the…
Data & analytics#openapi#open-data
Fork copies the collection into your workspace, without the publisher's secrets, so you can add your own key and send requests. Star saves it to your starred APIs (Account › Marketplace) and helps others find it.
Overview
OPA provides policy-based control for cloud native environments. The following endpoints (such as PUT /v1/policies) provide reference documentation for the OPA REST API.
API specification viewing options
- [View the specification in Redoc (default)](index.html)
- [View the specification in Swagger UI](swagger-ui.html)
Endpoints 16
Policy API
- GETList policies
/v1/policies?pretty=trueThis API endpoint responds with a list of all policy modules on the server (result response) - GETGet a policy module
/v1/policies/:id?pretty=trueThis API endpoint returns the details of the specified policy module ({id}) - PUTCreate or update a policy module
/v1/policies/:id?pretty=true&metrics=falseIf the policy module does not exist, it is created. If the policy module already exists, it is replaced. If the policy module isn't correctly defined, a *bad… - DELETEDelete a policy module
/v1/policies/:id?pretty=trueThis API endpoint removes an existing policy module from the server
Data API
- POSTGet a document (with webhook)
/v0/data/:path?pretty=trueThe example given here assumes you have created a policy (with PUT /v1/policies/{path}), such as: package opa.examples import input.example.flag allow_request… - GETGet a document
/v1/data/:path?input={"input":{"example":{"flag":true}}}&pretty=true&provenance=false&explain=full&metrics=false&instrument=falseThis API endpoint returns the document specified by path. The server will return a *bad request* (400) response if either: The query requires an input… - PUTCreate or overwrite a document
/v1/data/:pathIf the path does not refer to an existing document (for example *us-west/servers*), the server will attempt to create all the necessary containing documents.… - POSTGet a document (with input)
/v1/data/:path?pretty=true&provenance=false&explain=full&metrics=false&instrument=falseThe server will return a *bad request* (400) response if either: The query requires an input document and you do not provide it You provided an input document… - DELETEDelete a document
/v1/data/:pathThis API endpoint deletes an existing document from the server - PATCHUpdate a document
/v1/data/:pathThis API endpoint updates an existing document on the server by describing the changes required (using JSON patch operations)
Query API
- POSTExecute a simple query
/?pretty=trueThis API queries the document at */data/system/main* by default (however, you can configure OPA to use a different path to serve these queries). That document… - GETExecute an ad-hoc query (simple)
/v1/query?q={"query": "data.servers[i].ports[_] = \"p2\"; data.servers[i].name = name"}&pretty=true&explain=full&metrics=falseThis API endpoint returns bindings for the variables in the query. For more complex JSON queries, use POST /v1/query instead. - POSTExecute an ad-hoc query (complex)
/v1/query?pretty=true&explain=full&metrics=falseThis API endpoint returns bindings for the variables in the query. For simpler JSON queries, you may use GET /v1/query instead.
Compile API
- POSTCompile
/v1/compile?pretty=true&explain=full&metrics=false&instrument=falseThis API endpoint allows you to partially evaluate Rego queries and obtain a simplified version of the policy. The example below assumes that OPA has been…
Health API
- GETHealth
/health?bundles=true&plugins=falseThis API endpoint verifies that the server is operational. The response from the server is either 200 or 500: 200 - OPA service is healthy. If bundles is…
Config API
- GETGet configurations
/v1/config?pretty=trueThis API endpoint responds with active configuration (result response) Note The credentials field in the services configuration and The private_key and key…
API details
- Base URL
http://openpolicy.local- Authentication
- None declared in the description
- Operations
- 16 operations on 9 pathsGET 6POST 5PUT 2DELETE 2PATCH 1
- Main resources
- Data API 6Policy API 4Query API 3Compile API 1Config API 1Health API 1
- Description format
- OpenAPI 3.0.3, API version
0.28.0 - Links
- Documentation · OpenAPI document · Support
- Listed from
- APIs.guru OpenAPI Directory (CC0-1.0)
Source updated
How to test the Open Policy Agent (OPA) REST API in Swastik Codes
- Open the APISelect “Fork & run in Swastik Codes” on this page. Sign in or create a free account if asked.
- Fork it into your workspaceChoose a workspace. You get your own copy of the Open Policy Agent (OPA) REST API collection, without the publisher's secrets.
- Add your credentialsOpen the collection's variables or an environment and enter your API key or token, if the API needs one.
- Send a requestPick an endpoint, for example “List policies” (GET /v1/policies?pretty=true), and press Send. Check the response, add tests and run the whole collection with the runner.
Frequently asked questions
What is the Open Policy Agent (OPA) REST API?
OPA provides policy-based control for cloud native environments. The following *endpoints* (such as PUT /v1/policies) provide reference documentation for the… It is listed under Data & analytics and has 16 endpoints.
Who publishes the Open Policy Agent (OPA) REST API?
It is listed from Open Policy Agent's public API description (an OpenAPI document), not published by Open Policy Agent on Swastik Codes. Anyone who controls openpolicyagent.org can claim the profile by adding a DNS TXT record.
What is the base URL of the Open Policy Agent (OPA) REST API?
Requests go to http://openpolicy.local. Endpoint paths are added to this base URL.
How do I authenticate with the Open Policy Agent (OPA) REST API?
Its OpenAPI description does not declare an authentication scheme. Some endpoints may be open; check the provider's documentation before relying on that.
How many endpoints does the Open Policy Agent (OPA) REST API have?
16 operations on 9 paths (6 GET, 5 POST, 2 PUT, 2 DELETE, 1 PATCH). The largest groups are Data API, Policy API, Query API, Compile API.
Is forking the Open Policy Agent (OPA) REST API free?
Yes. Forking copies the collection into your workspace for free. It has been starred 0 times and forked 0 times.