Skip to main content
POST
/
v1
/
policies
Create a Control Loop Policy (TRU-67 Phase 1)
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>",
  "trigger_type": "eval_score",
  "action_type": "retry",
  "description": "<string>",
  "rollout_pct": 0,
  "dry_run": true,
  "max_retry_depth": 3,
  "max_cascade_depth": 5
}
'
{
  "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
}

Documentation Index

Fetch the complete documentation index at: https://docs.trulayer.ai/llms.txt

Use this file to discover all available pages before exploring further.

Authorizations

Authorization
string
header
required

SDK API key (tl_...) or Clerk session JWT

Body

application/json
name
string
required
rule_yaml
string
required
trigger_type
enum<string>
required
Available options:
eval_score,
anomaly,
failure_rate
action_type
enum<string>
required
Available options:
retry,
fallback_model,
route_pct,
block,
escalate
description
string
rollout_pct
integer
default:0
Required range: 0 <= x <= 100
dry_run
boolean
default:true
max_retry_depth
integer
default:3

Per-policy retry depth cap (TRU-362). Out-of-range values return HTTP 422.

Required range: 1 <= x <= 10
max_cascade_depth
integer
default:5

Per-policy cascade depth cap (TRU-371). Counts retry + fallback_model + prompt_modification combined per trace, across policies. Out-of-range values return HTTP 422.

Required range: 1 <= x <= 20

Response

Policy created

id
string<uuid>
required
created_at
string<date-time>
required
updated_at
string<date-time>
required
tenant_id
string<uuid>
required
name
string
required
description
string
required
status
enum<string>
required
Available options:
draft,
active,
paused,
archived
rule_yaml
string
required

Raw YAML DSL as authored. Opaque to the server in Phase 1.

trigger_type
enum<string>
required

Denormalised summary of the when: clause for fast filtering.

Available options:
eval_score,
anomaly,
failure_rate
action_type
enum<string>
required

Denormalised summary of the then: clause for fast filtering.

Available options:
retry,
fallback_model,
route_pct,
block,
escalate
rollout_pct
integer
required

Staged-rollout percentage. 0 means the policy is authored but inactive.

Required range: 0 <= x <= 100
dry_run
boolean
required

When true, the evaluator records observations without applying the action.

created_by
string
required

Clerk user ID of the author.

max_retry_depth
integer
required

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.

Required range: 1 <= x <= 10
max_cascade_depth
integer
required

Per-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.

Required range: 1 <= x <= 20