Update Project Guardrails
curl --request PUT \
--url https://api.promptguard.co/api/v1/projects/{project_id}/guardrails \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"guardrails": {
"prompt_injection": {
"enabled": true,
"level": "moderate"
},
"pii_detection": {
"enabled": true,
"level": "moderate",
"mode": "redact",
"entities": [
"<string>"
]
},
"toxicity": {
"enabled": true,
"threshold": 0.7,
"categories": [
"<string>"
]
},
"data_exfiltration": {
"enabled": true,
"level": "moderate"
},
"secret_key_detection": {
"enabled": true,
"level": "moderate"
},
"url_filtering": {
"enabled": true
},
"fraud_detection": {
"enabled": true
},
"malware_detection": {
"enabled": true
},
"jailbreak_detection": {
"enabled": true
},
"tool_injection": {
"enabled": true
},
"hallucination": {
"enabled": true,
"action": "metadata",
"block_threshold": 0.6
},
"mcp_security": {
"enabled": false,
"server_allowlist": [
"<string>"
],
"server_blocklist": [
"<string>"
],
"enforce_schema_validation": true,
"max_argument_size_bytes": 10000
}
}
}
'import requests
url = "https://api.promptguard.co/api/v1/projects/{project_id}/guardrails"
payload = { "guardrails": {
"prompt_injection": {
"enabled": True,
"level": "moderate"
},
"pii_detection": {
"enabled": True,
"level": "moderate",
"mode": "redact",
"entities": ["<string>"]
},
"toxicity": {
"enabled": True,
"threshold": 0.7,
"categories": ["<string>"]
},
"data_exfiltration": {
"enabled": True,
"level": "moderate"
},
"secret_key_detection": {
"enabled": True,
"level": "moderate"
},
"url_filtering": { "enabled": True },
"fraud_detection": { "enabled": True },
"malware_detection": { "enabled": True },
"jailbreak_detection": { "enabled": True },
"tool_injection": { "enabled": True },
"hallucination": {
"enabled": True,
"action": "metadata",
"block_threshold": 0.6
},
"mcp_security": {
"enabled": False,
"server_allowlist": ["<string>"],
"server_blocklist": ["<string>"],
"enforce_schema_validation": True,
"max_argument_size_bytes": 10000
}
} }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
guardrails: {
prompt_injection: {enabled: true, level: 'moderate'},
pii_detection: {enabled: true, level: 'moderate', mode: 'redact', entities: ['<string>']},
toxicity: {enabled: true, threshold: 0.7, categories: ['<string>']},
data_exfiltration: {enabled: true, level: 'moderate'},
secret_key_detection: {enabled: true, level: 'moderate'},
url_filtering: {enabled: true},
fraud_detection: {enabled: true},
malware_detection: {enabled: true},
jailbreak_detection: {enabled: true},
tool_injection: {enabled: true},
hallucination: {enabled: true, action: 'metadata', block_threshold: 0.6},
mcp_security: {
enabled: false,
server_allowlist: ['<string>'],
server_blocklist: ['<string>'],
enforce_schema_validation: true,
max_argument_size_bytes: 10000
}
}
})
};
fetch('https://api.promptguard.co/api/v1/projects/{project_id}/guardrails', 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.promptguard.co/api/v1/projects/{project_id}/guardrails",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'guardrails' => [
'prompt_injection' => [
'enabled' => true,
'level' => 'moderate'
],
'pii_detection' => [
'enabled' => true,
'level' => 'moderate',
'mode' => 'redact',
'entities' => [
'<string>'
]
],
'toxicity' => [
'enabled' => true,
'threshold' => 0.7,
'categories' => [
'<string>'
]
],
'data_exfiltration' => [
'enabled' => true,
'level' => 'moderate'
],
'secret_key_detection' => [
'enabled' => true,
'level' => 'moderate'
],
'url_filtering' => [
'enabled' => true
],
'fraud_detection' => [
'enabled' => true
],
'malware_detection' => [
'enabled' => true
],
'jailbreak_detection' => [
'enabled' => true
],
'tool_injection' => [
'enabled' => true
],
'hallucination' => [
'enabled' => true,
'action' => 'metadata',
'block_threshold' => 0.6
],
'mcp_security' => [
'enabled' => false,
'server_allowlist' => [
'<string>'
],
'server_blocklist' => [
'<string>'
],
'enforce_schema_validation' => true,
'max_argument_size_bytes' => 10000
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.promptguard.co/api/v1/projects/{project_id}/guardrails"
payload := strings.NewReader("{\n \"guardrails\": {\n \"prompt_injection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"pii_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\",\n \"mode\": \"redact\",\n \"entities\": [\n \"<string>\"\n ]\n },\n \"toxicity\": {\n \"enabled\": true,\n \"threshold\": 0.7,\n \"categories\": [\n \"<string>\"\n ]\n },\n \"data_exfiltration\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"secret_key_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"url_filtering\": {\n \"enabled\": true\n },\n \"fraud_detection\": {\n \"enabled\": true\n },\n \"malware_detection\": {\n \"enabled\": true\n },\n \"jailbreak_detection\": {\n \"enabled\": true\n },\n \"tool_injection\": {\n \"enabled\": true\n },\n \"hallucination\": {\n \"enabled\": true,\n \"action\": \"metadata\",\n \"block_threshold\": 0.6\n },\n \"mcp_security\": {\n \"enabled\": false,\n \"server_allowlist\": [\n \"<string>\"\n ],\n \"server_blocklist\": [\n \"<string>\"\n ],\n \"enforce_schema_validation\": true,\n \"max_argument_size_bytes\": 10000\n }\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.put("https://api.promptguard.co/api/v1/projects/{project_id}/guardrails")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"guardrails\": {\n \"prompt_injection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"pii_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\",\n \"mode\": \"redact\",\n \"entities\": [\n \"<string>\"\n ]\n },\n \"toxicity\": {\n \"enabled\": true,\n \"threshold\": 0.7,\n \"categories\": [\n \"<string>\"\n ]\n },\n \"data_exfiltration\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"secret_key_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"url_filtering\": {\n \"enabled\": true\n },\n \"fraud_detection\": {\n \"enabled\": true\n },\n \"malware_detection\": {\n \"enabled\": true\n },\n \"jailbreak_detection\": {\n \"enabled\": true\n },\n \"tool_injection\": {\n \"enabled\": true\n },\n \"hallucination\": {\n \"enabled\": true,\n \"action\": \"metadata\",\n \"block_threshold\": 0.6\n },\n \"mcp_security\": {\n \"enabled\": false,\n \"server_allowlist\": [\n \"<string>\"\n ],\n \"server_blocklist\": [\n \"<string>\"\n ],\n \"enforce_schema_validation\": true,\n \"max_argument_size_bytes\": 10000\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.promptguard.co/api/v1/projects/{project_id}/guardrails")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"guardrails\": {\n \"prompt_injection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"pii_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\",\n \"mode\": \"redact\",\n \"entities\": [\n \"<string>\"\n ]\n },\n \"toxicity\": {\n \"enabled\": true,\n \"threshold\": 0.7,\n \"categories\": [\n \"<string>\"\n ]\n },\n \"data_exfiltration\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"secret_key_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"url_filtering\": {\n \"enabled\": true\n },\n \"fraud_detection\": {\n \"enabled\": true\n },\n \"malware_detection\": {\n \"enabled\": true\n },\n \"jailbreak_detection\": {\n \"enabled\": true\n },\n \"tool_injection\": {\n \"enabled\": true\n },\n \"hallucination\": {\n \"enabled\": true,\n \"action\": \"metadata\",\n \"block_threshold\": 0.6\n },\n \"mcp_security\": {\n \"enabled\": false,\n \"server_allowlist\": [\n \"<string>\"\n ],\n \"server_blocklist\": [\n \"<string>\"\n ],\n \"enforce_schema_validation\": true,\n \"max_argument_size_bytes\": 10000\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"guardrails": {
"prompt_injection": {
"enabled": true,
"level": "moderate"
},
"pii_detection": {
"enabled": true,
"level": "moderate",
"mode": "redact",
"entities": [
"<string>"
]
},
"toxicity": {
"enabled": true,
"threshold": 0.7,
"categories": [
"<string>"
]
},
"data_exfiltration": {
"enabled": true,
"level": "moderate"
},
"secret_key_detection": {
"enabled": true,
"level": "moderate"
},
"url_filtering": {
"enabled": true
},
"fraud_detection": {
"enabled": true
},
"malware_detection": {
"enabled": true
},
"jailbreak_detection": {
"enabled": true
},
"tool_injection": {
"enabled": true
},
"hallucination": {
"enabled": true,
"action": "metadata",
"block_threshold": 0.6
},
"mcp_security": {
"enabled": false,
"server_allowlist": [
"<string>"
],
"server_blocklist": [
"<string>"
],
"enforce_schema_validation": true,
"max_argument_size_bytes": 10000
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Update Project Guardrails
Replace the guardrail config for one of the caller’s projects.
PUT
/
api
/
v1
/
projects
/
{project_id}
/
guardrails
Update Project Guardrails
curl --request PUT \
--url https://api.promptguard.co/api/v1/projects/{project_id}/guardrails \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"guardrails": {
"prompt_injection": {
"enabled": true,
"level": "moderate"
},
"pii_detection": {
"enabled": true,
"level": "moderate",
"mode": "redact",
"entities": [
"<string>"
]
},
"toxicity": {
"enabled": true,
"threshold": 0.7,
"categories": [
"<string>"
]
},
"data_exfiltration": {
"enabled": true,
"level": "moderate"
},
"secret_key_detection": {
"enabled": true,
"level": "moderate"
},
"url_filtering": {
"enabled": true
},
"fraud_detection": {
"enabled": true
},
"malware_detection": {
"enabled": true
},
"jailbreak_detection": {
"enabled": true
},
"tool_injection": {
"enabled": true
},
"hallucination": {
"enabled": true,
"action": "metadata",
"block_threshold": 0.6
},
"mcp_security": {
"enabled": false,
"server_allowlist": [
"<string>"
],
"server_blocklist": [
"<string>"
],
"enforce_schema_validation": true,
"max_argument_size_bytes": 10000
}
}
}
'import requests
url = "https://api.promptguard.co/api/v1/projects/{project_id}/guardrails"
payload = { "guardrails": {
"prompt_injection": {
"enabled": True,
"level": "moderate"
},
"pii_detection": {
"enabled": True,
"level": "moderate",
"mode": "redact",
"entities": ["<string>"]
},
"toxicity": {
"enabled": True,
"threshold": 0.7,
"categories": ["<string>"]
},
"data_exfiltration": {
"enabled": True,
"level": "moderate"
},
"secret_key_detection": {
"enabled": True,
"level": "moderate"
},
"url_filtering": { "enabled": True },
"fraud_detection": { "enabled": True },
"malware_detection": { "enabled": True },
"jailbreak_detection": { "enabled": True },
"tool_injection": { "enabled": True },
"hallucination": {
"enabled": True,
"action": "metadata",
"block_threshold": 0.6
},
"mcp_security": {
"enabled": False,
"server_allowlist": ["<string>"],
"server_blocklist": ["<string>"],
"enforce_schema_validation": True,
"max_argument_size_bytes": 10000
}
} }
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
guardrails: {
prompt_injection: {enabled: true, level: 'moderate'},
pii_detection: {enabled: true, level: 'moderate', mode: 'redact', entities: ['<string>']},
toxicity: {enabled: true, threshold: 0.7, categories: ['<string>']},
data_exfiltration: {enabled: true, level: 'moderate'},
secret_key_detection: {enabled: true, level: 'moderate'},
url_filtering: {enabled: true},
fraud_detection: {enabled: true},
malware_detection: {enabled: true},
jailbreak_detection: {enabled: true},
tool_injection: {enabled: true},
hallucination: {enabled: true, action: 'metadata', block_threshold: 0.6},
mcp_security: {
enabled: false,
server_allowlist: ['<string>'],
server_blocklist: ['<string>'],
enforce_schema_validation: true,
max_argument_size_bytes: 10000
}
}
})
};
fetch('https://api.promptguard.co/api/v1/projects/{project_id}/guardrails', 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.promptguard.co/api/v1/projects/{project_id}/guardrails",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'guardrails' => [
'prompt_injection' => [
'enabled' => true,
'level' => 'moderate'
],
'pii_detection' => [
'enabled' => true,
'level' => 'moderate',
'mode' => 'redact',
'entities' => [
'<string>'
]
],
'toxicity' => [
'enabled' => true,
'threshold' => 0.7,
'categories' => [
'<string>'
]
],
'data_exfiltration' => [
'enabled' => true,
'level' => 'moderate'
],
'secret_key_detection' => [
'enabled' => true,
'level' => 'moderate'
],
'url_filtering' => [
'enabled' => true
],
'fraud_detection' => [
'enabled' => true
],
'malware_detection' => [
'enabled' => true
],
'jailbreak_detection' => [
'enabled' => true
],
'tool_injection' => [
'enabled' => true
],
'hallucination' => [
'enabled' => true,
'action' => 'metadata',
'block_threshold' => 0.6
],
'mcp_security' => [
'enabled' => false,
'server_allowlist' => [
'<string>'
],
'server_blocklist' => [
'<string>'
],
'enforce_schema_validation' => true,
'max_argument_size_bytes' => 10000
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.promptguard.co/api/v1/projects/{project_id}/guardrails"
payload := strings.NewReader("{\n \"guardrails\": {\n \"prompt_injection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"pii_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\",\n \"mode\": \"redact\",\n \"entities\": [\n \"<string>\"\n ]\n },\n \"toxicity\": {\n \"enabled\": true,\n \"threshold\": 0.7,\n \"categories\": [\n \"<string>\"\n ]\n },\n \"data_exfiltration\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"secret_key_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"url_filtering\": {\n \"enabled\": true\n },\n \"fraud_detection\": {\n \"enabled\": true\n },\n \"malware_detection\": {\n \"enabled\": true\n },\n \"jailbreak_detection\": {\n \"enabled\": true\n },\n \"tool_injection\": {\n \"enabled\": true\n },\n \"hallucination\": {\n \"enabled\": true,\n \"action\": \"metadata\",\n \"block_threshold\": 0.6\n },\n \"mcp_security\": {\n \"enabled\": false,\n \"server_allowlist\": [\n \"<string>\"\n ],\n \"server_blocklist\": [\n \"<string>\"\n ],\n \"enforce_schema_validation\": true,\n \"max_argument_size_bytes\": 10000\n }\n }\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.put("https://api.promptguard.co/api/v1/projects/{project_id}/guardrails")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"guardrails\": {\n \"prompt_injection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"pii_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\",\n \"mode\": \"redact\",\n \"entities\": [\n \"<string>\"\n ]\n },\n \"toxicity\": {\n \"enabled\": true,\n \"threshold\": 0.7,\n \"categories\": [\n \"<string>\"\n ]\n },\n \"data_exfiltration\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"secret_key_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"url_filtering\": {\n \"enabled\": true\n },\n \"fraud_detection\": {\n \"enabled\": true\n },\n \"malware_detection\": {\n \"enabled\": true\n },\n \"jailbreak_detection\": {\n \"enabled\": true\n },\n \"tool_injection\": {\n \"enabled\": true\n },\n \"hallucination\": {\n \"enabled\": true,\n \"action\": \"metadata\",\n \"block_threshold\": 0.6\n },\n \"mcp_security\": {\n \"enabled\": false,\n \"server_allowlist\": [\n \"<string>\"\n ],\n \"server_blocklist\": [\n \"<string>\"\n ],\n \"enforce_schema_validation\": true,\n \"max_argument_size_bytes\": 10000\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.promptguard.co/api/v1/projects/{project_id}/guardrails")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"guardrails\": {\n \"prompt_injection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"pii_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\",\n \"mode\": \"redact\",\n \"entities\": [\n \"<string>\"\n ]\n },\n \"toxicity\": {\n \"enabled\": true,\n \"threshold\": 0.7,\n \"categories\": [\n \"<string>\"\n ]\n },\n \"data_exfiltration\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"secret_key_detection\": {\n \"enabled\": true,\n \"level\": \"moderate\"\n },\n \"url_filtering\": {\n \"enabled\": true\n },\n \"fraud_detection\": {\n \"enabled\": true\n },\n \"malware_detection\": {\n \"enabled\": true\n },\n \"jailbreak_detection\": {\n \"enabled\": true\n },\n \"tool_injection\": {\n \"enabled\": true\n },\n \"hallucination\": {\n \"enabled\": true,\n \"action\": \"metadata\",\n \"block_threshold\": 0.6\n },\n \"mcp_security\": {\n \"enabled\": false,\n \"server_allowlist\": [\n \"<string>\"\n ],\n \"server_blocklist\": [\n \"<string>\"\n ],\n \"enforce_schema_validation\": true,\n \"max_argument_size_bytes\": 10000\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"guardrails": {
"prompt_injection": {
"enabled": true,
"level": "moderate"
},
"pii_detection": {
"enabled": true,
"level": "moderate",
"mode": "redact",
"entities": [
"<string>"
]
},
"toxicity": {
"enabled": true,
"threshold": 0.7,
"categories": [
"<string>"
]
},
"data_exfiltration": {
"enabled": true,
"level": "moderate"
},
"secret_key_detection": {
"enabled": true,
"level": "moderate"
},
"url_filtering": {
"enabled": true
},
"fraud_detection": {
"enabled": true
},
"malware_detection": {
"enabled": true
},
"jailbreak_detection": {
"enabled": true
},
"tool_injection": {
"enabled": true
},
"hallucination": {
"enabled": true,
"action": "metadata",
"block_threshold": 0.6
},
"mcp_security": {
"enabled": false,
"server_allowlist": [
"<string>"
],
"server_blocklist": [
"<string>"
],
"enforce_schema_validation": true,
"max_argument_size_bytes": 10000
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Authorizations
PromptGuard API key for developer endpoints. Keys start with pg_live_ and are created in the dashboard.
Path Parameters
Body
application/json
Full per-guardrail configuration for a project.
Show child attributes
Show child attributes
Response
Successful Response
Full per-guardrail configuration for a project.
Show child attributes
Show child attributes
⌘I