Skip to content

Guardrails API

GET /api/v1/admin/guardrails · operation listGuardrails

YAML and console guardrails with built-in detector names. Requires guardrails and guardrails:read (admin, viewer).

Authentication: adminSession

Responses

Status Description Body
200 Guardrails application/json: object
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

Response 200 fields:

  • application/json: object
    • version (integer (int64), required)
    • data (array of Guardrail, required)
    • detectors (array of string, required)
    • scope (string)
    • guardrail_streaming (GuardrailStreamingSettings)

PUT /api/v1/admin/guardrails/{id} · operation upsertGuardrail

Versioned, audited console override (PostgreSQL v44). Patterns are RE2 (linear time, no backreferences), at most 8 of 256 characters, and must not match empty text. Takes effect on the next Chat Completions, Anthropic Messages or Responses request on every replica after sync; other operations are not inspected. Requires guardrail_management and guardrails:manage.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^[a-z][a-z0-9_-]{0,63}$
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • version (integer (int64), required)
    • guardrail (Guardrail, required)

Responses

Status Description Body
200 Saved; guardrail and new version —
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error
409 Configuration version conflict —
422 Invalid guardrail, detector, pattern or model —

DELETE /api/v1/admin/guardrails/{id} · operation deleteGuardrail

Remove a console guardrail or revert an override to YAML.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • version (integer (int64), required)

Responses

Status Description Body
200 Removed; new version —
403 Model not allowed application/json: Error
404 No console override, or feature disabled —
409 Configuration version conflict —

GET /api/v1/admin/guardrail-policies · operation listGuardrailPolicies

Guardrail policies (ADR 0145) with their source (yaml or console), and the templates (id, name, description, the guardrails each creates, availability and what it needs). Requires guardrails, guardrail_policies and guardrails:read.

Authentication: adminSession

Responses

Status Description Body
200 version, data (the policies) and templates application/json: object
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

Response 200 fields:

  • application/json: object
    • version (integer (int64), required)
    • data (array of GuardrailPolicy, required)
    • templates (array of object, required)

PUT /api/v1/admin/guardrail-policies/{id} · operation upsertGuardrailPolicy

Creates or replaces a console policy: the guardrails it adds and removes, the policy it inherits and the teams, keys or models it is attached to (“*” for all). The whole configuration is validated with the change (unknown guardrails, inheritance cycles). Requires guardrails:manage.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, max length 64
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object

Responses

Status Description Body
200 New configuration version and the saved policy —
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error
409 version_conflict —
422 invalid_policy —

DELETE /api/v1/admin/guardrail-policies/{id}

Section titled “DELETE /api/v1/admin/guardrail-policies/{id}”

DELETE /api/v1/admin/guardrail-policies/{id} · operation deleteGuardrailPolicy

Removes a console policy or reverts a YAML one; refused while another policy inherits it. Requires guardrails:manage.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, max length 64
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • version (integer (int64), required)

Responses

Status Description Body
200 New configuration version —
404 Feature disabled or no console policy —
409 policy_in_use or version_conflict —

POST /api/v1/admin/guardrail-policies/simulate

Section titled “POST /api/v1/admin/guardrail-policies/simulate”

POST /api/v1/admin/guardrail-policies/simulate · operation simulateGuardrailPolicies

Which guardrails a request of this team, key and model meets, and why (on by default, added or removed by a policy, not for this model, disabled), with the attached policies. With a text, the active input guardrails run in order, provider guardrails included and billed. Requires guardrails:manage.

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • team (string, max length 128)
    • key_id (string, max length 128)
    • model (string, required)
    • text (string, max length 8192)

Responses

Status Description Body
200 steps (guardrail, active, reason, policy), policies and, with text, run (verdict, triggered_by, output, results) —
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

POST /api/v1/admin/guardrail-policies/templates/{id}/apply

Section titled “POST /api/v1/admin/guardrail-policies/templates/{id}/apply”

POST /api/v1/admin/guardrail-policies/templates/{id}/apply · operation applyGuardrailPolicyTemplate

Creates the template’s guardrails, off by default and kept if they already exist, and a policy with the template’s ID attached to the given teams, keys or models, in one configuration change. Requires guardrails:manage.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, one of "lgpd-pii", "injection-secrets", "content-safety", "regulated"
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • version (integer (int64), required)
    • teams (array of string)
    • keys (array of string)
    • models (array of string)

