Set policy agents
curl --request PUT \
--url https://cp.xenovia.io/api/v1/policies/{policy_id}/agents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
}
'import requests
url = "https://cp.xenovia.io/api/v1/policies/{policy_id}/agents"
payload = { "agent_ids": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({agent_ids: ['3c90c3cc-0d44-4b50-8888-8dd25736052a']})
};
fetch('https://cp.xenovia.io/api/v1/policies/{policy_id}/agents', 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://cp.xenovia.io/api/v1/policies/{policy_id}/agents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'agent_ids' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]),
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://cp.xenovia.io/api/v1/policies/{policy_id}/agents"
payload := strings.NewReader("{\n \"agent_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}")
req, _ := http.NewRequest("PUT", 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.put("https://cp.xenovia.io/api/v1/policies/{policy_id}/agents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cp.xenovia.io/api/v1/policies/{policy_id}/agents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agent_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"org_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"owner_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"category": "<string>",
"summary": "<string>",
"rego": "<string>",
"enabled": true,
"stage": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"warnings": [
"<string>"
],
"group": "<string>",
"template_controls_outdated": true,
"agent_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"agents": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"provider": "<string>",
"coding_tool": "<string>",
"status": "<string>"
}
],
"agent_modes": {},
"enforcement_mode": "enforce",
"template_id": "<string>",
"template_version": 123,
"framework_tags": [
"<string>"
],
"control_mappings": [
{
"framework": "<string>",
"controls": [
"<string>"
],
"rationale": ""
}
],
"parameter_values": {},
"version": 1,
"baseline_target": {},
"conformance_cases": [
{
"name": "<string>",
"input": {},
"expect": {
"action": "<string>",
"rule": "<string>"
},
"stage": "request",
"parameters": {}
}
],
"conformance": {
"ran_at": "2023-11-07T05:31:56Z",
"opa_version": "<string>",
"source": "template",
"passed": 123,
"failed": 123,
"cases": [
{
"name": "<string>",
"stage": "request",
"expected_action": "<string>",
"got_action": "<string>",
"ok": true,
"expected_rule": "<string>",
"got_rule": "<string>",
"error": "<string>"
}
]
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Policies
Set policy agents
Auth: organization API key with write scope, or a signed-in user.
Body: {"agent_ids": [...]}, up to 200, replacing the agents the policy covers. A policy left with no agents is disabled.
PUT
/
api
/
v1
/
policies
/
{policy_id}
/
agents
Set policy agents
curl --request PUT \
--url https://cp.xenovia.io/api/v1/policies/{policy_id}/agents \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
]
}
'import requests
url = "https://cp.xenovia.io/api/v1/policies/{policy_id}/agents"
payload = { "agent_ids": ["3c90c3cc-0d44-4b50-8888-8dd25736052a"] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({agent_ids: ['3c90c3cc-0d44-4b50-8888-8dd25736052a']})
};
fetch('https://cp.xenovia.io/api/v1/policies/{policy_id}/agents', 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://cp.xenovia.io/api/v1/policies/{policy_id}/agents",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'agent_ids' => [
'3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
]),
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://cp.xenovia.io/api/v1/policies/{policy_id}/agents"
payload := strings.NewReader("{\n \"agent_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}")
req, _ := http.NewRequest("PUT", 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.put("https://cp.xenovia.io/api/v1/policies/{policy_id}/agents")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"agent_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://cp.xenovia.io/api/v1/policies/{policy_id}/agents")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"agent_ids\": [\n \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"org_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"owner_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"category": "<string>",
"summary": "<string>",
"rego": "<string>",
"enabled": true,
"stage": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"warnings": [
"<string>"
],
"group": "<string>",
"template_controls_outdated": true,
"agent_ids": [
"3c90c3cc-0d44-4b50-8888-8dd25736052a"
],
"agents": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"provider": "<string>",
"coding_tool": "<string>",
"status": "<string>"
}
],
"agent_modes": {},
"enforcement_mode": "enforce",
"template_id": "<string>",
"template_version": 123,
"framework_tags": [
"<string>"
],
"control_mappings": [
{
"framework": "<string>",
"controls": [
"<string>"
],
"rationale": ""
}
],
"parameter_values": {},
"version": 1,
"baseline_target": {},
"conformance_cases": [
{
"name": "<string>",
"input": {},
"expect": {
"action": "<string>",
"rule": "<string>"
},
"stage": "request",
"parameters": {}
}
],
"conformance": {
"ran_at": "2023-11-07T05:31:56Z",
"opa_version": "<string>",
"source": "template",
"passed": 123,
"failed": 123,
"cases": [
{
"name": "<string>",
"stage": "request",
"expected_action": "<string>",
"got_action": "<string>",
"ok": true,
"expected_rule": "<string>",
"got_rule": "<string>",
"error": "<string>"
}
]
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
Body
application/json
Response
Successful Response