REST API Reference
Complete reference for all KoreShield REST API endpoints.Base URL
Authentication
All endpoints require authentication via theAuthorization header:
POST /v1/scan
Scan a prompt for security threats including prompt injection, jailbreaks, and data exfiltration attempts.Request
The text content to scan for threats
Optional user identifier for tracking and analytics
Optional metadata for context and logging
Detection sensitivity level
low- Higher confidence threshold, fewer false positivesmedium- Balanced detection (recommended)high- Lower threshold, catches more threats
Custom policy ID to apply specific rules
Response
Whether a threat was detected in the content
Type of threat detected (if any)
prompt_injectionjailbreakdata_exfiltrationpii_leakagemalicious_instruction
Confidence score from 0.0 to 1.0
Severity level:
low, medium, high, criticalArray of attack patterns that were detected
Additional context and analysis data
ISO 8601 timestamp of the scan
Example Request
Example Response
POST /v1/scan/rag
Scan RAG (Retrieval-Augmented Generation) context for indirect prompt injection attacks hidden in retrieved documents.Request
The user’s query/question
Array of retrieved document objects to scan
Detection sensitivity for RAG attacks
Response
Whether the RAG context is safe to use
Array of document IDs that contain threats
Detailed threat classification
Example Request
Example Response
POST /v1/proxy/
OpenAI-compatible proxy endpoint for routing LLM requests through KoreShield with automatic security scanning.Path Parameters
LLM provider to proxy to
openaianthropicgeminideepseekazure-openai
Request
Follows OpenAI Chat Completions API format:Model identifier (e.g., “gpt-4”, “claude-3-opus”)
Array of message objects with role and content
Enable streaming responses
Sampling temperature (0.0 to 2.0)
Maximum tokens to generate
Response
Returns standard OpenAI Chat Completions response format with additional security headers:X-Koreshield-Threat-Detected:trueif threat was foundX-Koreshield-Threat-Type: Type of threat detectedX-Koreshield-Scan-Duration: Scan duration in milliseconds
Example Request
GET /health
Health check endpoint for monitoring KoreShield service status.Response
Service status:
healthy, degraded, unhealthyKoreShield version
Service uptime in seconds
Status of dependent services (database, cache, etc.)
Example
GET /v1/policies
Retrieve configured security policies.Query Parameters
Maximum number of policies to return
Offset for pagination
Response
Array of policy objects
Total number of policies
Example
GET /metrics
Prometheus-compatible metrics endpoint for monitoring.Response Format
Returns metrics in Prometheus text format:Error Responses
All errors follow a consistent format:HTTP Status Codes
| Code | Description | Common Causes |
|---|---|---|
| 400 | Bad Request | Invalid parameters, malformed JSON |
| 401 | Unauthorized | Missing or invalid API key |
| 403 | Forbidden | Request blocked by security policy |
| 404 | Not Found | Invalid endpoint or resource |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server-side error |
| 503 | Service Unavailable | Service temporarily down |
Error Types
validation_error- Invalid request parametersauthentication_error- Authentication failedpermission_error- Insufficient permissionsrate_limit_error- Rate limit exceededapi_error- Internal API error
Example Error
Rate Limiting
Rate limits are applied per API key:| Header | Description |
|---|---|
X-RateLimit-Limit | Maximum requests per window |
X-RateLimit-Remaining | Remaining requests in window |
X-RateLimit-Reset | Unix timestamp when limit resets |
Example Headers
Next Steps
CLI Reference
Command-line interface documentation
Configuration
Configure security policies
RAG Defense
Learn about RAG security
Integrations
Framework integrations