Data API
Get a document (with webhook)
The 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 { flag == true }
The server will return a not found (404) response if the requested document is missing or undefined.
post/v0/data/{path}
Query parameters
prettyboolean
If true, response will be in a human-readable format.
Response
Success
Example response
{
"result": [
{
"id": "example2",
"raw": "package opa.examples\\n\\nimport data.servers\\n\\nviolations[server] {\\n\\tserver = servers[_]\\n\\tserver.protocols[_] = \\\"http\\\"\\n\\tpublic_servers[server]\\n}\\n",
"ast": {
"package": {
"path": [
{
"type": "import",
"value": "data.opa.example"
}
]
},
"rules": [
{
"head": {
"name": "violations",
"key": {
"type": "var",
"value": "$0"
}
},
"body": [
{
"index": 1,
"terms": [
{
"type": "var"
}
]
}
]
}
]
}
}
],
"provenance": {
"build_commit": "4c6e524",
"build_hostname": "3bb58334a5a9"
},
"metrics": {
"timer_rego_input_parse_ns": 69994,
"timer_rego_query_parse_ns": 4096,
"timer_rego_query_compile_ns": 4096,
"timer_rego_query_eval_ns": 69994,
"timer_rego_module_parse_ns": 12345,
"timer_rego_module_compile_ns": 69994,
"timer_server_handler_ns": 631000,
"timer_server_read_bytes_ns": 631000,
"timer_query_compile_stage_build_comprehension_index_ns": 43000,
"timer_query_compile_stage_check_safety_ns": 852000,
"timer_query_compile_stage_check_types_ns": 577000,
"timer_query_compile_stage_check_undefined_funcs_ns": 426000,
"timer_query_compile_stage_check_unsafe_builtins_ns": 14000,
"timer_query_compile_stage_resolve_refs_ns": 3000,
"timer_query_compile_stage_rewrite_comprehension_terms_ns": 329000,
"timer_query_compile_stage_rewrite_dynamic_terms_ns": 27000,
"timer_query_compile_stage_rewrite_expr_terms_ns": 40000,
"timer_query_compile_stage_rewrite_local_vars_ns": 187000,
"timer_query_compile_stage_rewrite_to_capture_value_ns": 1178000,
"timer_query_compile_stage_rewrite_with_values_ns": 23000
},
"explanation": [
{
"op": "enter",
"type": "expr",
"node": {
"terms": [
{
"type": "var",
"value": "$term1"
}
]
}
}
]
}