---
title: "Patch Guardrail"
method: PATCH
path: "/guardrails/{guardrail_id}"
tags: ["Guardrails"]
---

# Patch Guardrail

`PATCH /guardrails/{guardrail_id}`

Partially update an existing guardrail

👉 [Guardrail docs](https://docs.litellm.ai/docs/proxy/guardrails/quick_start)

This endpoint allows updating specific fields of a guardrail without sending the entire object.
Only the following fields can be updated:
- guardrail_name: The name of the guardrail
- default_on: Whether the guardrail is enabled by default
- guardrail_info: Additional information about the guardrail

Example Request:
```bash
curl -X PATCH "http://localhost:4000/guardrails/123e4567-e89b-12d3-a456-426614174000" \
    -H "Authorization: Bearer <your_api_key>" \
    -H "Content-Type: application/json" \
    -d '{
        "guardrail_name": "updated-name",
        "default_on": true,
        "guardrail_info": {
            "description": "Updated description"
        }
    }'
```

Example Response:
```json
{
    "guardrail_id": "123e4567-e89b-12d3-a456-426614174000",
    "guardrail_name": "updated-name",
    "litellm_params": {
        "guardrail": "bedrock",
        "mode": "pre_call",
        "guardrailIdentifier": "ff6ujrregl1q",
        "guardrailVersion": "DRAFT",
        "default_on": true
    },
    "guardrail_info": {
        "description": "Updated description"
    },
    "created_at": "2023-11-09T12:34:56.789Z",
    "updated_at": "2023-11-09T14:22:33.456Z"
}
```

## Path parameters

- `guardrail_id` string, required

## Request body

- PatchGuardrailRequest
  - `guardrail_name` string, nullable
  - `litellm_params` BaseLitellmParamsInput
    - `patterns` ContentFilterPattern[], nullable — List of patterns (prebuilt or custom regex) to detect
      - `pattern_type` 'prebuilt' | 'regex', required — Type of pattern: 'prebuilt' for predefined patterns or 'regex' for custom
      - `pattern_name` string, nullable — Name of prebuilt pattern (e.g., 'us_ssn', 'credit_card'). Required if pattern_type is 'prebuilt'
      - `pattern` string, nullable — Custom regex pattern. Required if pattern_type is 'regex'
      - `name` string, nullable — Name for this pattern (used in logging and error messages)
      - `action` 'BLOCK' | 'MASK', required — Action to take when content filter detects a match
    - `blocked_words` BlockedWord[], nullable — List of blocked words with individual actions
      - `keyword` string, required — The keyword to block or mask
      - `action` 'BLOCK' | 'MASK', required — Action to take when content filter detects a match
      - `description` string, nullable — Optional description explaining why this keyword is sensitive
    - `blocked_words_file` string, nullable — Path to YAML file containing blocked_words list
    - `categories` ContentFilterCategoryConfig[], nullable — List of prebuilt categories to enable (harmful_*, bias_*)
      - `category` string, required — The category to detect
      - `enabled` boolean — Whether the category is enabled
      - `action` 'BLOCK' | 'MASK', required — The action to take when the category is detected
      - `severity_threshold` 'high' | 'medium' | 'low' — The severity threshold to detect the category
      - `category_file` string, nullable — Optional override. Use your own category file instead of the default one.
    - `severity_threshold` string, nullable — Minimum severity to block (high, medium, low)
    - `pattern_redaction_format` string, nullable — Format string for pattern redaction (use {pattern_name} placeholder)
    - `keyword_redaction_tag` string, nullable — Tag to use for keyword redaction
    - `api_key` string, nullable — API key for the guardrail service
    - `api_base` string, nullable — Base URL for the guardrail service API
    - `experimental_use_latest_role_message_only` boolean, nullable — When True, guardrails only receive the latest message for the relevant role (e.g., newest user input pre-call, newest assistant output post-call)
    - `category_thresholds` LakeraCategoryThresholds
      - `prompt_injection` number
      - `jailbreak` number
    - `detect_secrets_config` object, nullable — Configuration for detect-secrets guardrail
    - `guard_name` string, nullable — Name of the guardrail in guardrails.ai
    - `default_on` boolean, nullable — Whether the guardrail is enabled by default
    - `mask_request_content` boolean, nullable — Will mask request content if guardrail makes any changes
    - `mask_response_content` boolean, nullable — Will mask response content if guardrail makes any changes
    - `pangea_input_recipe` string, nullable — Recipe for input (LLM request)
    - `pangea_output_recipe` string, nullable — Recipe for output (LLM response)
    - `model` string, nullable — Optional field if guardrail requires a 'model' parameter
    - `violation_message_template` string, nullable — Custom message when a guardrail blocks an action. Supports placeholders like {tool_name}, {rule_id}, and {default_message}.
    - `end_session_after_n_fails` integer, nullable — For /v1/realtime sessions: automatically close the session after this many guardrail violations.
    - `on_violation` 'warn' | 'end_session', nullable — For /v1/realtime sessions: 'warn' speaks the violation message and continues; 'end_session' speaks the message and closes the connection.
    - `realtime_violation_message` string, nullable — The message the bot speaks aloud when a /v1/realtime guardrail fires. Falls back to violation_message_template if not set.
    - `template_id` string, nullable — The ID of your Model Armor template
    - `location` string, nullable — Google Cloud location/region (e.g., us-central1)
    - `credentials` string, nullable — Path to Google Cloud credentials JSON file or JSON string
    - `api_endpoint` string, nullable — Optional custom API endpoint for Model Armor
    - `fail_on_error` boolean, nullable — Whether to fail the request if Model Armor encounters an error
    - `additional_provider_specific_params` object, nullable — Additional provider-specific parameters for generic guardrail APIs
    - `unreachable_fallback` 'fail_closed' | 'fail_open' — Behavior when a guardrail endpoint is unreachable due to network errors. NOTE: This is currently only implemented by guardrail='generic_guardrail_api'. 'fail_closed' raises an error (default). 'fail_open' logs a critical error and allows the request to proceed.
    - `extra_headers` string[], nullable — Header names to forward from the client request to the guardrail (e.g. x-request-id). Only these headers' values are sent; others may be omitted or sent as [present]. Used by generic_guardrail_api (similar to MCP extra_headers).
    - `custom_code` string, nullable — Python-like code containing the apply_guardrail function for custom guardrail logic
  - `guardrail_info` object, nullable

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/sea-lion/apis/litellm-api.md) · [All operations](https://skmtc.net/sea-lion/apis/litellm-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/sea-lion/litellm-api/revisions/1e929292ddd5/schema)
