curl --request POST \
--url https://api.onecli.sh/v1/org/policy/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"targets": [
{
"provider": "<string>",
"tools": [
"<string>"
],
"connectionId": "<string>",
"secretId": "<string>",
"hostPattern": "<string>",
"pathPattern": "<string>"
}
],
"description": "<string>",
"enabled": true,
"rateLimit": 500000,
"requireApproval": true,
"conditions": "<unknown>",
"identities": [
{
"id": "<string>"
}
]
}
'import requests
url = "https://api.onecli.sh/v1/org/policy/rules"
payload = {
"name": "<string>",
"targets": [
{
"provider": "<string>",
"tools": ["<string>"],
"connectionId": "<string>",
"secretId": "<string>",
"hostPattern": "<string>",
"pathPattern": "<string>"
}
],
"description": "<string>",
"enabled": True,
"rateLimit": 500000,
"requireApproval": True,
"conditions": "<unknown>",
"identities": [{ "id": "<string>" }]
}
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: '<string>',
targets: [
{
provider: '<string>',
tools: ['<string>'],
connectionId: '<string>',
secretId: '<string>',
hostPattern: '<string>',
pathPattern: '<string>'
}
],
description: '<string>',
enabled: true,
rateLimit: 500000,
requireApproval: true,
conditions: '<unknown>',
identities: [{id: '<string>'}]
})
};
fetch('https://api.onecli.sh/v1/org/policy/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.onecli.sh/v1/org/policy/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' => '<string>',
'targets' => [
[
'provider' => '<string>',
'tools' => [
'<string>'
],
'connectionId' => '<string>',
'secretId' => '<string>',
'hostPattern' => '<string>',
'pathPattern' => '<string>'
]
],
'description' => '<string>',
'enabled' => true,
'rateLimit' => 500000,
'requireApproval' => true,
'conditions' => '<unknown>',
'identities' => [
[
'id' => '<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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.onecli.sh/v1/org/policy/rules"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"targets\": [\n {\n \"provider\": \"<string>\",\n \"tools\": [\n \"<string>\"\n ],\n \"connectionId\": \"<string>\",\n \"secretId\": \"<string>\",\n \"hostPattern\": \"<string>\",\n \"pathPattern\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"enabled\": true,\n \"rateLimit\": 500000,\n \"requireApproval\": true,\n \"conditions\": \"<unknown>\",\n \"identities\": [\n {\n \"id\": \"<string>\"\n }\n ]\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.onecli.sh/v1/org/policy/rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"targets\": [\n {\n \"provider\": \"<string>\",\n \"tools\": [\n \"<string>\"\n ],\n \"connectionId\": \"<string>\",\n \"secretId\": \"<string>\",\n \"hostPattern\": \"<string>\",\n \"pathPattern\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"enabled\": true,\n \"rateLimit\": 500000,\n \"requireApproval\": true,\n \"conditions\": \"<unknown>\",\n \"identities\": [\n {\n \"id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onecli.sh/v1/org/policy/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\": \"<string>\",\n \"targets\": [\n {\n \"provider\": \"<string>\",\n \"tools\": [\n \"<string>\"\n ],\n \"connectionId\": \"<string>\",\n \"secretId\": \"<string>\",\n \"hostPattern\": \"<string>\",\n \"pathPattern\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"enabled\": true,\n \"rateLimit\": 500000,\n \"requireApproval\": true,\n \"conditions\": \"<unknown>\",\n \"identities\": [\n {\n \"id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"scope": "project",
"status": "draft",
"generation": 123,
"priority": 123,
"enabled": true,
"isDefault": true,
"logicalId": "<string>",
"source": "<string>",
"name": "<string>",
"description": "<string>",
"action": "allow",
"rateLimit": 123,
"rateLimitWindow": "minute",
"requireApproval": true,
"conditions": "<unknown>",
"identities": [
{
"type": "agent",
"id": "<string>"
}
],
"targets": [
{
"kind": "app",
"provider": "<string>",
"tools": [
"<string>"
],
"connectionScope": "organization",
"connectionId": "<string>",
"secretId": "<string>",
"secretScope": "organization",
"hostPattern": "<string>",
"pathPattern": "<string>",
"method": "GET"
}
],
"createdAt": "2023-11-07T05:31:56Z"
}Create a policy rule (organization)
Creates a DRAFT rule; it enforces only after a publish. Organization rules take user/group identities (never a specific agent). Requires an organization API key with the admin role.
curl --request POST \
--url https://api.onecli.sh/v1/org/policy/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"targets": [
{
"provider": "<string>",
"tools": [
"<string>"
],
"connectionId": "<string>",
"secretId": "<string>",
"hostPattern": "<string>",
"pathPattern": "<string>"
}
],
"description": "<string>",
"enabled": true,
"rateLimit": 500000,
"requireApproval": true,
"conditions": "<unknown>",
"identities": [
{
"id": "<string>"
}
]
}
'import requests
url = "https://api.onecli.sh/v1/org/policy/rules"
payload = {
"name": "<string>",
"targets": [
{
"provider": "<string>",
"tools": ["<string>"],
"connectionId": "<string>",
"secretId": "<string>",
"hostPattern": "<string>",
"pathPattern": "<string>"
}
],
"description": "<string>",
"enabled": True,
"rateLimit": 500000,
"requireApproval": True,
"conditions": "<unknown>",
"identities": [{ "id": "<string>" }]
}
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: '<string>',
targets: [
{
provider: '<string>',
tools: ['<string>'],
connectionId: '<string>',
secretId: '<string>',
hostPattern: '<string>',
pathPattern: '<string>'
}
],
description: '<string>',
enabled: true,
rateLimit: 500000,
requireApproval: true,
conditions: '<unknown>',
identities: [{id: '<string>'}]
})
};
fetch('https://api.onecli.sh/v1/org/policy/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.onecli.sh/v1/org/policy/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' => '<string>',
'targets' => [
[
'provider' => '<string>',
'tools' => [
'<string>'
],
'connectionId' => '<string>',
'secretId' => '<string>',
'hostPattern' => '<string>',
'pathPattern' => '<string>'
]
],
'description' => '<string>',
'enabled' => true,
'rateLimit' => 500000,
'requireApproval' => true,
'conditions' => '<unknown>',
'identities' => [
[
'id' => '<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;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.onecli.sh/v1/org/policy/rules"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"targets\": [\n {\n \"provider\": \"<string>\",\n \"tools\": [\n \"<string>\"\n ],\n \"connectionId\": \"<string>\",\n \"secretId\": \"<string>\",\n \"hostPattern\": \"<string>\",\n \"pathPattern\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"enabled\": true,\n \"rateLimit\": 500000,\n \"requireApproval\": true,\n \"conditions\": \"<unknown>\",\n \"identities\": [\n {\n \"id\": \"<string>\"\n }\n ]\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.onecli.sh/v1/org/policy/rules")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"targets\": [\n {\n \"provider\": \"<string>\",\n \"tools\": [\n \"<string>\"\n ],\n \"connectionId\": \"<string>\",\n \"secretId\": \"<string>\",\n \"hostPattern\": \"<string>\",\n \"pathPattern\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"enabled\": true,\n \"rateLimit\": 500000,\n \"requireApproval\": true,\n \"conditions\": \"<unknown>\",\n \"identities\": [\n {\n \"id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.onecli.sh/v1/org/policy/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\": \"<string>\",\n \"targets\": [\n {\n \"provider\": \"<string>\",\n \"tools\": [\n \"<string>\"\n ],\n \"connectionId\": \"<string>\",\n \"secretId\": \"<string>\",\n \"hostPattern\": \"<string>\",\n \"pathPattern\": \"<string>\"\n }\n ],\n \"description\": \"<string>\",\n \"enabled\": true,\n \"rateLimit\": 500000,\n \"requireApproval\": true,\n \"conditions\": \"<unknown>\",\n \"identities\": [\n {\n \"id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "<string>",
"scope": "project",
"status": "draft",
"generation": 123,
"priority": 123,
"enabled": true,
"isDefault": true,
"logicalId": "<string>",
"source": "<string>",
"name": "<string>",
"description": "<string>",
"action": "allow",
"rateLimit": 123,
"rateLimitWindow": "minute",
"requireApproval": true,
"conditions": "<unknown>",
"identities": [
{
"type": "agent",
"id": "<string>"
}
],
"targets": [
{
"kind": "app",
"provider": "<string>",
"tools": [
"<string>"
],
"connectionScope": "organization",
"connectionId": "<string>",
"secretId": "<string>",
"secretScope": "organization",
"hostPattern": "<string>",
"pathPattern": "<string>",
"method": "GET"
}
],
"createdAt": "2023-11-07T05:31:56Z"
}Authorizations
API key obtained from the dashboard or GET /user/api-key
Body
rateLimit/rateLimitWindow are paired and, like requireApproval, valid only with action: allow.
255allow, block 1 - 100 elementsShow child attributes
Show child attributes
10001 <= x <= 1000000minute, hour, day A conditions array (max 10) or a session-policy object ({repositories: [...]} / {folders: [...]}; allow rules with a connection target only).
100Show child attributes
Show child attributes
Response
The created draft rule
A policy-engine rule (the staged draft → publish model). Writes land in the draft; only a publish makes them enforced. Published row ids regenerate on every publish; logicalId is the identity stable across statuses and generations.
project, organization draft, published 0 for the draft working copy; the snapshot number for published rows.
First-match order (lower evaluates first).
True on the scope's terminal Default Rule.
Generation-stable identity; compare rules across draft/published by this, never by id.
custom (user-owned, editable), default (the Default Rule), or system-managed rows: blocklist (compiled from app blocklists) and — at project scope — grant (compiled from agent grants; managed through the Grants endpoints, never edited as rules). Older deployments may also carry legacy app_permission/equipment rows.
allow, block minute, hour, day, null A conditions array, a session-policy object ({repositories} / {folders}), or null.
Show child attributes
Show child attributes
Show child attributes
Show child attributes