POST/api/v1/security

Create and run a security scan

Runs a red-team security scan against the specified model with the given attack types. Returns severity counts and overall score.

Authentication

Send Authorization: Bearer YOUR_API_KEY on every request. Generate API keys at /dashboard/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

201Scan completed
429(no description)

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

import { EvalGuard } from "@evalguard/sdk";

const client = new EvalGuard({ apiKey: process.env.EVALGUARD_API_KEY });

const response = await client.request({
  method: "POST",
  path: "/api/v1/security",
  body: {
    "projectId": "00000000-0000-0000-0000-000000000000",
    "model": "gpt-4o",
    "prompt": "You are a customer support agent.",
    "attackTypes": [
      "prompt-injection",
      "jailbreak",
      "pii-leak"
    ]
  },
});
console.log(response);

Python

from evalguard import EvalGuard
import os

client = EvalGuard(api_key=os.environ["EVALGUARD_API_KEY"])

response = client.request(
    method="POST",
    path="/api/v1/security",
    body={
    "projectId": "00000000-0000-0000-0000-000000000000",
    "model": "gpt-4o",
    "prompt": "You are a customer support agent.",
    "attackTypes": [
        "prompt-injection",
        "jailbreak",
        "pii-leak"
    ]
},
)
print(response)

Go

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/evalguard/evalguard-go"
)

func main() {
	client := evalguard.NewClient(os.Getenv("EVALGUARD_API_KEY"))
	resp, err := client.Request(context.Background(), "POST", "/api/v1/security", map[string]any{"projectId": "00000000-0000-0000-0000-000000000000", "model": "gpt-4o", "prompt": "You are a customer support agent.", "attackTypes": []any{"prompt-injection", "jailbreak", "pii-leak"}})
	if err != nil { panic(err) }
	fmt.Println(resp)
}

Errors

429

Other Security endpoints