Update Policy - Barndoor Documentation
Update Policy
cURL
curl --request PATCH \
--url https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"description": "<string>",
"support_contact": "<string>",
"tags": [
"<string>"
],
"application_ids": [
"<string>"
],
"rules": [
{
"name": "",
"authorized": false,
"actions": [
"<string>"
],
"roles_groups": [
"<string>"
],
"condition": {
"match": {
"expr": "<string>"
}
}
}
]
}
'
Python
import requests
url = "https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}"
payload = {
"name": "<string>",
"description": "<string>",
"support_contact": "<string>",
"tags": ["<string>"],
"application_ids": ["<string>"],
"rules": [
{
"name": "",
"authorized": False,
"actions": ["<string>"],
"roles_groups": ["<string>"],
"condition": { "match": { "expr": "<string>" } }
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {
method: 'PATCH',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: '<string>',
description: '<string>',
support_contact: '<string>',
tags: ['<string>'],
application_ids: ['<string>'],
rules: [
{
name: '',
authorized: false,
actions: ['<string>'],
roles_groups: ['<string>'],
condition: {match: {expr: '<string>'}}
}
]
})
};
fetch('https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}', 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://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'name' => '<string>',
'description' => '<string>',
'support_contact' => '<string>',
'tags' => ['<string>'],
'application_ids' => ['<string>'],
'rules' => [
[
'name' => '',
'authorized' => false,
'actions' => ['<string>'],
'roles_groups' => ['<string>'],
'condition' => ['match' => ['expr' => '<string>']]
]
]
]),
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;
}
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"support_contact\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"application_ids\": [\n \"<string>\"\n ],\n \"rules\": [\n {\n \"name\": \"\",\n \"authorized\": false,\n \"actions\": [\n \"<string>\"\n ],\n \"roles_groups\": [\n \"<string>\"\n ],\n \"condition\": {\n \"match\": {\n \"expr\": \"<string>\"\n }\n }\n }\n ]\n}")
req, _ := http.NewRequest("PATCH", 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))
}
Java
HttpResponse<String> response = Unirest.patch("https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"support_contact\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"application_ids\": [\n \"<string>\"\n ],\n \"rules\": [\n {\n \"name\": \"\",\n \"authorized\": false,\n \"actions\": [\n \"<string>\"\n ],\n \"roles_groups\": [\n \"<string>\"\n ],\n \"condition\": {\n \"match\": {\n \"expr\": \"<string>\"\n }\n }\n }\n ]\n}")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://your-org.platform.barndoor.ai/api/v2/policies/{policy_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"support_contact\": \"<string>\",\n \"tags\": [\n \"<string>\"\n ],\n \"application_ids\": [\n \"<string>\"\n ],\n \"rules\": [\n {\n \"name\": \"\",\n \"authorized\": false,\n \"actions\": [\n \"<string>\"\n ],\n \"roles_groups\": [\n \"<string>\"\n ],\n \"condition\": {\n \"match\": {\n \"expr\": \"<string>\"\n }\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body
Responses
200
{
"policy": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"organization_id": "<string>",
"name": "<string>",
"status": "<string>",
"mcp_server_id": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"created_by_user_id": "<string>",
"updated_by_user_id": "<string>",
"support_contact": "<string>",
"description": "<string>",
"application_ids": [
"<string>"
],
"tags": [
"<string>"
],
"rules": [
{
"name": "",
"authorized": false,
"actions": [
"<string>"
],
"roles_groups": [
"<string>"
],
"condition": {
"match": {
"expr": "<string>"
}
}
}
]
}
}
422
{
"detail": [
{
"loc": ["<string>"],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}
Authorizations
Authorization
string
header
required
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
policy_id
string
Body
application/json
Request body for partial updates to an existing policy.
name
string | null
Human-friendly policy name, unique within an organization
description
string | null
Longer description of the policy.
support_contact
string | null
Primary point of contact associated with the policy.
tags
string[] | null
Tags for categorizing the policy.
application_ids
string[] | null
List of application (agent) identifiers to which this policy applies.
rules
PolicyRule · object[] | null
Full set of rules that govern the policy.