REST API Reference
Complete reference for the DriftRail API. All endpoints require authentication via API key.
Base URL
Authentication
Include your API key in the Authorization header:
Authorization: Bearer aso_live_your_api_key_here
Alternative: Use X-API-Key header.
Key Formats
| Environment | Prefix | Example |
|---|---|---|
| Production | aso_live_ | aso_live_a1b2c3d4... |
| Staging | aso_test_ | aso_test_e5f6g7h8... |
| Development | aso_dev_ | aso_dev_i9j0k1l2... |
Rate Limits
| Plan | Requests/min | Burst |
|---|---|---|
| Starter | 60 | 100 |
| Growth | 300 | 500 |
| Pro | 1,000 | 2,000 |
| Enterprise | Custom | Custom |
Per-key rate limits can be configured via the API Keys endpoint.
Error Codes
400Bad Request - Invalid parameters401Unauthorized - Invalid or missing API key403Forbidden - Insufficient permissions or scope404Not Found - Resource doesn't exist415Unsupported Media Type - Use application/json429Too Many Requests - Rate limit exceeded500Internal Server ErrorInline Guard
Real-time content safety check. Blocks dangerous outputs before they reach users. <50ms latency.
/api/guard
Critical Path
Request Body
{
"output": "The LLM response to check",
"input": "Optional user prompt for context",
"mode": "strict",
"timeout_ms": 100,
"skip_classification": false
}
Response
{
"allowed": true,
"action": "allow",
"output": "The LLM response to check",
"triggered": [],
"classification": {
"risk_score": 15,
"pii": { "detected": false, "types": [] },
"toxicity": { "detected": false, "severity": "none" },
"prompt_injection": { "detected": false, "risk": "none" }
},
"latency_ms": 42,
"fallback": false
}
Fail-Open: If classification times out, allowed: true and fallback: true are returned.
Ingest
Log an LLM inference event for async classification and monitoring.
/ingest
Request Body
{
"model": "gpt-5",
"provider": "openai",
"input": {
"prompt": "What is the capital of France?",
"messages": [{ "role": "user", "content": "..." }],
"retrievedSources": [{ "id": "doc-1", "content": "..." }]
},
"output": {
"text": "The capital of France is Paris.",
"toolCalls": []
},
"metadata": {
"latencyMs": 420,
"tokensIn": 25,
"tokensOut": 12,
"temperature": 0.7
}
}
Response (202 Accepted)
{
"success": true,
"event_id": "evt_a1b2c3d4...",
"job_id": "job_e5f6g7h8..."
}
Events
Query logged inference events with optional filters.
/api/events
Query Parameters
Classifications
List classification results with risk scores and detected issues.
/api/classifications
List all classifications with filters for risk score and time range.
/api/classifications/distribution
Get risk distribution statistics (low, medium, high counts).
/api/classifications/high-risk
Get high-risk events above threshold (default: 70).
Stats
Get aggregated statistics for your application.
/api/stats
Query param: period = 1h, 24h, 7d, 30d
{
"period": "24h",
"events": { "total": 5000, "by_environment": {...} },
"models": [{ "model": "gpt-5", "count": 3000 }],
"risk": { "low": 4200, "medium": 650, "high": 150 },
"latency": { "avg_ms": 520, "p95_ms": 1200 },
"alerts": { "critical": 1, "warning": 3, "info": 8 }
}
API Keys
Manage API keys with scoping, IP allowlisting, expiration, and usage analytics.
/api/keys
List all API keys with usage stats.
/api/keys
Create new API key with optional scopes, IP restrictions, expiration.
{
"name": "Production API",
"environment": "prod",
"scopes": ["read", "write", "ingest", "guard"],
"allowed_ips": ["192.168.1.0/24"],
"expires_at": "2025-12-31T23:59:59Z",
"rate_limit_override": 500
}
/api/keys/rotate
Rotate a key with optional grace period.
/api/keys/usage
Get usage overview across all keys.
/api/keys?key_id=xxx
Revoke an API key.
Scopes: read, write, ingest, guard, admin, * (all)
Guardrails
Configure rule-based guardrails for content filtering.
/api/guardrails
List all guardrails.
/api/guardrails
Create a guardrail rule.
{
"name": "Block PII",
"rule_type": "block_pii",
"action": "block",
"config": { "types": ["email", "phone", "ssn"] }
}
/api/guardrails/check
Test content against guardrails.
Rule Types: block_high_risk, block_pii, block_toxicity, block_prompt_injection, custom_regex, custom_keywords
Actions: flag, block, redact, warn
Detections
Configure detection types and custom classifiers.
/api/detections/types
List available detection types for your tier.
/api/detections/settings
Update enabled detections.
/api/detections/custom
Pro+
Add custom detection with your own prompt.
Webhooks
Register webhook endpoints for real-time notifications.
/api/webhooks
Register a webhook (HTTPS required).
{
"url": "https://your-app.com/webhook",
"events": ["alert.critical", "classification.high_risk"]
}
Events: alert.created, alert.critical, usage.threshold, classification.high_risk
Integrations
Connect to Slack, Teams, or Discord for notifications.
/api/integrations
Create integration.
{
"type": "slack",
"webhook_url": "https://hooks.slack.com/...",
"channel_name": "#ai-alerts",
"events": ["alert.critical", "incident.created"]
}
/api/integrations/test
Test a webhook URL before saving.
Types: slack, teams, discord
Projects
Organize your AI applications into projects with separate keys and guardrails.
/api/projects
List all projects.
/api/projects
Create a new project.
/api/projects/:id/keys
List project API keys.
/api/projects/:id/guardrails
List project-specific guardrails.
/api/projects/:id/usage
Get project usage statistics.
Incidents
Track and manage AI safety incidents.
/api/incidents
List incidents with status/severity filters.
/api/incidents
Create an incident.
{
"title": "High hallucination rate detected",
"description": "Hallucination rate spiked to 15%",
"severity": "high",
"incident_type": "hallucination_spike"
}
/api/incidents/:id/status
Update incident status (open, investigating, mitigating, resolved, closed).
/api/incidents/stats
Get incident statistics including MTTR.
Compliance
Manage compliance frameworks and GDPR data subject requests.
/api/compliance/status
Get compliance framework status (HIPAA, SOC2, GDPR, PCI-DSS).
/api/compliance/settings
Update compliance settings.
{
"hipaa_enabled": true,
"gdpr_enabled": true,
"pii_auto_redact": true,
"pii_redaction_level": "standard",
"data_region": "eu"
}
/api/compliance/dsar
Create GDPR Data Subject Access Request.
Model Comparison
Compare model performance and run A/B tests.
/api/models/leaderboard
Get model performance leaderboard. Metrics: avg_risk_score, avg_latency_ms, hallucination_rate, error_rate.
/api/models/comparisons
Create A/B test comparison between two models.
/api/models/performance/:model
Get performance history for a specific model.
Exports
Export data for compliance audits and analysis.
/api/exports
Create an export job.
{
"export_type": "events",
"format": "json",
"date_from": "2026-01-01T00:00:00Z",
"date_to": "2026-01-31T23:59:59Z"
}
/api/exports/download/:id
Download completed export file.
Types: events, classifications, audit_logs, incidents, full_audit
Formats: json, csv, pdf
Brand Safety
Protect your brand with content rules and competitor monitoring.
/api/brand-safety/rules
Create a brand safety rule.
{
"name": "Block Competitor Mentions",
"rule_type": "competitor_mentions",
"config": { "terms": ["CompetitorA", "CompetitorB"] },
"action": "flag",
"severity": "medium"
}
/api/brand-safety/check
Check text against brand safety rules.
Rule Types: blocked_terms, competitor_mentions, sentiment_threshold, topic_restriction, custom_regex
Retention
Configure data retention policies for compliance.
/api/retention
Create a retention policy.
{
"name": "Production Events - 90 days",
"data_type": "inference_events",
"retention_days": 90,
"environment_filter": ["prod"]
}
/api/retention/summary
Get retention summary with deletion stats.
Audit Logs
Search, stream, and export audit logs. Configure SIEM integration.
/api/logs
Search logs with filters (level, action, actor, resource, time range).
/api/logs/stats
Get log statistics by level and action.
/api/logs/export
Configure SIEM export (Splunk, Datadog, etc.).
/api/logs/sampling
Configure log sampling for high-volume environments.
/api/logs/retention
Configure log retention with optional archiving.
AI Playground
Test AI models with real-time DriftRail safety monitoring.
/api-playground
Get usage limits and available models.
/api-playground
Send a message and get AI response with detections.
{
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "What is the capital of France?" }
],
"model": "gemini-flash-lite-latest",
"runDetections": true
}
Limits: Starter: 25/mo, Growth: 500/mo, Pro: 2,500/mo, Enterprise: 10,000+/mo
Alerts
Manage drift alerts and notifications.
/api/alerts
List alerts with severity and status filters.
/api/alerts
Acknowledge or resolve an alert.