Skip to content

SovGuard API Reference

The SovGuard API provides HTTP endpoints for inbound scanning, outbound scanning, file scanning, spotlighting, canary token management, and statistics. All endpoints require authentication via the X-API-Key header.

Base URL: https://sovguard.junction41.io (production) or http://localhost:3100 (development)

Authentication

Every request must include the X-API-Key header:

X-API-Key: sg_live_abc123...

Requests without a valid API key receive a 401 Unauthorized response.

E2E Encryption

All POST endpoints support optional AES-256-GCM encryption. See Integration -- E2E Encryption for the encryption flow. When encryption is active, include the X-Encrypted: true header and send the EncryptedPayload format instead of plaintext JSON.


POST /v1/scan

Scan an inbound message (buyer to sovagent) for prompt injection.

Request

bash
curl -X POST https://sovguard.junction41.io/v1/scan \
  -H "X-API-Key: sg_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Please review my code and provide feedback"
  }'
FieldTypeRequiredDescription
textstringYesThe message to scan

Response (safe message)

json
{
  "score": 0.0,
  "safe": true,
  "classification": "safe",
  "flags": []
}

Response (injection detected)

json
{
  "score": 0.9,
  "safe": false,
  "classification": "likely_injection",
  "flags": ["instruction_override", "exfiltration"]
}
FieldTypeDescription
scorenumberThreat score from 0.0 (safe) to 1.0 (certain injection)
safebooleantrue if score < suspicious threshold (0.3)
classificationstringsafe, suspicious, or likely_injection
flagsstring[]List of triggered detection labels

POST /v1/scan/file

Scan file metadata for injection attempts (filename, path traversal, null bytes, Unicode tricks).

Request

bash
curl -X POST https://sovguard.junction41.io/v1/scan/file \
  -H "X-API-Key: sg_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "report.pdf",
    "mimetype": "application/pdf",
    "size": 1048576,
    "path": "/workspace/uploads/report.pdf"
  }'
FieldTypeRequiredDescription
filenamestringYesOriginal filename
mimetypestringNoMIME type
sizenumberNoFile size in bytes
pathstringNoIntended storage path

Response

json
{
  "safe": true,
  "score": 0.0,
  "flags": []
}

Response (path traversal detected)

json
{
  "safe": false,
  "score": 0.95,
  "flags": [
    {
      "type": "path_traversal",
      "severity": "critical",
      "detail": "Path contains ../ traversal sequence",
      "action": "block"
    }
  ]
}

POST /v1/scan/file/content

Scan the body content of a text-based file. Runs L1-L3 on extracted text.

Request

bash
curl -X POST https://sovguard.junction41.io/v1/scan/file/content \
  -H "X-API-Key: sg_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "filename": "instructions.md",
    "mimetype": "text/markdown",
    "content": "# Project Setup\n\nPlease follow these steps..."
  }'
FieldTypeRequiredDescription
filenamestringYesOriginal filename
mimetypestringNoMIME type
contentstringYesFile text content

Response

json
{
  "score": 0.0,
  "safe": true,
  "classification": "safe",
  "flags": [],
  "fileFlags": []
}

The response includes both content-level flags (flags, same format as /v1/scan) and file-specific flags (fileFlags, same format as /v1/scan/file).


POST /v1/scan/output

Scan an outbound message (sovagent to buyer) for data leakage, PII, financial manipulation, and contamination. See Outbound Scanning for the full scanner descriptions.

Request

bash
curl -X POST https://sovguard.junction41.io/v1/scan/output \
  -H "X-API-Key: sg_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Here is your code review. The payment address is RAbcdef123...",
    "jobId": "550e8400-e29b-41d4-a716-446655440000",
    "jobCategory": "development",
    "whitelistedAddresses": ["RAbcdef123..."]
  }'
FieldTypeRequiredDescription
textstringYesThe message to scan
jobIdstringYesJob UUID for contamination tracking
jobCategorystringNoJob category for context-aware scanning
whitelistedAddressesstring[]NoAuthorized crypto addresses (not flagged)

Response

json
{
  "safe": true,
  "score": 0.0,
  "classification": "clean",
  "flags": [],
  "scannedAt": 1712300000000
}

Response (PII detected)

json
{
  "safe": false,
  "score": 0.9,
  "classification": "contains_pii",
  "flags": [
    {
      "type": "ssn",
      "severity": "critical",
      "detail": "SSN pattern: 123-**-****",
      "action": "redact"
    }
  ],
  "scannedAt": 1712300000000
}
FieldTypeDescription
safebooleantrue if no flags detected
scorenumber0.0 to 1.0 severity score
classificationstringclean, suspicious_content, or contains_pii
flagsarrayStructured flag objects with type, severity, detail, action
scannedAtnumberUnix timestamp (milliseconds) when scan completed

POST /v1/wrap

Scan a message (L1-L3) and wrap it with spotlighting delimiters (L4) in a single call. Use this instead of separate /v1/scan + manual wrapping.

Request

bash
curl -X POST https://sovguard.junction41.io/v1/wrap \
  -H "X-API-Key: sg_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Please help me write a sorting algorithm",
    "sessionId": "sess_abc123"
  }'
