Skip to main content
PATCH
/
guardrails
/
{id}
Update a guardrail
curl --request PATCH \
  --url https://openrouter.ai/api/v1/guardrails/{id} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "description": "Updated description",
  "limit_usd": 75,
  "name": "Updated Guardrail Name",
  "reset_interval": "weekly"
}
'
import requests

url = "https://openrouter.ai/api/v1/guardrails/{id}"

payload = {
    "description": "Updated description",
    "limit_usd": 75,
    "name": "Updated Guardrail Name",
    "reset_interval": "weekly"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'PATCH',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    description: 'Updated description',
    limit_usd: 75,
    name: 'Updated Guardrail Name',
    reset_interval: 'weekly'
  })
};

fetch('https://openrouter.ai/api/v1/guardrails/{id}', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://openrouter.ai/api/v1/guardrails/{id}",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PATCH",
  CURLOPT_POSTFIELDS => json_encode([
    'description' => 'Updated description',
    'limit_usd' => 75,
    'name' => 'Updated Guardrail Name',
    'reset_interval' => 'weekly'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://openrouter.ai/api/v1/guardrails/{id}"

	payload := strings.NewReader("{\n  \"description\": \"Updated description\",\n  \"limit_usd\": 75,\n  \"name\": \"Updated Guardrail Name\",\n  \"reset_interval\": \"weekly\"\n}")

	req, _ := http.NewRequest("PATCH", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.patch("https://openrouter.ai/api/v1/guardrails/{id}")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"description\": \"Updated description\",\n  \"limit_usd\": 75,\n  \"name\": \"Updated Guardrail Name\",\n  \"reset_interval\": \"weekly\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://openrouter.ai/api/v1/guardrails/{id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"description\": \"Updated description\",\n  \"limit_usd\": 75,\n  \"name\": \"Updated Guardrail Name\",\n  \"reset_interval\": \"weekly\"\n}"

response = http.request(request)
puts response.read_body
{
  "data": {
    "allowed_models": null,
    "allowed_providers": [
      "openai"
    ],
    "created_at": "2025-08-24T10:30:00Z",
    "description": "Updated description",
    "enforce_zdr": null,
    "enforce_zdr_anthropic": true,
    "enforce_zdr_google": true,
    "enforce_zdr_openai": true,
    "enforce_zdr_other": true,
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "ignored_models": null,
    "ignored_providers": null,
    "limit_usd": 75,
    "name": "Updated Guardrail Name",
    "reset_interval": "weekly",
    "updated_at": "2025-08-24T16:00:00Z",
    "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"
  }
}
{
  "error": {
    "code": 400,
    "message": "Invalid request parameters"
  }
}
{
  "error": {
    "code": 401,
    "message": "Missing Authentication header"
  }
}
{
  "error": {
    "code": 404,
    "message": "Resource not found"
  }
}
{
  "error": {
    "code": 500,
    "message": "Internal Server Error"
  }
}

Authorizations

Authorization
string
header
required

API key as bearer token in Authorization header

Path Parameters

id
string<uuid>
required

The unique identifier of the guardrail to update

Example:

"550e8400-e29b-41d4-a716-446655440000"

Body

application/json
allowed_models
string[] | null

Array of model identifiers (slug or canonical_slug accepted)

Minimum array length: 1
Example:
["openai/gpt-5.2"]
allowed_providers
string[] | null

New list of allowed provider IDs

Minimum array length: 1
Example:
["openai", "anthropic", "deepseek"]
content_filter_builtins
object[] | null

Builtin content filters to apply. Set to null to remove. The "flag" action is only supported for "regex-prompt-injection"; PII slugs (email, phone, ssn, credit-card, ip-address, person-name, address) accept "block" or "redact" only.

Example:
[
  {
    "action": "block",
    "slug": "regex-prompt-injection"
  }
]
content_filters
object[] | null

Custom regex content filters to apply. Set to null to remove.

Example:

null

description
string | null

New description for the guardrail

Maximum string length: 1000
Example:

"Updated description"

enforce_zdr
boolean | null
deprecated

Deprecated. Use enforce_zdr_anthropic, enforce_zdr_openai, enforce_zdr_google, and enforce_zdr_other instead. When provided, its value is copied into any of those per-provider fields that are not explicitly specified on the request.

Example:

true

enforce_zdr_anthropic
boolean | null

Whether to enforce zero data retention for Anthropic models. Falls back to enforce_zdr when not provided.

Example:

true

enforce_zdr_google
boolean | null

Whether to enforce zero data retention for Google models. Falls back to enforce_zdr when not provided.

Example:

true

enforce_zdr_openai
boolean | null

Whether to enforce zero data retention for OpenAI models. Falls back to enforce_zdr when not provided.

Example:

true

enforce_zdr_other
boolean | null

Whether to enforce zero data retention for models that are not from Anthropic, OpenAI, or Google. Falls back to enforce_zdr when not provided.

Example:

true

ignored_models
string[] | null

Array of model identifiers to exclude from routing (slug or canonical_slug accepted)

Minimum array length: 1
Example:
["openai/gpt-4o-mini"]
ignored_providers
string[] | null

List of provider IDs to exclude from routing

Minimum array length: 1
Example:
["azure"]
limit_usd
number<double> | null

New spending limit in USD

Example:

75

name
string

New name for the guardrail

Required string length: 1 - 200
Example:

"Updated Guardrail Name"

reset_interval
enum<string> | null

Interval at which the limit resets (daily, weekly, monthly)

Available options:
daily,
weekly,
monthly,
null
Example:

"monthly"

Response

Guardrail updated successfully

data
object
required

The updated guardrail

Example:
{
  "allowed_models": null,
  "allowed_providers": ["openai", "anthropic", "google"],
  "content_filter_builtins": [
    {
      "action": "redact",
      "label": "[EMAIL]",
      "slug": "email"
    }
  ],
  "content_filters": null,
  "created_at": "2025-08-24T10:30:00Z",
  "description": "Guardrail for production environment",
  "enforce_zdr": null,
  "enforce_zdr_anthropic": true,
  "enforce_zdr_google": false,
  "enforce_zdr_openai": true,
  "enforce_zdr_other": false,
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "ignored_models": null,
  "ignored_providers": null,
  "limit_usd": 100,
  "name": "Production Guardrail",
  "reset_interval": "monthly",
  "updated_at": "2025-08-24T15:45:00Z",
  "workspace_id": "0df9e665-d932-5740-b2c7-b52af166bc11"
}