API Reference

Complete REST API documentation. Interactive Swagger docs are available at /docs when the server is running.

All endpoints (except auth and health) require a JWT Bearer token:
Authorization: Bearer <token>

Authentication

MethodPathDescription
POST/api/auth/registerRegister a new user
POST/api/auth/loginLogin and receive JWT token
GET/api/auth/meGet current user info
PUT/api/auth/profileUpdate display name or password
GET/api/auth/capabilitiesCheck available features (SMTP, OAuth)
POST/api/auth/forgot-passwordRequest password reset email
POST/api/auth/reset-passwordReset password with token
GET/api/auth/google/loginInitiate Google OAuth flow
GET/api/auth/google/callbackGoogle OAuth callback

Register

bash
curl -X POST http://localhost:8000/api/auth/register \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com", "password": "securepass", "display_name": "Alice"}'

Response: {"access_token": "eyJ...", "token_type": "bearer"}

Login

bash
curl -X POST http://localhost:8000/api/auth/login \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com", "password": "securepass"}'

Chat

MethodPathDescription
POST/api/chatSend a message (SSE streaming)
POST/api/chat/with-documentChat with file attachment

Send Message

bash
curl -N http://localhost:8000/api/chat \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "message": "Summarize this for John Smith at john@acme.com", "conversation_id": null, "provider": "openai", "model": "gpt-4o-mini" }'

Returns Server-Sent Events (SSE) with data: lines containing JSON chunks.

Chat with Document

Upload a file alongside a message. The document text is extracted, sanitized, and prepended as context for the LLM.

bash
curl -N http://localhost:8000/api/chat/with-document \ -H "Authorization: Bearer $TOKEN" \ -F "message=Summarize the key points in this document" \ -F "provider=openai" \ -F "model=gpt-4o-mini" \ -F "file=@report.pdf"

Supported file types: PDF, DOCX, TXT, CSV, XLSX (max 10 MB).

Sanitize (Detection Only)

MethodPathDescription
POST/api/sanitizeSanitize a single text (no LLM call)
POST/api/sanitize/batchSanitize multiple texts in one request

No LLM call, no token cost. Ideal for corpus testing, CI/CD integration, and detection benchmarking.

Sanitize Single Text

bash
curl -X POST http://localhost:8000/api/sanitize \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"text": "Contact John Smith at john@acme.com or 555-123-4567"}'
{ "sanitized_text": "Contact PERSON_001 at EMAIL_001 or PHONE_001", "entity_count": 3, "entities": [ { "entity_type": "PERSON", "placeholder": "PERSON_001", "confidence": 0.85, "detection_method": "ner" }, { "entity_type": "EMAIL", "placeholder": "EMAIL_001", "confidence": 0.95, "detection_method": "regex" }, { "entity_type": "PHONE", "placeholder": "PHONE_001", "confidence": 0.85, "detection_method": "regex" } ], "processing_ms": 3 }

Set return_original: true to include original values (admin/owner roles only).

Batch Sanitize

bash
curl -X POST http://localhost:8000/api/sanitize/batch \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "texts": [ "Email john@acme.com about the project", "Call Jane Doe at 555-987-6543" ] }'

Entity placeholders are consistent across all texts in the batch (shared mapper).

Conversations

MethodPathDescription
GET/api/conversationsList conversations (search/sort)
GET/api/conversations/{id}Get conversation with messages
PUT/api/conversations/{id}Rename conversation
DELETE/api/conversations/{id}Delete conversation
GET/api/conversations/{id}/exportExport as JSON or Markdown

Gateway API (OpenAI-Compatible)

MethodPathDescription
POST/v1/chat/completionsOpenAI-compatible chat completion

Requires an API key (created via the API Keys endpoint). Works with any OpenAI SDK by changing the base URL:

python
from openai import OpenAI client = OpenAI(base_url="http://localhost:8000/v1", api_key="vk-your-api-key") response = client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "user", "content": "Hello"}] )

Provider Routing

Prefix the model name to route to a specific provider:

Model PrefixProvider
gpt-*, o3-*OpenAI
claude-*Anthropic
ollama/* or unmatchedOllama

Document Scanner

MethodPathDescription
POST/api/documents/scanUpload and scan a document for PII

No LLM call — pure detection. Upload a file via multipart form data. Supported: PDF, DOCX, TXT, CSV, XLSX (max 10 MB). Files are processed in-memory and discarded.

Models

MethodPathDescription
GET/api/modelsList available models and provider status

Rules (Custom Detection)

MethodPathDescription
GET/api/rulesList all detection rules
POST/api/rulesCreate a custom rule
PUT/api/rules/{id}Update a rule
DELETE/api/rules/{id}Delete a custom rule
POST/api/rules/testTest a rule against sample text

Create Rule

bash
curl -X POST http://localhost:8000/api/rules \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Internal Project Code", "pattern": "PROJ-[A-Z]{3}-\\d{4}", "entity_type": "PROJECT_CODE", "description": "Internal project identifiers" }'

Policies

MethodPathDescription
GET/api/policiesList all policies
POST/api/policiesCreate a policy
PUT/api/policies/{id}Update a policy
DELETE/api/policies/{id}Delete a policy

Policy Actions

ActionBehavior
redactReplace entity with placeholder (default)
blockReject the message entirely
warnAllow but flag in the sanitization panel
allowPass through without modification

API Keys

MethodPathDescription
GET/api/api-keysList API keys (hashed)
POST/api/api-keysCreate a new API key
DELETE/api/api-keys/{id}Revoke an API key

Webhooks

MethodPathDescription
GET/api/webhooksList webhooks
POST/api/webhooksCreate a webhook
PUT/api/webhooks/{id}Update a webhook
DELETE/api/webhooks/{id}Delete a webhook

Settings

MethodPathDescription
GET/api/settingsGet organization settings
PUT/api/settingsUpdate organization settings

Admin

MethodPathDescription
GET/api/admin/dashboardDashboard stats
GET/api/admin/usageUsage records
GET/api/admin/entitiesEntity detection stats
GET/api/admin/auditAudit log entries
GET/api/admin/usersList users (admin only)
POST/api/admin/users/inviteInvite a user
PUT/api/admin/users/{id}Update user role/status

Usage Quota

MethodPathDescription
GET/api/usage/quotaCurrent usage vs tier limits

Licensing

MethodPathDescription
GET/api/licensing/statusCurrent license status and tier
GET/api/licensing/tiersAvailable tiers and limits
POST/api/licensing/activateActivate a license key
POST/api/licensing/deactivateDeactivate current license

Health

MethodPathDescription
GET/api/healthBasic health check
GET/api/health/liveLiveness probe (Kubernetes)
GET/api/health/readyReadiness probe (checks DB)

Error Responses

All errors follow a consistent format:

{ "detail": "Description of the error" }
CodeMeaning
401Missing or invalid authentication
403Insufficient permissions or license tier
404Resource not found
422Validation error (invalid input)
429Rate limited