curl --request POST \
--url https://api.enkryptai.com/guardrails/guardrail/detect \
--header 'Content-Type: application/json' \
--header 'X-Enkrypt-Guardrail: <x-enkrypt-guardrail>' \
--header 'X-Enkrypt-Mode: <x-enkrypt-mode>' \
--header 'apikey: <api-key>' \
--data '
{
"text": "<string>",
"user_metadata": {
"request_id": "abc-123",
"source": "mobile-app"
}
}
'import requests
url = "https://api.enkryptai.com/guardrails/guardrail/detect"
payload = {
"text": "<string>",
"user_metadata": {
"request_id": "abc-123",
"source": "mobile-app"
}
}
headers = {
"X-Enkrypt-Guardrail": "<x-enkrypt-guardrail>",
"X-Enkrypt-Mode": "<x-enkrypt-mode>",
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Enkrypt-Guardrail': '<x-enkrypt-guardrail>',
'X-Enkrypt-Mode': '<x-enkrypt-mode>',
apikey: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({text: '<string>', user_metadata: {request_id: 'abc-123', source: 'mobile-app'}})
};
fetch('https://api.enkryptai.com/guardrails/guardrail/detect', 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.enkryptai.com/guardrails/guardrail/detect",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'user_metadata' => [
'request_id' => 'abc-123',
'source' => 'mobile-app'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Enkrypt-Guardrail: <x-enkrypt-guardrail>",
"X-Enkrypt-Mode: <x-enkrypt-mode>",
"apikey: <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.enkryptai.com/guardrails/guardrail/detect"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"user_metadata\": {\n \"request_id\": \"abc-123\",\n \"source\": \"mobile-app\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Enkrypt-Guardrail", "<x-enkrypt-guardrail>")
req.Header.Add("X-Enkrypt-Mode", "<x-enkrypt-mode>")
req.Header.Add("apikey", "<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.post("https://api.enkryptai.com/guardrails/guardrail/detect")
.header("X-Enkrypt-Guardrail", "<x-enkrypt-guardrail>")
.header("X-Enkrypt-Mode", "<x-enkrypt-mode>")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"user_metadata\": {\n \"request_id\": \"abc-123\",\n \"source\": \"mobile-app\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.enkryptai.com/guardrails/guardrail/detect")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Enkrypt-Guardrail"] = '<x-enkrypt-guardrail>'
request["X-Enkrypt-Mode"] = '<x-enkrypt-mode>'
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"user_metadata\": {\n \"request_id\": \"abc-123\",\n \"source\": \"mobile-app\"\n }\n}"
response = http.request(request)
puts response.read_body{
"summary": {
"injection_attack": 1,
"policy_violation": 1
},
"details": {
"injection_attack": {
"safe": 0.001584,
"attack": 0.998416,
"p_injection": "0.998416",
"p_jailbreak": "0.103658",
"detected_attacks": [
"injection"
],
"explanation": "Prefaces the request with an instruction to disregard prior directives before asking for another customer's record."
},
"policy_violation": {
"violating_policy": "Rule 1: Both user queries and assistant responses must not contain disclosure of personal or sensitive data about an identifiable individual OTHER THAN the person communicating in the chunk.",
"explanation": "Discloses personal and sensitive data (SSN, balance) about a named third party (John Q. Public).",
"violated_rules": [
{
"id": "priv-1",
"display_text": "No disclosing others' personal data",
"text": "Both user queries and assistant responses must not contain disclosure of personal or sensitive data about an identifiable individual OTHER THAN the person communicating in the chunk.",
"risk_category": "privacy_data_protection",
"applicability": "user_assistant",
"severity": "high",
"frameworks": [
"hipaa",
"gdpr"
],
"mappings": [
{
"framework": "gdpr",
"clause": "Art. 9 — Special categories of personal data"
}
],
"source": "document/catalog",
"suggested": false
}
],
"most_unsafe_content": "the full account record for another customer, John Q. Public: SSN 123-45-6789, balance $84,220"
}
},
"result_message": "Your message does not comply with our usage policies. Please revise and try again."
}Detect with Guardrail
Detect threats in text using a saved guardrail with input/output mode selection
curl --request POST \
--url https://api.enkryptai.com/guardrails/guardrail/detect \
--header 'Content-Type: application/json' \
--header 'X-Enkrypt-Guardrail: <x-enkrypt-guardrail>' \
--header 'X-Enkrypt-Mode: <x-enkrypt-mode>' \
--header 'apikey: <api-key>' \
--data '
{
"text": "<string>",
"user_metadata": {
"request_id": "abc-123",
"source": "mobile-app"
}
}
'import requests
url = "https://api.enkryptai.com/guardrails/guardrail/detect"
payload = {
"text": "<string>",
"user_metadata": {
"request_id": "abc-123",
"source": "mobile-app"
}
}
headers = {
"X-Enkrypt-Guardrail": "<x-enkrypt-guardrail>",
"X-Enkrypt-Mode": "<x-enkrypt-mode>",
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'X-Enkrypt-Guardrail': '<x-enkrypt-guardrail>',
'X-Enkrypt-Mode': '<x-enkrypt-mode>',
apikey: '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({text: '<string>', user_metadata: {request_id: 'abc-123', source: 'mobile-app'}})
};
fetch('https://api.enkryptai.com/guardrails/guardrail/detect', 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.enkryptai.com/guardrails/guardrail/detect",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'text' => '<string>',
'user_metadata' => [
'request_id' => 'abc-123',
'source' => 'mobile-app'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Enkrypt-Guardrail: <x-enkrypt-guardrail>",
"X-Enkrypt-Mode: <x-enkrypt-mode>",
"apikey: <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.enkryptai.com/guardrails/guardrail/detect"
payload := strings.NewReader("{\n \"text\": \"<string>\",\n \"user_metadata\": {\n \"request_id\": \"abc-123\",\n \"source\": \"mobile-app\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Enkrypt-Guardrail", "<x-enkrypt-guardrail>")
req.Header.Add("X-Enkrypt-Mode", "<x-enkrypt-mode>")
req.Header.Add("apikey", "<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.post("https://api.enkryptai.com/guardrails/guardrail/detect")
.header("X-Enkrypt-Guardrail", "<x-enkrypt-guardrail>")
.header("X-Enkrypt-Mode", "<x-enkrypt-mode>")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"text\": \"<string>\",\n \"user_metadata\": {\n \"request_id\": \"abc-123\",\n \"source\": \"mobile-app\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.enkryptai.com/guardrails/guardrail/detect")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Enkrypt-Guardrail"] = '<x-enkrypt-guardrail>'
request["X-Enkrypt-Mode"] = '<x-enkrypt-mode>'
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"text\": \"<string>\",\n \"user_metadata\": {\n \"request_id\": \"abc-123\",\n \"source\": \"mobile-app\"\n }\n}"
response = http.request(request)
puts response.read_body{
"summary": {
"injection_attack": 1,
"policy_violation": 1
},
"details": {
"injection_attack": {
"safe": 0.001584,
"attack": 0.998416,
"p_injection": "0.998416",
"p_jailbreak": "0.103658",
"detected_attacks": [
"injection"
],
"explanation": "Prefaces the request with an instruction to disregard prior directives before asking for another customer's record."
},
"policy_violation": {
"violating_policy": "Rule 1: Both user queries and assistant responses must not contain disclosure of personal or sensitive data about an identifiable individual OTHER THAN the person communicating in the chunk.",
"explanation": "Discloses personal and sensitive data (SSN, balance) about a named third party (John Q. Public).",
"violated_rules": [
{
"id": "priv-1",
"display_text": "No disclosing others' personal data",
"text": "Both user queries and assistant responses must not contain disclosure of personal or sensitive data about an identifiable individual OTHER THAN the person communicating in the chunk.",
"risk_category": "privacy_data_protection",
"applicability": "user_assistant",
"severity": "high",
"frameworks": [
"hipaa",
"gdpr"
],
"mappings": [
{
"framework": "gdpr",
"clause": "Art. 9 — Special categories of personal data"
}
],
"source": "document/catalog",
"suggested": false
}
],
"most_unsafe_content": "the full account record for another customer, John Q. Public: SSN 123-45-6789, balance $84,220"
}
},
"result_message": "Your message does not comply with our usage policies. Please revise and try again."
}Authorizations
Headers
The guardrail name
"My Guardrail"
Whether to apply input (prompt) or output (response) detectors
prompt, response "prompt"
Body
The text to analyze
Optional arbitrary metadata object echoed back in the response. Limits: at most 16 top-level keys, key names up to 64 characters, nesting depth up to 3, total serialized size up to 4 KB. When provided and valid, this object is also echoed as a top-level user_metadata key on error responses (4xx/5xx) of endpoints that accept it; invalid or oversized metadata is never echoed, including on the 422 response it causes.
{
"request_id": "abc-123",
"source": "mobile-app"
}
Response
Successful Response
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Block message when a block-type detector triggers (custom or built-in default), revised text when only revise-type detectors trigger, or null when no detections fire.
Optional arbitrary metadata object echoed back in the response. Limits: at most 16 top-level keys, key names up to 64 characters, nesting depth up to 3, total serialized size up to 4 KB. When provided and valid, this object is also echoed as a top-level user_metadata key on error responses (4xx/5xx) of endpoints that accept it; invalid or oversized metadata is never echoed, including on the 422 response it causes.
{
"request_id": "abc-123",
"source": "mobile-app"
}

