Attach policies to an agent
curl --request PUT \
--url https://api.akhara.dev/api/agents/{id}/policies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"policyIds": [
"healthcare-0",
"latch-1",
"reliability-3"
]
}
'import requests
url = "https://api.akhara.dev/api/agents/{id}/policies"
payload = { "policyIds": ["healthcare-0", "latch-1", "reliability-3"] }
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({policyIds: ['healthcare-0', 'latch-1', 'reliability-3']})
};
fetch('https://api.akhara.dev/api/agents/{id}/policies', 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.akhara.dev/api/agents/{id}/policies",
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([
'policyIds' => [
'healthcare-0',
'latch-1',
'reliability-3'
]
]),
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.akhara.dev/api/agents/{id}/policies"
payload := strings.NewReader("{\n \"policyIds\": [\n \"healthcare-0\",\n \"latch-1\",\n \"reliability-3\"\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://api.akhara.dev/api/agents/{id}/policies")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"policyIds\": [\n \"healthcare-0\",\n \"latch-1\",\n \"reliability-3\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.akhara.dev/api/agents/{id}/policies")
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 \"policyIds\": [\n \"healthcare-0\",\n \"latch-1\",\n \"reliability-3\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"status": "<string>",
"baseUrl": "<string>",
"apiKeyMasked": "ak_live_••••4f2a",
"categories": [
"<string>"
],
"tools": [
"<string>"
],
"policyIds": [
"<string>"
],
"runtime": {
"status": "<string>",
"boundary": "android-emulator",
"env": {
"GATEWAY": "https://api.akhara.dev"
},
"provisionedAt": 123
},
"createdAt": 123,
"updatedAt": 123
}Agents
Attach policies
Sets the agent’s attached policyIds. The effective set is these plus the always-on enterprise baseline.
PUT
/
api
/
agents
/
{id}
/
policies
Attach policies to an agent
curl --request PUT \
--url https://api.akhara.dev/api/agents/{id}/policies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"policyIds": [
"healthcare-0",
"latch-1",
"reliability-3"
]
}
'import requests
url = "https://api.akhara.dev/api/agents/{id}/policies"
payload = { "policyIds": ["healthcare-0", "latch-1", "reliability-3"] }
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({policyIds: ['healthcare-0', 'latch-1', 'reliability-3']})
};
fetch('https://api.akhara.dev/api/agents/{id}/policies', 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.akhara.dev/api/agents/{id}/policies",
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([
'policyIds' => [
'healthcare-0',
'latch-1',
'reliability-3'
]
]),
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.akhara.dev/api/agents/{id}/policies"
payload := strings.NewReader("{\n \"policyIds\": [\n \"healthcare-0\",\n \"latch-1\",\n \"reliability-3\"\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://api.akhara.dev/api/agents/{id}/policies")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"policyIds\": [\n \"healthcare-0\",\n \"latch-1\",\n \"reliability-3\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.akhara.dev/api/agents/{id}/policies")
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 \"policyIds\": [\n \"healthcare-0\",\n \"latch-1\",\n \"reliability-3\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"name": "<string>",
"status": "<string>",
"baseUrl": "<string>",
"apiKeyMasked": "ak_live_••••4f2a",
"categories": [
"<string>"
],
"tools": [
"<string>"
],
"policyIds": [
"<string>"
],
"runtime": {
"status": "<string>",
"boundary": "android-emulator",
"env": {
"GATEWAY": "https://api.akhara.dev"
},
"provisionedAt": 123
},
"createdAt": 123,
"updatedAt": 123
}Sets the agent’s attached
policyIds. The effective set the PDP evaluates is
these plus the always-on enterprise baseline (latch-0 … latch-5). See
Policies.Authorizations
Workspace API key (ak_live_…).
Path Parameters
Body
application/json
Response
200 - application/json
The updated agent.
⌘I