Guardrails
Policy rules plus the evaluation log. Evaluating a proposed action checks it against every enabled rule — the strictest matching rule wins (block beats approve beats allow) — and records the verdict.
All endpoints require a Bearer JWT in the Authorization header plus an X-Workspace-Id header selecting the workspace.
Rules
GET
/api/guardrails/rulesAuth requiredList policy rules ordered by name.
Query Parameters
| Field | Type | Required | Note |
|---|---|---|---|
| enabled | boolean | No | — |
Response
[
{
"id": 1,
"workspace_id": 1,
"name": "AE spend cap",
"rule_kind": "spend_cap",
"action_kind": "spend",
"threshold_cents": 500000,
"verdict": "approve",
"required_approvals": 1,
"enabled": true
}
]POST
/api/guardrails/rulesAuth requiredCreate a policy rule. Returns 422 for an unknown verdict.
Request Body
| Field | Type | Required | Note |
|---|---|---|---|
| name | string | Yes | Required |
| rule_kind | string | Yes | spend_cap | approval_threshold | flagged_account | first_of_kind |
| action_kind | string | No | Restricts the rule to one action kind |
| threshold_cents | number | No | Used by spend_cap / approval_threshold |
| window | string | No | — |
| max_count | number | No | — |
| account_ref | string | No | Used by flagged_account |
| verdict | string | No | allow | approve | block. Default 'approve' |
| required_approvals | number | No | Default 1 |
| enabled | boolean | No | Default true |
Response
{
"id": 2,
"name": "Block flagged vendor",
"rule_kind": "flagged_account",
"account_ref": "sketchy-vendor",
"verdict": "block",
"enabled": true
}GET
/api/guardrails/rules/{rule_id}Auth requiredGet a single policy rule.
Response
{
"id": 1,
"name": "AE spend cap",
"rule_kind": "spend_cap",
"action_kind": "spend",
"threshold_cents": 500000,
"verdict": "approve",
"required_approvals": 1,
"enabled": true
}PATCH
/api/guardrails/rules/{rule_id}Auth requiredUpdate a rule. All fields optional; returns 400 when no fields are provided.
Request Body
| Field | Type | Required | Note |
|---|---|---|---|
| name | string | No | — |
| rule_kind | string | No | — |
| action_kind | string | No | — |
| threshold_cents | number | No | — |
| window | string | No | — |
| max_count | number | No | — |
| account_ref | string | No | — |
| verdict | string | No | — |
| required_approvals | number | No | — |
| enabled | boolean | No | — |
Response
{ "id": 1, "name": "AE spend cap", "threshold_cents": 1000000, "enabled": true }DELETE
/api/guardrails/rules/{rule_id}Auth requiredDelete a policy rule.
Response
{ "deleted": 1 }Evaluation
POST
/api/guardrails/evaluateAuth requiredCheck a proposed action against the enabled rules and record the verdict. Strictest matching rule wins.
Request Body
| Field | Type | Required | Note |
|---|---|---|---|
| action_kind | string | Yes | Required, e.g. 'spend' |
| amount_cents | number | No | Default 0 |
| account_ref | string | No | — |
| actor | string | No | — |
Response
{
"verdict": "approve",
"reason": "AE spend cap: $6,000 is over the $5,000 cap",
"policy_id": 1,
"required_approvals": 1,
"suggested_rule": null
}GET
/api/guardrails/evalsAuth requiredList recorded evaluation verdicts, newest first.
Query Parameters
| Field | Type | Required | Note |
|---|---|---|---|
| verdict | string | No | allow | approve | block |
| limit | number | No | Default 50, max 200 |
Response
[
{
"id": 7,
"workspace_id": 1,
"rule_id": 1,
"rule_name": "AE spend cap",
"action_kind": "spend",
"amount_cents": 600000,
"account_ref": null,
"actor": "jane",
"verdict": "approve",
"reason": "AE spend cap: $6,000 is over the $5,000 cap"
}
]