# Guardrail

> > This page is auto-generated from the formations OpenAPI spec.
> Do not edit manually — run `pnpm generate-formations-resource-docs` to regenerate.

# Guardrail

> This page is auto-generated from the formations OpenAPI spec.
> Do not edit manually — run `pnpm generate-formations-resource-docs` to regenerate.

Creates a guardrail — an action-class document (`class`/`guard`) that gates tool-call autonomy. Attach it to a tool or agent via that resource's `guardrail_ids` (a `{ "ref": … }` to this resource in the same template resolves to its physical id at deploy time). Mirrors the guardrails REST contract; `class`/`default_class`/`guard`/`escalate` are flattened here from the REST API's single `document` object.

## Syntax

```yaml
type: guardrail
properties:
  name: String
  description: String
  class: Any
  default_class: String
  guard: Object
  escalate: Boolean
  context_tool_id: String
  context_mode: String
```

## Output

The physical resource ID is the **public ID** of the created resource. Reference it from other resources with a `ref` expression:

```yaml
      some_field:
        ref: MyGuardrail
```

## Properties

**`name`**

Human-readable name

_Required_: Yes
_Type_: String

---

**`description`**

Optional description

_Required_: No
_Type_: String
_Nullable_: Yes

---

**`class`**

A class literal (`A` / `B` / `C` / `D`) or a JSON Logic expression returning one. An invalid result resolves to `default_class`.

_Required_: Yes
_Type_: Any

---

**`default_class`**

Applied when the `class` expression returns anything other than a valid class. Defaults to `C` (fail-closed).

_Required_: No
_Type_: String
_Allowed values_: `A`, `B`, `C`, `D`

---

**`guard`**

A single JSON Logic expression; when the call classifies as `B` it executes only if this evaluates truthy.

_Required_: No
_Type_: Object
_Nullable_: Yes

---

**`escalate`**

When true, a passing guard still files an approval item.

_Required_: No
_Type_: Boolean
_Nullable_: Yes

---

**`context_tool_id`**

Optional tool the platform calls at evaluation time to fetch fresh guardrail context.

_Required_: No
_Type_: String
_Nullable_: Yes

---

**`context_mode`**

How tool-fetched context combines with the caller-supplied context.

_Required_: No
_Type_: String
_Nullable_: Yes
_Allowed values_: `merge`, `replace`, `null`

---
