curl --request POST \
--url https://api.visiqlabs.com/allow/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Block large refunds",
"description": "Require approval for refunds over $500",
"rego_source": "package visiq.action\n\ndefault decision = \"permit\"\n\ndecision = \"approval_required\" {\n input.action == \"refund.create\"\n input.context.amount > 500\n}\n",
"priority": 50,
"enabled": true
}
'import requests
url = "https://api.visiqlabs.com/allow/rules"
payload = {
"name": "Block large refunds",
"description": "Require approval for refunds over $500",
"rego_source": "package visiq.action
default decision = \"permit\"
decision = \"approval_required\" {
input.action == \"refund.create\"
input.context.amount > 500
}
",
"priority": 50,
"enabled": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Block large refunds',
description: 'Require approval for refunds over $500',
rego_source: 'package visiq.action\n\ndefault decision = "permit"\n\ndecision = "approval_required" {\n input.action == "refund.create"\n input.context.amount > 500\n}\n',
priority: 50,
enabled: true
})
};
fetch('https://api.visiqlabs.com/allow/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.visiqlabs.com/allow/rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Block large refunds',
'description' => 'Require approval for refunds over $500',
'rego_source' => 'package visiq.action
default decision = "permit"
decision = "approval_required" {
input.action == "refund.create"
input.context.amount > 500
}
',
'priority' => 50,
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.visiqlabs.com/allow/rules"
payload := strings.NewReader("{\n \"name\": \"Block large refunds\",\n \"description\": \"Require approval for refunds over $500\",\n \"rego_source\": \"package visiq.action\\n\\ndefault decision = \\\"permit\\\"\\n\\ndecision = \\\"approval_required\\\" {\\n input.action == \\\"refund.create\\\"\\n input.context.amount > 500\\n}\\n\",\n \"priority\": 50,\n \"enabled\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.visiqlabs.com/allow/rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Block large refunds\",\n \"description\": \"Require approval for refunds over $500\",\n \"rego_source\": \"package visiq.action\\n\\ndefault decision = \\\"permit\\\"\\n\\ndecision = \\\"approval_required\\\" {\\n input.action == \\\"refund.create\\\"\\n input.context.amount > 500\\n}\\n\",\n \"priority\": 50,\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.visiqlabs.com/allow/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Block large refunds\",\n \"description\": \"Require approval for refunds over $500\",\n \"rego_source\": \"package visiq.action\\n\\ndefault decision = \\\"permit\\\"\\n\\ndecision = \\\"approval_required\\\" {\\n input.action == \\\"refund.create\\\"\\n input.context.amount > 500\\n}\\n\",\n \"priority\": 50,\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"description": "<string>",
"rego_source": "<string>",
"natural_language": "<string>",
"priority": 123,
"enabled": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"error": "Invalid request body",
"code": "invalid_request",
"details": [
{
"path": [
"agent_id"
],
"message": "Required"
}
]
}{
"error": "Unauthorized",
"code": "unauthenticated"
}{
"error": "insufficient_scope",
"code": "insufficient_scope",
"detail": "This API key is not authorized for the requested operation."
}{
"error": "<string>",
"code": "<string>",
"detail": "<string>",
"details": [
{}
]
}{
"error": "<string>",
"code": "<string>",
"detail": "<string>",
"details": [
{}
]
}{
"error": "rate_limiter_unavailable",
"code": "rate_limiter_unavailable",
"detail": "Rate limiter unavailable, please retry."
}Create an action rule
Create an action-governance rule from Rego source. Requires permission allow_rules:create.
curl --request POST \
--url https://api.visiqlabs.com/allow/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Block large refunds",
"description": "Require approval for refunds over $500",
"rego_source": "package visiq.action\n\ndefault decision = \"permit\"\n\ndecision = \"approval_required\" {\n input.action == \"refund.create\"\n input.context.amount > 500\n}\n",
"priority": 50,
"enabled": true
}
'import requests
url = "https://api.visiqlabs.com/allow/rules"
payload = {
"name": "Block large refunds",
"description": "Require approval for refunds over $500",
"rego_source": "package visiq.action
default decision = \"permit\"
decision = \"approval_required\" {
input.action == \"refund.create\"
input.context.amount > 500
}
",
"priority": 50,
"enabled": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Block large refunds',
description: 'Require approval for refunds over $500',
rego_source: 'package visiq.action\n\ndefault decision = "permit"\n\ndecision = "approval_required" {\n input.action == "refund.create"\n input.context.amount > 500\n}\n',
priority: 50,
enabled: true
})
};
fetch('https://api.visiqlabs.com/allow/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.visiqlabs.com/allow/rules",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Block large refunds',
'description' => 'Require approval for refunds over $500',
'rego_source' => 'package visiq.action
default decision = "permit"
decision = "approval_required" {
input.action == "refund.create"
input.context.amount > 500
}
',
'priority' => 50,
'enabled' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.visiqlabs.com/allow/rules"
payload := strings.NewReader("{\n \"name\": \"Block large refunds\",\n \"description\": \"Require approval for refunds over $500\",\n \"rego_source\": \"package visiq.action\\n\\ndefault decision = \\\"permit\\\"\\n\\ndecision = \\\"approval_required\\\" {\\n input.action == \\\"refund.create\\\"\\n input.context.amount > 500\\n}\\n\",\n \"priority\": 50,\n \"enabled\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.visiqlabs.com/allow/rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Block large refunds\",\n \"description\": \"Require approval for refunds over $500\",\n \"rego_source\": \"package visiq.action\\n\\ndefault decision = \\\"permit\\\"\\n\\ndecision = \\\"approval_required\\\" {\\n input.action == \\\"refund.create\\\"\\n input.context.amount > 500\\n}\\n\",\n \"priority\": 50,\n \"enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.visiqlabs.com/allow/rules")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Block large refunds\",\n \"description\": \"Require approval for refunds over $500\",\n \"rego_source\": \"package visiq.action\\n\\ndefault decision = \\\"permit\\\"\\n\\ndecision = \\\"approval_required\\\" {\\n input.action == \\\"refund.create\\\"\\n input.context.amount > 500\\n}\\n\",\n \"priority\": 50,\n \"enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"description": "<string>",
"rego_source": "<string>",
"natural_language": "<string>",
"priority": 123,
"enabled": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"error": "Invalid request body",
"code": "invalid_request",
"details": [
{
"path": [
"agent_id"
],
"message": "Required"
}
]
}{
"error": "Unauthorized",
"code": "unauthenticated"
}{
"error": "insufficient_scope",
"code": "insufficient_scope",
"detail": "This API key is not authorized for the requested operation."
}{
"error": "<string>",
"code": "<string>",
"detail": "<string>",
"details": [
{}
]
}{
"error": "<string>",
"code": "<string>",
"detail": "<string>",
"details": [
{}
]
}{
"error": "rate_limiter_unavailable",
"code": "rate_limiter_unavailable",
"detail": "Rate limiter unavailable, please retry."
}Authorizations
A VisIQ API key presented as Authorization: Bearer vq_prod_.... Mint harness keys under Settings → Harness Keys and API keys under Settings → API Keys in the dashboard.
Headers
Optional. Makes this write safe to retry: a repeat with the same key, method, path (including its query string) and body within 24 hours returns the stored response with X-Idempotent-Replayed: true instead of running again. Reusing the key with a different request is a 422; a repeat while the first is still running is a 409, until the first request's 2-minute processing lease expires, after which the repeat runs. See REST conventions.
1 - 256^[A-Za-z0-9_-]+$The legacy spelling of Idempotency-Key, accepted with the same behaviour. Sending both with different values is a 400.
1 - 256^[A-Za-z0-9_-]+$