Create Policy
curl --request POST \
--url https://api.enkryptai.com/guardrails/add-policy \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"name": "<string>",
"description": "<string>",
"detectors": {}
}
'import requests
url = "https://api.enkryptai.com/guardrails/add-policy"
payload = {
"name": "<string>",
"description": "<string>",
"detectors": {}
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', description: '<string>', detectors: {}})
};
fetch('https://api.enkryptai.com/guardrails/add-policy', 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/add-policy",
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([
'name' => '<string>',
'description' => '<string>',
'detectors' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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/add-policy"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"detectors\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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/add-policy")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"detectors\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.enkryptai.com/guardrails/add-policy")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"detectors\": {}\n}"
response = http.request(request)
puts response.read_body{
"message": "Policy details added successfully",
"data": {
"name": "<string>",
"description": "<string>",
"detectors": {
"topic_detector": {
"enabled": true,
"topic": [
"<string>"
],
"block_message": "<string>"
},
"nsfw": {
"enabled": true,
"block_message": "<string>"
},
"toxicity": {
"enabled": true,
"block_message": "<string>"
},
"pii": {
"enabled": true,
"entities": []
},
"injection_attack": {
"enabled": true,
"block_message": "<string>"
},
"keyword_detector": {
"enabled": true,
"banned_keywords": [
"<string>"
]
},
"system_prompt": {
"enabled": false,
"index": "system",
"block_message": "<string>"
},
"copyright_ip": {
"enabled": false,
"block_message": "<string>"
},
"policy_violation": {
"enabled": true,
"policy_text": "<string>",
"coc_policy_name": "<string>",
"need_explanation": true,
"block_message": "<string>"
},
"bias": {
"enabled": true
},
"sponge_attack": {
"enabled": false,
"block_message": "<string>"
}
},
"created_at": "2024-10-07T11:23:03.695943+00:00",
"updated_at": "2024-10-07T11:23:03.695943+00:00",
"policy_id": 1234567890,
"project_name": "default"
}
}Guardrails Policy (Legacy)
Add Policy (Legacy)
deprecated
Create a new policy for guardrails
POST
/
guardrails
/
add-policy
Create Policy
curl --request POST \
--url https://api.enkryptai.com/guardrails/add-policy \
--header 'Content-Type: application/json' \
--header 'apikey: <api-key>' \
--data '
{
"name": "<string>",
"description": "<string>",
"detectors": {}
}
'import requests
url = "https://api.enkryptai.com/guardrails/add-policy"
payload = {
"name": "<string>",
"description": "<string>",
"detectors": {}
}
headers = {
"apikey": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {apikey: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({name: '<string>', description: '<string>', detectors: {}})
};
fetch('https://api.enkryptai.com/guardrails/add-policy', 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/add-policy",
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([
'name' => '<string>',
'description' => '<string>',
'detectors' => [
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"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/add-policy"
payload := strings.NewReader("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"detectors\": {}\n}")
req, _ := http.NewRequest("POST", url, payload)
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/add-policy")
.header("apikey", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"detectors\": {}\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.enkryptai.com/guardrails/add-policy")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["apikey"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\",\n \"description\": \"<string>\",\n \"detectors\": {}\n}"
response = http.request(request)
puts response.read_body{
"message": "Policy details added successfully",
"data": {
"name": "<string>",
"description": "<string>",
"detectors": {
"topic_detector": {
"enabled": true,
"topic": [
"<string>"
],
"block_message": "<string>"
},
"nsfw": {
"enabled": true,
"block_message": "<string>"
},
"toxicity": {
"enabled": true,
"block_message": "<string>"
},
"pii": {
"enabled": true,
"entities": []
},
"injection_attack": {
"enabled": true,
"block_message": "<string>"
},
"keyword_detector": {
"enabled": true,
"banned_keywords": [
"<string>"
]
},
"system_prompt": {
"enabled": false,
"index": "system",
"block_message": "<string>"
},
"copyright_ip": {
"enabled": false,
"block_message": "<string>"
},
"policy_violation": {
"enabled": true,
"policy_text": "<string>",
"coc_policy_name": "<string>",
"need_explanation": true,
"block_message": "<string>"
},
"bias": {
"enabled": true
},
"sponge_attack": {
"enabled": false,
"block_message": "<string>"
}
},
"created_at": "2024-10-07T11:23:03.695943+00:00",
"updated_at": "2024-10-07T11:23:03.695943+00:00",
"policy_id": 1234567890,
"project_name": "default"
}
}Archived: This endpoint is legacy. Use the new Add Guardrail endpoint instead, which supports separate input/output detector configurations.
Authorizations
Body
application/json
โI

