POST/v1/guardrails

Create a guardrail

A guardrail matches when any of its rules matches. A new guardrail starts in observe mode unless you set mode: it counts matches, and never blocks, delays or fails a request. timing, max_wait_ms and on_error take effect in enforce mode. A tag, model or identity that does not exist answers 422.

Authentication: Bearer API key in the Authorization header

Request body

  • namestringrequired

    A name for people.

  • modeenum

    observe counts matches and never blocks, delays or fails a request. enforce blocks matching requests. off stops checking.

    "observe""enforce""off"
    Default: "observe"
  • timingenum

    parallel checks while the model generates and holds the response until the check passes. before_dispatch finishes the check before the request is sent to a model.

    "parallel""before_dispatch"
    Default: "parallel"
  • rulesarray<object>required

    The guardrail matches when any rule matches.

    rules
    • tagstringrequired

      A tag id from GET /v1/tags.

    • thresholdnumber

      The rule matches when the tag's probability for any message in the request is at or above this value.

      Default: 0.5
  • modelsarray | null

    The only model slugs the guardrail covers, compared with the model that serves the request. null does not limit it.

    Default: null
  • exclude_modelsarray | null

    Model slugs the guardrail leaves out, so it covers every other model. null leaves none out. Set models or exclude_models, not both.

    Default: null
  • identity_idsarray | null

    The only identities the guardrail covers. null covers every identity. A request is covered when both its model and its identity are.

    Default: null
  • max_wait_msinteger

    The longest a request waits for the check, in milliseconds: 0 to 5,000 for parallel, 100 to 5,000 for before_dispatch. Defaults to 250 for parallel and 2,000 for before_dispatch.

  • on_errorenumrequired

    What happens when the check does not finish in time, or the request carries content it cannot read. allow lets the request through. block refuses it: 503 gateway_unavailable when the check did not finish, 400 content_filter for content it cannot read.

    "allow""block"

Responses

  • 201

    The created guardrail.

    Response
    • idstringrequired
    • namestringrequired

      A name for people.

    • managedbooleanrequired

      true on a platform guardrail, which is read-only and shows only its name, tags and models.

    • modeenum

      observe counts matches and never blocks, delays or fails a request. enforce blocks matching requests. off stops checking.

      "observe""enforce""off"
    • timingenum

      parallel checks while the model generates and holds the response until the check passes. before_dispatch finishes the check before the request is sent to a model.

      "parallel""before_dispatch"
    • rulesarray<object>required

      The guardrail matches when any rule matches.

      rules
      • tagstringrequired

        A tag id from GET /v1/tags.

      • thresholdnumber

        The rule matches when the tag's probability for any message in the request is at or above this value.

        Default: 0.5
    • modelsarray | nullrequired

      The only model slugs the guardrail covers, compared with the model that serves the request. null does not limit it.

    • exclude_modelsarray | null

      Model slugs the guardrail leaves out, so it covers every other model. null leaves none out. Set models or exclude_models, not both.

    • identity_idsarray | null

      The only identities the guardrail covers. null covers every identity. A request is covered when both its model and its identity are.

    • max_wait_msinteger

      The longest a request waits for the check, in milliseconds.

    • on_errorenum

      What happens when the check does not finish in time, or the request carries content it cannot read. allow lets the request through. block refuses it: 503 gateway_unavailable when the check did not finish, 400 content_filter for content it cannot read.

      "allow""block"
    • created_atstring
    • updated_atstring
  • 401

    Missing, unknown or revoked API key.

  • 403

    The key is not a provisioning key, or the resource is read-only (tag_read_only, guardrail_read_only).

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one.

  • 404

    The resource does not exist or belongs to another organization. An organization without access gets this answer on every route.

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one.

  • 422

    The body failed validation, or it names something that does not exist or cannot be used (unknown_tag, unknown_model, unknown_identity, model_not_allowed).

    Response
    • errorstringrequired

      Human-readable message.

    • codestring

      Stable machine reason, when the route defines one.

Request

curl -X POST 'https://api.experientiallabs.ai/v1/guardrails' \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Keep confidential data off external models",
  "timing": "before_dispatch",
  "rules": [
    {
      "tag": "internalConfidential",
      "threshold": 0.5
    }
  ],
  "exclude_models": [
    "my-local-model"
  ],
  "on_error": "block"
}'

Response

{
  "id": "00000000-0000-4000-8000-000000000011",
  "name": "Keep confidential data off external models",
  "managed": false,
  "mode": "observe",
  "timing": "before_dispatch",
  "rules": [
    {
      "tag": "internalConfidential",
      "threshold": 0.5
    }
  ],
  "models": null,
  "exclude_models": [
    "my-local-model"
  ],
  "identity_ids": null,
  "max_wait_ms": 2000,
  "on_error": "block",
  "created_at": "2026-11-20T00:00:00Z",
  "updated_at": "2026-11-20T00:00:00Z"
}

https://api.experientiallabs.ai/v1/guardrails