Update a guardrail
Changes a guardrail’s name, modes, always_on, or settings. settings is replaced whole, secrets included. The type cannot change. The instance must be ready; otherwise the request answers 409.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const AgentGatewayGuardrail = await client.agentGateways.guardrails.update('instance_id', 'guardrail_id', {
name: 'name',
});
console.log(AgentGatewayGuardrail.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
agent_gateway_guardrail = client.agent_gateways.guardrails.update(
instance_id="instance_id",
guardrail_id="guardrail_id",
name="name",
)
print(agent_gateway_guardrail.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
guardrail, err := client.AgentGateways.Guardrails.Update(
context.TODO(),
"instance_id",
"guardrail_id",
telnyx.AgentGatewayGuardrailUpdateParams{
Name: telnyx.String("name"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", guardrail.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.agentGateways.guardrails.GuardrailUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
GuardrailUpdateParams params = GuardrailUpdateParams.builder()
.name("name")
.build();
var response = client.agentGateways().guardrails().update("instance_id", "guardrail_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
agent_gateway_guardrail = telnyx.agent_gateways.guardrails.update("instance_id", "guardrail_id", name: "name")
puts(agent_gateway_guardrail)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$agent_gateway_guardrail = $client->agentGateways->guardrails->update(
'instance_id',
'guardrail_id',
name: 'name',
);
var_dump($agent_gateway_guardrail);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx agent-gateways:guardrails update \
--api-key 'My API Key' \
--instance-id 32ce035d-3165-4031-b1a7-a7c0c259590a \
--guardrail-id 9645e556-6532-4341-8cab-21b58cdef529 \
--name namecurl --request PATCH \
--url https://api.telnyx.com/v2/agent_gateways/{instance_id}/guardrails/{guardrail_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"always_on": true
}
'{
"data": {
"id": "9645e556-6532-4341-8cab-21b58cdef529",
"name": "mask-pii",
"modes": [
"before_request"
],
"always_on": true,
"type": "content_filter",
"settings": {
"patterns": [
{
"name": "us_ssn",
"action": "mask"
},
{
"name": "email",
"action": "mask"
}
],
"regexes": [],
"keywords": [],
"categories": []
},
"created_at": "2026-10-28T17:07:48.905000Z",
"updated_at": "2026-10-28T17:07:48.905000Z"
}
}{
"errors": [
{
"code": "10012",
"title": "Duplicate resource",
"detail": "Resource is a duplicate.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10012"
},
"source": {
"pointer": "/name"
}
}
]
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "The required authentication headers were either invalid or not included in the request.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10009"
}
}
]
}{
"errors": [
{
"code": "10005",
"title": "Resource not found",
"detail": "The requested resource or URL could not be found.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10005"
}
}
]
}{
"errors": [
{
"code": "99901",
"title": "Instance not ready",
"detail": "The instance is not ready; its engine is not running."
}
]
}{
"errors": [
{
"code": "10027",
"title": "Unprocessable Entity",
"detail": "The type does not run in one of these modes.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10027"
},
"source": {
"pointer": "/modes"
}
}
]
}{
"errors": [
{
"code": "99903",
"title": "Engine unavailable",
"detail": "The instance's engine did not answer; try again shortly."
}
]
}Authorizations
Telnyx API key
Path Parameters
The Agent Gateway's id.
The guardrail's id.
Body
The fields to change. settings is replaced whole, secrets included.
A name, unique on the instance. A request names it in its guardrails field.
^[A-Za-z0-9_.-]{1,100}$When the guardrail runs. Each type runs in some modes only.
1before_request, during_request, after_request, logging_only, before_tool_request, during_tool_request, after_tool_request true runs the guardrail on every request, and a request cannot turn it off. false runs it on the requests that name it.
The type's settings. content_filter: patterns (prebuilt patterns by name, such as us_ssn or email), regexes, keywords, and categories (such as prompt_injection), each with an action of block or mask. tool_permission: rules (id, tool_name, tool_type, decision, argument_patterns), a default decision, and on_denied (block or rewrite). model_judge: a model on the instance and weighted criteria (name, description, weight, the weights summing to 100). custom_code: code defining apply_guardrail(inputs, request_data, input_type). lakera: api_key, project_id, api_base. presidio: analyzer_url, anonymizer_url, entities (entity name to block or mask), language. bedrock: guardrail_id, version, region, and access_key_id with secret_access_key, or role_name. azure_content_safety: api_key, endpoint, severity (0 to 7). Provider secrets are write-only.
Response
The updated guardrail
Show child attributes
Show child attributes
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const AgentGatewayGuardrail = await client.agentGateways.guardrails.update('instance_id', 'guardrail_id', {
name: 'name',
});
console.log(AgentGatewayGuardrail.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
agent_gateway_guardrail = client.agent_gateways.guardrails.update(
instance_id="instance_id",
guardrail_id="guardrail_id",
name="name",
)
print(agent_gateway_guardrail.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
guardrail, err := client.AgentGateways.Guardrails.Update(
context.TODO(),
"instance_id",
"guardrail_id",
telnyx.AgentGatewayGuardrailUpdateParams{
Name: telnyx.String("name"),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", guardrail.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.agentGateways.guardrails.GuardrailUpdateParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
GuardrailUpdateParams params = GuardrailUpdateParams.builder()
.name("name")
.build();
var response = client.agentGateways().guardrails().update("instance_id", "guardrail_id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
agent_gateway_guardrail = telnyx.agent_gateways.guardrails.update("instance_id", "guardrail_id", name: "name")
puts(agent_gateway_guardrail)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$agent_gateway_guardrail = $client->agentGateways->guardrails->update(
'instance_id',
'guardrail_id',
name: 'name',
);
var_dump($agent_gateway_guardrail);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx agent-gateways:guardrails update \
--api-key 'My API Key' \
--instance-id 32ce035d-3165-4031-b1a7-a7c0c259590a \
--guardrail-id 9645e556-6532-4341-8cab-21b58cdef529 \
--name namecurl --request PATCH \
--url https://api.telnyx.com/v2/agent_gateways/{instance_id}/guardrails/{guardrail_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"always_on": true
}
'{
"data": {
"id": "9645e556-6532-4341-8cab-21b58cdef529",
"name": "mask-pii",
"modes": [
"before_request"
],
"always_on": true,
"type": "content_filter",
"settings": {
"patterns": [
{
"name": "us_ssn",
"action": "mask"
},
{
"name": "email",
"action": "mask"
}
],
"regexes": [],
"keywords": [],
"categories": []
},
"created_at": "2026-10-28T17:07:48.905000Z",
"updated_at": "2026-10-28T17:07:48.905000Z"
}
}{
"errors": [
{
"code": "10012",
"title": "Duplicate resource",
"detail": "Resource is a duplicate.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10012"
},
"source": {
"pointer": "/name"
}
}
]
}{
"errors": [
{
"code": "10009",
"title": "Authentication failed",
"detail": "The required authentication headers were either invalid or not included in the request.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10009"
}
}
]
}{
"errors": [
{
"code": "10005",
"title": "Resource not found",
"detail": "The requested resource or URL could not be found.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10005"
}
}
]
}{
"errors": [
{
"code": "99901",
"title": "Instance not ready",
"detail": "The instance is not ready; its engine is not running."
}
]
}{
"errors": [
{
"code": "10027",
"title": "Unprocessable Entity",
"detail": "The type does not run in one of these modes.",
"meta": {
"url": "https://developers.telnyx.com/docs/overview/errors/10027"
},
"source": {
"pointer": "/modes"
}
}
]
}{
"errors": [
{
"code": "99903",
"title": "Engine unavailable",
"detail": "The instance's engine did not answer; try again shortly."
}
]
}