> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tavus.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Legacy guardrail sets

> The legacy guardrails set API is still supported for backwards compatibility. New integrations should use individually addressable guardrails.

<Note>
  New integrations should use the [Guardrails API](/api-reference/guardrails/create-guardrails). The endpoints documented below remain available for accounts that still rely on the legacy set shape.
</Note>

The legacy API groups multiple guardrails together into a named **set** that is attached to a PAL via `guardrails_id`. The endpoints on this page use the same paths as the new individual API - the server discriminates between the two surfaces based on the request body shape (for `POST`) or the UUID type (for `GET`, `PATCH`, `DELETE`).

## Create guardrail set

`POST /v2/guardrails`

Send a payload with `name` and `data` (an array of guardrail items) to create a legacy set. If you send `guardrail_name` at the top level instead, the request is routed to [Create Guardrails](/api-reference/guardrails/create-guardrails) and creates an individual guardrail.

```sh theme={null}
curl --request POST \
  --url https://tavusapi.com/v2/guardrails \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '{
    "name": "Healthcare Compliance Guardrails",
    "data": [
      {
        "guardrail_name": "no_medical_advice",
        "guardrail_prompt": "Never provide medical advice outside approved guidelines.",
        "modality": "verbal",
        "callback_url": "https://your-server.com/guardrails-webhook"
      },
      {
        "guardrail_name": "check_if_alone",
        "guardrail_prompt": "Confirm throughout the call that the participant is alone.",
        "modality": "visual"
      }
    ]
  }'
```

**Response**

```json theme={null}
{
  "guardrails_id": "g12345",
  "guardrails_name": "Healthcare Compliance Guardrails",
  "status": "active",
  "created_at": "2024-01-15T10:30:00Z"
}
```

Attach the returned `guardrails_id` to a PAL via `guardrails_id` on [Create PAL](/api-reference/pals/create-pal).

## List guardrail sets

`GET /v2/guardrails?legacy=true`

`legacy=true` is the default, so omitting the parameter returns the legacy set list. Pass `legacy=false` to get a flat list of [individual guardrails](/api-reference/guardrails/list-guardrails) instead.

```sh theme={null}
curl --request GET \
  --url 'https://tavusapi.com/v2/guardrails?legacy=true' \
  --header 'x-api-key: <api-key>'
```

## Get guardrail set

`GET /v2/guardrails/{guardrails_id}`

When the supplied UUID is a legacy set UUID, the response returns the set shape:

```json theme={null}
{
  "uuid": "g12345",
  "name": "Healthcare Compliance Guardrails",
  "data": [
    {
      "guardrail_name": "no_medical_advice",
      "guardrail_prompt": "Never provide medical advice outside approved guidelines.",
      "modality": "verbal",
      "callback_url": "https://your-server.com/guardrails-webhook"
    }
  ]
}
```

## Patch guardrail set

`PATCH /v2/guardrails/{guardrails_id}`

Send a [JSON Patch](https://jsonpatch.com/) array against the set document. Mirror UUIDs are preserved across field-level edits, moves, and removes; a whole-object `replace /data/<i>` rotates the underlying individual UUID.

```sh theme={null}
curl --request PATCH \
  --url https://tavusapi.com/v2/guardrails/g12345 \
  --header 'Content-Type: application/json' \
  --header 'x-api-key: <api-key>' \
  --data '[
    { "op": "replace", "path": "/data/0/guardrail_prompt", "value": "Updated prompt." }
  ]'
```

## Delete guardrail set

`DELETE /v2/guardrails/{guardrails_id}`

Deletes the set and all of its mirrored individual items. PALs referencing the set via `guardrails_id` are scrubbed automatically.

```sh theme={null}
curl --request DELETE \
  --url https://tavusapi.com/v2/guardrails/g12345 \
  --header 'x-api-key: <api-key>'
```

## Migrating to individual guardrails

The two surfaces interoperate - every guardrail item inside a legacy set is also addressable as an individual guardrail by its own `uuid`. To move off the legacy set shape:

1. Stop creating new sets. Use [Create Guardrails](/api-reference/guardrails/create-guardrails) per guardrail.
2. Attach guardrails to PALs via `guardrail_ids` (explicit list) or `guardrail_tags` (tag-based, dynamic) on [Create PAL](/api-reference/pals/create-pal) instead of `guardrails_id`.
3. Existing sets continue to work - PALs can mix `guardrails_id`, `guardrail_ids`, and `guardrail_tags` during the transition.
