/api/v1/securityCreate and run a security scan
Creates and runs a red-team security scan against the specified model. Body: projectId, model, prompt, attackTypes (ids from the attack-plugin registry — unknown ids are rejected 400, the legacy aliases `toxicity` and `hallucination` are remapped), plus optional `depth` (quick|standard|full, default full) or an explicit `strategies` id list. Two outcomes by size: a set that fits the inline strategy budget runs synchronously and returns 201 with { id, status: passed|failed, mode:'sync', score, strategyCoverage, totalTests, executedTests, erroredTests, duration, severityCounts, findingsCount } (5-minute timeout); anything larger — which the default full depth normally is — is queued to the worker and returns 202 with { id, status:'pending', mode:'async', strategyCoverage, statusUrl } for the caller to poll at GET /api/v1/security/{id}. The strategy set is never silently truncated to fit. Enforces the org's security_scans usage quota (429), a consent gate on any subject_email/subject_id (451), and fails 502 SCAN_TARGET_UNREACHABLE rather than reporting a false pass when every attack attempt errored. Editor role, security_scans:create, honors Idempotency-Key.
Authentication
Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/settings/api-keys.
Request body required
Example
{
"projectId": "00000000-0000-0000-0000-000000000000",
"model": "gpt-4o",
"prompt": "You are a customer support agent.",
"attackTypes": [
"prompt-injection",
"jailbreak",
"pii-leak"
]
}Schema
{
"application/json": {
"schema": {
"type": "object",
"required": [
"projectId",
"model",
"prompt",
"attackTypes"
],
"properties": {
"projectId": {
"type": "string",
"format": "uuid"
},
"model": {
"type": "string",
"example": "gpt-4o"
},
"prompt": {
"type": "string",
"description": "System prompt to test",
"example": "You are a customer support agent."
},
"attackTypes": {
"type": "array",
"items": {
"type": "string"
},
"description": "Attack categories to run",
"example": [
"prompt-injection",
"jailbreak",
"pii-leak"
]
}
}
}
}
}Response
201 example
{
"success": false,
"data": {
"id": "string",
"status": "passed",
"score": 0,
"totalTests": 0,
"duration": 0,
"severityCounts": {
"critical": 0,
"high": 0,
"medium": 0,
"low": 0
},
"findingsCount": 0
}
}All status codes
Code samples
cURL
curl -X POST \
https://evalguard.ai/api/v1/security \
-H "Authorization: Bearer $EVALGUARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "projectId": "00000000-0000-0000-0000-000000000000", "model": "gpt-4o", "prompt": "You are a customer support agent.", "attackTypes": [ "prompt-injection", "jailbreak", "pii-leak" ] }'TypeScript
// The TypeScript SDK (@evalguard/sdk) exposes TYPED methods — runEval,
// getEval, runSecurityScan, checkFirewall, … — not a generic request().
// For an arbitrary endpoint, call it directly:
const res = await fetch("https://evalguard.ai/api/v1/security", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.EVALGUARD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"projectId": "00000000-0000-0000-0000-000000000000",
"model": "gpt-4o",
"prompt": "You are a customer support agent.",
"attackTypes": [
"prompt-injection",
"jailbreak",
"pii-leak"
]
}),
});
console.log(res.status, await res.json());Python
# The Python SDK (pip install evalguardai) exposes TYPED methods on
# EvalGuardClient — run_eval, get_eval, … — not a generic request().
# For an arbitrary endpoint, call it directly:
import os
import requests
headers = {"Authorization": f"Bearer {os.environ['EVALGUARD_API_KEY']}"}
headers["Content-Type"] = "application/json"
response = requests.request(
"POST",
"https://evalguard.ai/api/v1/security",
headers=headers,
json={
"projectId": "00000000-0000-0000-0000-000000000000",
"model": "gpt-4o",
"prompt": "You are a customer support agent.",
"attackTypes": [
"prompt-injection",
"jailbreak",
"pii-leak"
]
},
)
print(response.status_code, response.json())Go
package main
import (
"context"
"fmt"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{"projectId":"00000000-0000-0000-0000-000000000000","model":"gpt-4o","prompt":"You are a customer support agent.","attackTypes":["prompt-injection","jailbreak","pii-leak"]}`)
req, _ := http.NewRequestWithContext(context.Background(), "POST", "https://evalguard.ai/api/v1/security", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("EVALGUARD_API_KEY"))
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil { panic(err) }
defer resp.Body.Close()
fmt.Println(resp.Status)
}