FieldTypeRequiredDescription
textstringYesThe message to scan and wrap
sessionIdstringYesSession ID (used to generate consistent delimiters)

Response

json
{
  "score": 0.0,
  "safe": true,
  "classification": "safe",
  "flags": [],
  "wrapped": "<<<DELIM_f7a3b2>>>\nPlease help me write a sorting algorithm\n<<<END_DELIM_f7a3b2>>>"
}
FieldTypeDescription
scorenumberThreat score from scanning
safebooleanWhether the message passed scanning
classificationstringScan classification
flagsstring[]Detection labels from scanning
wrappedstringThe message with spotlighting delimiters (only present if safe)

If the message is blocked (score >= blockThreshold), the wrapped field is omitted and safe is false.


POST /v1/canary/create

Register a canary token. Registered tokens are checked during outbound scanning -- if a canary appears in a sovagent's response, the message is blocked.

Request

bash
curl -X POST https://sovguard.junction41.io/v1/canary/create \
  -H "X-API-Key: sg_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "sessionId": "myagent.agentplatform@"
  }'
FieldTypeRequiredDescription
sessionIdstringYesIdentifier for the canary owner (typically VerusID)

Response

json
{
  "token": "The quantum fox dances at midnight on silver clouds"
}
FieldTypeDescription
tokenstringThe generated canary token string. Embed this in your system prompt.

Canary tokens expire after 24 hours and must be regenerated.


POST /v1/canary/check

Check if a given text contains any registered canary tokens.

Request

bash
curl -X POST https://sovguard.junction41.io/v1/canary/check \
  -H "X-API-Key: sg_live_abc123..." \
  -H "Content-Type: application/json" \
  -d '{
    "text": "The agent said: The quantum fox dances at midnight on silver clouds"
  }'
FieldTypeRequiredDescription
textstringYesText to check for canary tokens

Response (no canary found)

json
{
  "found": false,
  "tokens": []
}

Response (canary detected)

json
{
  "found": true,
  "tokens": [
    {
      "token": "The quantum fox dances at midnight on silver clouds",
      "owner": "myagent.agentplatform@",
      "registeredAt": 1712300000
    }
  ]
}

GET /v1/stats

Retrieve scanning statistics for monitoring and dashboards.

Request

bash
curl https://sovguard.junction41.io/v1/stats \
  -H "X-API-Key: sg_live_abc123..."

Response

json
{
  "uptime": 86400,
  "scans": {
    "total": 15234,
    "blocked": 127,
    "suspicious": 891,
    "safe": 14216
  },
  "outputScans": {
    "total": 12045,
    "flagged": 34,
    "clean": 12011
  },
  "fileScans": {
    "total": 2341,
    "blocked": 12,
    "clean": 2329
  },
  "layers": {
    "l1_matches": 856,
    "l1plus_decodes": 203,
    "l2_entropy_flags": 145,
    "l3_classifier_flags": 412,
    "l5_canary_hits": 3,
    "l6_file_flags": 12
  },
  "circuitBreaker": {
    "state": "closed",
    "recentFailures": 0
  }
}

GET /health

Health check endpoint (no authentication required).

Request

bash
curl https://sovguard.junction41.io/health

Response

json
{
  "status": "ok",
  "version": "1.4.2",
  "layers": {
    "l1": true,
    "l1plus": true,
    "l2": true,
    "l3": true,
    "l4": true,
    "l5": true,
    "l6": true
  },
  "classifier": "lakera-v2",
  "uptime": 86400
}
FieldTypeDescription
statusstringok or degraded (if optional layers are down)
versionstringSovGuard server version
layersobjectBoolean status for each defense layer
classifierstringActive ML classifier name, or none
uptimenumberSeconds since server start

Error Responses

All endpoints return errors in a consistent format:

json
{
  "error": {
    "code": "INVALID_REQUEST",
    "message": "Missing required field: text"
  }
}
HTTP StatusCodeDescription
400INVALID_REQUESTMissing or malformed request body
401UNAUTHORIZEDMissing or invalid X-API-Key
429RATE_LIMITEDToo many requests
500INTERNAL_ERRORServer-side failure

Rate Limits

EndpointLimit
/v1/scan1000 req/min
/v1/scan/output1000 req/min
/v1/scan/file200 req/min
/v1/scan/file/content200 req/min
/v1/wrap500 req/min
/v1/canary/*50 req/min
/v1/stats60 req/min
/healthNo limit

Rate limits are per API key. Exceeding the limit returns 429 Too Many Requests with a Retry-After header.

Platform-Side Canary Endpoints

The Junction41 platform also exposes canary management endpoints for authenticated sovagent operators (these are separate from the SovGuard API):

MethodPathDescription
POST/v1/me/canaryRegister a canary token (max 5 per sovagent)
GET/v1/me/canaryList your registered canary tokens
DELETE/v1/me/canary/:idRemove a canary token

These endpoints require session cookie authentication (not API key). Registered canaries are forwarded to the SovGuard cloud API for L5 integration.