REST API
REST API

REST API Reference

The PrivaiShield API provides programmatic access to PII redaction. Use it to integrate privacy protection into your applications, data pipelines, and workflows.

BASE URL
https://api.privaishield.com/v1

Authentication

All API requests require authentication using an API key. Include your key in the Authorization header as a Bearer token.

Authorization HeaderHTTP
Authorization: Bearer sk_live_your_api_key_here
Test Keys

Prefix: sk_test_

Use for development and testing. Rate limited to 100 req/min.

Live Keys

Prefix: sk_live_

Use for production. Higher rate limits based on your plan.

Generate API keys in your account dashboard. Keep your keys secure and never expose them in client-side code.

Endpoints

The API provides endpoints for text redaction, document processing, and batch operations.

POST/redactRedact PII from text
POST/redact/documentProcess documents
POST/redact/batchBatch processing
POST/redact/streamStreaming redaction
GET/entitiesList entity types
GET/usageGet usage stats

Text Redaction

The primary endpoint for redacting PII from text. Supports both standard (pattern-based) and enhanced (ML-powered) detection modes.

RequestcURL
curl -X POST https://api.privaishield.com/v1/redact \
  -H "Authorization: Bearer sk_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Contact John Smith at john@acme.com or 555-123-4567",
    "mode": "enhanced",
    "entities": ["PERSON", "EMAIL", "PHONE"],
    "returnOriginal": false
  }'
Request Parameters
textstringrequiredThe text to redact (max 100KB)
mode"standard" | "enhanced"Detection mode (default: enhanced)
entitiesstring[]Entity types to detect (default: all)
returnOriginalbooleanInclude original values (default: false)
confidencenumberMinimum confidence threshold (0-1)
ResponseJSON
{
  "redacted": "Contact [PERSON_1] at [EMAIL_1] or [PHONE_1]",
  "entities": [
    {
      "type": "PERSON",
      "token": "[PERSON_1]",
      "start": 8,
      "end": 18,
      "confidence": 0.97
    },
    {
      "type": "EMAIL",
      "token": "[EMAIL_1]",
      "start": 22,
      "end": 35,
      "confidence": 0.99
    },
    {
      "type": "PHONE",
      "token": "[PHONE_1]",
      "start": 39,
      "end": 51,
      "confidence": 0.95
    }
  ],
  "mode": "enhanced",
  "processingTime": "47ms"
}

Document Processing

Process documents (PDF, DOCX, TXT) and receive redacted content. Documents are processed page-by-page with full text extraction.

RequestcURL
curl -X POST https://api.privaishield.com/v1/redact/document \
  -H "Authorization: Bearer sk_live_your_key" \
  -F "file=@contract.pdf" \
  -F "mode=enhanced" \
  -F "outputFormat=pdf"
Supported Formats
PDFDOCXDOCTXTRTFCSVXLSX
ResponseJSON
{
  "documentId": "doc_abc123",
  "pages": 5,
  "totalEntities": 23,
  "processingTime": "1.2s",
  "downloadUrl": "https://api.privaishield.com/v1/documents/doc_abc123/download",
  "expiresAt": "2024-01-15T12:00:00Z"
}

Streaming

Stream redaction results in real-time using Server-Sent Events (SSE). Ideal for long documents or when you want to show progress.

RequestcURL
curl -X POST https://api.privaishield.com/v1/redact/stream \
  -H "Authorization: Bearer sk_live_your_key" \
  -H "Accept: text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{"text": "Long document content...", "mode": "enhanced"}'
Response (SSE)text
event: entity
data: {"type":"PERSON","token":"[PERSON_1]","confidence":0.97}

event: entity
data: {"type":"EMAIL","token":"[EMAIL_1]","confidence":0.99}

event: progress
data: {"processed":50,"total":100}

event: complete
data: {"redacted":"...","totalEntities":5,"processingTime":"120ms"}

Batch Processing

Process multiple texts in a single request. Ideal for high-volume pipelines with up to 100 items per batch.

RequestcURL
curl -X POST https://api.privaishield.com/v1/redact/batch \
  -H "Authorization: Bearer sk_live_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "items": [
      {"id": "1", "text": "Email: john@example.com"},
      {"id": "2", "text": "Phone: 555-123-4567"},
      {"id": "3", "text": "SSN: 123-45-6789"}
    ],
    "mode": "enhanced"
  }'
ResponseJSON
{
  "results": [
    {"id": "1", "redacted": "Email: [EMAIL_1]", "entities": [...]},
    {"id": "2", "redacted": "Phone: [PHONE_1]", "entities": [...]},
    {"id": "3", "redacted": "SSN: [SSN_1]", "entities": [...]}
  ],
  "totalItems": 3,
  "totalEntities": 3,
  "processingTime": "89ms"
}

Rate Limits

Rate limits vary by plan. Headers in each response indicate your current usage and limits.

PlanRequests/minBatch sizeMax text size
Free601010KB
Pro60050100KB
Business3,0001001MB
EnterpriseCustomCustomCustom
Rate Limit Headers
X-RateLimit-LimitMaximum requests per minute
X-RateLimit-RemainingRequests remaining in current window
X-RateLimit-ResetUnix timestamp when limit resets

Error Handling

The API uses standard HTTP status codes. Errors include a JSON body with details about what went wrong.

Error ResponseJSON
{
  "error": {
    "code": "invalid_request",
    "message": "The 'text' field is required",
    "param": "text",
    "type": "validation_error"
  }
}
HTTP Status Codes
200OKRequest succeeded
400Bad RequestInvalid request parameters
401UnauthorizedInvalid or missing API key
403ForbiddenInsufficient permissions
429Too Many RequestsRate limit exceeded
500Internal ErrorServer error (retry with backoff)