curl --request POST \
--url https://api.trulayer.ai/v1/policies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"rule_yaml": "<string>",
"description": "<string>",
"rollout_pct": 0,
"dry_run": true,
"max_retry_depth": 3,
"max_cascade_depth": 5
}
'import requests
url = "https://api.trulayer.ai/v1/policies"
payload = {
"name": "<string>",
"rule_yaml": "<string>",
"description": "<string>",
"rollout_pct": 0,
"dry_run": True,
"max_retry_depth": 3,
"max_cascade_depth": 5
}
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>',
rule_yaml: '<string>',
description: '<string>',
rollout_pct: 0,
dry_run: true,
max_retry_depth: 3,
max_cascade_depth: 5
})
};
fetch('https://api.trulayer.ai/v1/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.trulayer.ai/v1/policies",
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>',
'rule_yaml' => '<string>',
'description' => '<string>',
'rollout_pct' => 0,
'dry_run' => true,
'max_retry_depth' => 3,
'max_cascade_depth' => 5
]),
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.trulayer.ai/v1/policies"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"rule_yaml\": \"<string>\",\n \"description\": \"<string>\",\n \"rollout_pct\": 0,\n \"dry_run\": true,\n \"max_retry_depth\": 3,\n \"max_cascade_depth\": 5\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.trulayer.ai/v1/policies")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"rule_yaml\": \"<string>\",\n \"description\": \"<string>\",\n \"rollout_pct\": 0,\n \"dry_run\": true,\n \"max_retry_depth\": 3,\n \"max_cascade_depth\": 5\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trulayer.ai/v1/policies")
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 \"rule_yaml\": \"<string>\",\n \"description\": \"<string>\",\n \"rollout_pct\": 0,\n \"dry_run\": true,\n \"max_retry_depth\": 3,\n \"max_cascade_depth\": 5\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"description": "<string>",
"status": "draft",
"rule_yaml": "<string>",
"trigger_type": "eval_score",
"action_type": "retry",
"rollout_pct": 50,
"dry_run": true,
"created_by": "<string>",
"max_retry_depth": 5,
"max_cascade_depth": 10
}{
"error": "<string>"
}{
"error": "<string>"
}Create a Control Loop Policy (TRU-67 Phase 1)
Creates a named YAML-DSL policy in draft status. Dashboard-only
(Clerk session + member role required). Phase 2 (follow-up
issue) adds the automated evaluator that applies active policies
to eval events; Phase 1 is CRUD only.
curl --request POST \
--url https://api.trulayer.ai/v1/policies \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "<string>",
"rule_yaml": "<string>",
"description": "<string>",
"rollout_pct": 0,
"dry_run": true,
"max_retry_depth": 3,
"max_cascade_depth": 5
}
'import requests
url = "https://api.trulayer.ai/v1/policies"
payload = {
"name": "<string>",
"rule_yaml": "<string>",
"description": "<string>",
"rollout_pct": 0,
"dry_run": True,
"max_retry_depth": 3,
"max_cascade_depth": 5
}
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>',
rule_yaml: '<string>',
description: '<string>',
rollout_pct: 0,
dry_run: true,
max_retry_depth: 3,
max_cascade_depth: 5
})
};
fetch('https://api.trulayer.ai/v1/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.trulayer.ai/v1/policies",
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>',
'rule_yaml' => '<string>',
'description' => '<string>',
'rollout_pct' => 0,
'dry_run' => true,
'max_retry_depth' => 3,
'max_cascade_depth' => 5
]),
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.trulayer.ai/v1/policies"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"rule_yaml\": \"<string>\",\n \"description\": \"<string>\",\n \"rollout_pct\": 0,\n \"dry_run\": true,\n \"max_retry_depth\": 3,\n \"max_cascade_depth\": 5\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.trulayer.ai/v1/policies")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"rule_yaml\": \"<string>\",\n \"description\": \"<string>\",\n \"rollout_pct\": 0,\n \"dry_run\": true,\n \"max_retry_depth\": 3,\n \"max_cascade_depth\": 5\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.trulayer.ai/v1/policies")
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 \"rule_yaml\": \"<string>\",\n \"description\": \"<string>\",\n \"rollout_pct\": 0,\n \"dry_run\": true,\n \"max_retry_depth\": 3,\n \"max_cascade_depth\": 5\n}"
response = http.request(request)
puts response.read_body{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"description": "<string>",
"status": "draft",
"rule_yaml": "<string>",
"trigger_type": "eval_score",
"action_type": "retry",
"rollout_pct": 50,
"dry_run": true,
"created_by": "<string>",
"max_retry_depth": 5,
"max_cascade_depth": 10
}{
"error": "<string>"
}{
"error": "<string>"
}Authorizations
SDK API key (tl_...) or Clerk session JWT
Body
eval_score, anomaly, failure_rate retry, fallback_model, route_pct, block, escalate 0 <= x <= 100Per-policy retry depth cap (TRU-362). Out-of-range values return HTTP 422.
1 <= x <= 10Per-policy cascade depth cap (TRU-371). Counts retry + fallback_model + prompt_modification combined per trace, across policies. Out-of-range values return HTTP 422.
1 <= x <= 20Response
Policy created
draft, active, paused, archived Raw YAML DSL as authored. Opaque to the server in Phase 1.
Denormalised summary of the when: clause for fast filtering.
eval_score, anomaly, failure_rate Denormalised summary of the then: clause for fast filtering.
retry, fallback_model, route_pct, block, escalate Staged-rollout percentage. 0 means the policy is authored but inactive.
0 <= x <= 100When true, the evaluator records observations without applying the action.
Clerk user ID of the author.
Per-policy retry depth cap (TRU-362). When the executor counts
this many or more previously-executed retry actions on a trace
for this policy, the next retry is auto-converted to an
escalate action and routed through the HITL pending_approval
queue. Default 3.
1 <= x <= 10Per-policy cascade depth cap (TRU-371). Counts every
remediation action on the trace — retry plus
fallback_model plus prompt_modification — across all
policies. When the count reaches this many, the next
remediation is auto-converted to escalate and parked in
the HITL queue. Distinct from max_retry_depth which
counts retries only; both gates run per Execute call and
whichever fires first wins. Default 5.
1 <= x <= 20