Responses

Status Description Body
200 New configuration version, the policy and the guardrails —
400 Invalid input application/json: Error
404 Feature disabled or template not found —
422 template_unavailable or invalid_policy —

GET /api/v1/admin/guardrails/catalog · operation guardrailCatalog

Guardrail catalog (ADR 0143), with figures measured by this gateway. Every built-in detector is run alone against the labeled datasets on each read (positives are the cases labeled with it, negatives every case that should pass) and returns precision, recall, F1, false positives and negatives and p50/p95 latency. Provider kinds (moderation, Azure Content Safety, Bedrock, Lakera, Presidio, generic API) come with the latest evaluation of each configured guardrail of that kind. Also lists the dataset frameworks, the case count and the latest run of every guardrail. Requires guardrails and guardrails:read.

Authentication: adminSession

Responses

Status Description Body
200 data (id, kind detector or provider, name, description, latency, cost, needs, measured, evals, in_use), frameworks, cases, evals —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

GET /api/v1/admin/guardrails/datasets · operation guardrailDatasets

The labeled cases (ADR 0143) the catalog and the Compliance tab use: id, framework, category, prompt, expected (fail or pass) and labels (the built-in detectors that should fire). Requires guardrails and guardrails:read.

Authentication: adminSession

Responses

Status Description Body
200 data: the cases —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

POST /api/v1/admin/guardrails/{id}/evaluate

Section titled “POST /api/v1/admin/guardrails/{id}/evaluate”

POST /api/v1/admin/guardrails/{id}/evaluate · operation evaluateGuardrail

Evaluates one configured guardrail, provider guardrails included, against the labeled cases of the chosen frameworks (all when empty), four cases at a time within 90 seconds. A case that should fail counts as caught when it is blocked or masked; a provider failure is counted apart. The run (counts, precision, recall, F1, p50/p95) is stored, the latest 20 per guardrail; prompts are not. Provider guardrails are billed as usual. Requires guardrails, storage and guardrails:manage.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, max length 64
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • frameworks (array of string)

Responses

Status Description Body
200 The stored run: guardrail_id, frameworks, cases, true_positives, false_positives, true_negatives, false_negatives, errors, precision, recall, f1, p50_ms, p95_ms, actor, created_at —
400 No case matches the chosen frameworks —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled or guardrail not found —
503 Storage unavailable —
504 evaluation_timeout: longer than 90 seconds —

POST /api/v1/admin/guardrails/test · operation testGuardrails

Compliance test (ADR 0142), the backend of the Playground Compliance tab. Runs one to ten configured guardrails, pattern and provider guardrails alike, over up to 8 KiB of text in the order given, as a request would meet them: a mask feeds the next guardrail, every guardrail reports its own outcome (blocked, masked, allowed, error) and a provider failure follows its on_error. A mode monitor guardrail (T128) reports would_block or would_mask, never masks the text and never decides the verdict, and its failure is only an error outcome. Provider guardrails are called and billed as on a request; the text is not stored or logged. Requires guardrails, guardrail_compliance and the guardrails:manage console permission.

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • guardrail_ids (array of string, required, min items 1, max items 10)
    • text (string, required, min length 1, max length 8192)

Responses

Status Description Body
200 verdict (blocked, masked or allowed), triggered_by (first blocking guardrail), output (the text after masks, absent when blocked), request_id and results per guardrail (id, kind, mode, outcome, findings, latency_ms) —
400 Invalid input application/json: Error
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

POST /api/v1/admin/guardrails/simulate · operation simulateGuardrail

Run a draft guardrail on up to 8 KiB of sample text. Nothing is sent upstream, stored or logged. Blocked samples return an empty output.

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • guardrail (Guardrail, required)
    • text (string, required, max length 8192)

Responses

Status Description Body
200 Findings per detector or pattern and the masked output application/json: object
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error
422 Invalid draft guardrail —

Response 200 fields:

  • application/json: object
    • findings (object, required)
      • any other key: integer
    • blocked (boolean, required)
    • output (string, required)
    • outcome (string, one of "passed", "masked", "blocked", "would_block", "would_mask") — T128: what the draft would do; a monitor returns would_block or would_mask with the sample unchanged in output

m7gtwcontact@m7gtw.com