curl --request POST \
--url https://api.promptguard.co/api/v1/security-testing/run/{test_name} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"custom_prompt": "<string>",
"target_preset": "default"
}
'import requests
url = "https://api.promptguard.co/api/v1/security-testing/run/{test_name}"
payload = {
"custom_prompt": "<string>",
"target_preset": "default"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({custom_prompt: '<string>', target_preset: 'default'})
};
fetch('https://api.promptguard.co/api/v1/security-testing/run/{test_name}', 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/security-testing/run/{test_name}",
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([
'custom_prompt' => '<string>',
'target_preset' => 'default'
]),
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/security-testing/run/{test_name}"
payload := strings.NewReader("{\n \"custom_prompt\": \"<string>\",\n \"target_preset\": \"default\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.promptguard.co/api/v1/security-testing/run/{test_name}")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"custom_prompt\": \"<string>\",\n \"target_preset\": \"default\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.promptguard.co/api/v1/security-testing/run/{test_name}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"custom_prompt\": \"<string>\",\n \"target_preset\": \"default\"\n}"
response = http.request(request)
puts response.read_body{
"test_name": "<string>",
"prompt": "<string>",
"decision": "<string>",
"reason": "<string>",
"threat_type": "<string>",
"confidence": 123,
"blocked": true,
"errored": false
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Run Named Test
Run a single named attack from the corpus.
curl --request POST \
--url https://api.promptguard.co/api/v1/security-testing/run/{test_name} \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"custom_prompt": "<string>",
"target_preset": "default"
}
'import requests
url = "https://api.promptguard.co/api/v1/security-testing/run/{test_name}"
payload = {
"custom_prompt": "<string>",
"target_preset": "default"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({custom_prompt: '<string>', target_preset: 'default'})
};
fetch('https://api.promptguard.co/api/v1/security-testing/run/{test_name}', 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/security-testing/run/{test_name}",
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([
'custom_prompt' => '<string>',
'target_preset' => 'default'
]),
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/security-testing/run/{test_name}"
payload := strings.NewReader("{\n \"custom_prompt\": \"<string>\",\n \"target_preset\": \"default\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://api.promptguard.co/api/v1/security-testing/run/{test_name}")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"custom_prompt\": \"<string>\",\n \"target_preset\": \"default\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.promptguard.co/api/v1/security-testing/run/{test_name}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"custom_prompt\": \"<string>\",\n \"target_preset\": \"default\"\n}"
response = http.request(request)
puts response.read_body{
"test_name": "<string>",
"prompt": "<string>",
"decision": "<string>",
"reason": "<string>",
"threat_type": "<string>",
"confidence": 123,
"blocked": true,
"errored": false
}{
"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
Body for run-all (where custom_prompt is ignored) and run-custom.
target_preset names the policy to test. A composed
"use_case:strictness" pair is used as given; a bare use case means
that use case at moderate strictness; a bare strictness level means the
default use case at that strictness -- so the wire default "default" is
default:moderate and "strict" is default:strict. The
vocabularies are the ones served by GET /dashboard/presets/use-cases
and GET /dashboard/presets/strictness-levels. Anything else is a 400
that lists the valid composed names; it used to be silently substituted
with the default engine, which made every preset selector a no-op.
Response
Successful Response
One attack prompt and what the policy engine decided about it.
"block", "allow", or "error" when the probe did not complete.
True when the engine raised while evaluating this prompt. Not a verdict: an errored probe is neither blocked nor allowed, and is excluded from the summary's block_rate.