Update a Firewall Policy
Change a policy’s rules or its action — including switching it to block.
PATCH
/
ai-gateway
/
firewall-policies
/
{id}
Update a prompt-firewall policy
curl --request PATCH \
--url https://api.knoxcall.com/v1/ai-gateway/firewall-policies/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"heuristics": [
{
"name": "no_competitor_mentions",
"pattern": "CompetitorAI",
"flags": "i"
}
],
"canary_enabled": true
}
'import requests
url = "https://api.knoxcall.com/v1/ai-gateway/firewall-policies/{id}"
payload = {
"heuristics": [
{
"name": "no_competitor_mentions",
"pattern": "CompetitorAI",
"flags": "i"
}
],
"canary_enabled": True
}
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({
heuristics: [{name: 'no_competitor_mentions', pattern: 'CompetitorAI', flags: 'i'}],
canary_enabled: true
})
};
fetch('https://api.knoxcall.com/v1/ai-gateway/firewall-policies/{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://api.knoxcall.com/v1/ai-gateway/firewall-policies/{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([
'heuristics' => [
[
'name' => 'no_competitor_mentions',
'pattern' => 'CompetitorAI',
'flags' => 'i'
]
],
'canary_enabled' => true
]),
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://api.knoxcall.com/v1/ai-gateway/firewall-policies/{id}"
payload := strings.NewReader("{\n \"heuristics\": [\n {\n \"name\": \"no_competitor_mentions\",\n \"pattern\": \"CompetitorAI\",\n \"flags\": \"i\"\n }\n ],\n \"canary_enabled\": true\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://api.knoxcall.com/v1/ai-gateway/firewall-policies/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"heuristics\": [\n {\n \"name\": \"no_competitor_mentions\",\n \"pattern\": \"CompetitorAI\",\n \"flags\": \"i\"\n }\n ],\n \"canary_enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.knoxcall.com/v1/ai-gateway/firewall-policies/{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 \"heuristics\": [\n {\n \"name\": \"no_competitor_mentions\",\n \"pattern\": \"CompetitorAI\",\n \"flags\": \"i\"\n }\n ],\n \"canary_enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"version": 123,
"heuristics": [
{
"name": "no_competitor_mentions",
"kind": "regex",
"pattern": "CompetitorAI",
"flags": "i"
}
],
"canary_enabled": true,
"action": "block",
"created_at": "2023-11-07T05:31:56Z"
},
"meta": {
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}Partial update. Omitted fields are left as they are.
Changing
action to block takes effect on every agent that references this
policy, on their next request. Dry-run the rule set with
Test firewall rules first —
under block, a rule that will not compile stops being a warning and becomes a
503 on live traffic.
Requires the update capability on ai_gateway. See the control-plane overview for authentication, the {data, meta} envelope, pagination and error types.Authorizations
OAuth2BearerAuthApiKeyAuth
OAuth 2.1 authentication — recommended for new integrations. Access tokens
(kc_ prefix) are minted at the root-host token endpoint
https://api.knoxcall.com/oauth/token and passed as Authorization: Bearer <access_token>.
Public clients must use PKCE with the authorization_code grant; confidential
clients may use client_credentials. The first-party SDKs and the
knoxcall login CLI handle token minting, caching, refresh, and DPoP for you.
Path Parameters
Body
application/json
Was this page helpful?
⌘I
Update a prompt-firewall policy
curl --request PATCH \
--url https://api.knoxcall.com/v1/ai-gateway/firewall-policies/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"heuristics": [
{
"name": "no_competitor_mentions",
"pattern": "CompetitorAI",
"flags": "i"
}
],
"canary_enabled": true
}
'import requests
url = "https://api.knoxcall.com/v1/ai-gateway/firewall-policies/{id}"
payload = {
"heuristics": [
{
"name": "no_competitor_mentions",
"pattern": "CompetitorAI",
"flags": "i"
}
],
"canary_enabled": True
}
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({
heuristics: [{name: 'no_competitor_mentions', pattern: 'CompetitorAI', flags: 'i'}],
canary_enabled: true
})
};
fetch('https://api.knoxcall.com/v1/ai-gateway/firewall-policies/{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://api.knoxcall.com/v1/ai-gateway/firewall-policies/{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([
'heuristics' => [
[
'name' => 'no_competitor_mentions',
'pattern' => 'CompetitorAI',
'flags' => 'i'
]
],
'canary_enabled' => true
]),
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://api.knoxcall.com/v1/ai-gateway/firewall-policies/{id}"
payload := strings.NewReader("{\n \"heuristics\": [\n {\n \"name\": \"no_competitor_mentions\",\n \"pattern\": \"CompetitorAI\",\n \"flags\": \"i\"\n }\n ],\n \"canary_enabled\": true\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://api.knoxcall.com/v1/ai-gateway/firewall-policies/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"heuristics\": [\n {\n \"name\": \"no_competitor_mentions\",\n \"pattern\": \"CompetitorAI\",\n \"flags\": \"i\"\n }\n ],\n \"canary_enabled\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.knoxcall.com/v1/ai-gateway/firewall-policies/{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 \"heuristics\": [\n {\n \"name\": \"no_competitor_mentions\",\n \"pattern\": \"CompetitorAI\",\n \"flags\": \"i\"\n }\n ],\n \"canary_enabled\": true\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"tenant_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "<string>",
"version": 123,
"heuristics": [
{
"name": "no_competitor_mentions",
"kind": "regex",
"pattern": "CompetitorAI",
"flags": "i"
}
],
"canary_enabled": true,
"action": "block",
"created_at": "2023-11-07T05:31:56Z"
},
"meta": {
"request_id": "550e8400-e29b-41d4-a716-446655440000"
}
}