REST API

Call Privacy APIs Directly

HTTP endpoints. Bearer token auth. Curl, Python, Node.js examples. Synchronous API. No SDK needed: any HTTP client works. Full REST semantics.

Base Endpoints

Base URL: https://anonym.legal/api/presidio

Auth: Authorization: Bearer YOUR_API_KEY

Text endpoints (analyze, anonymize, deanonymize, batch) take a POST with a JSON body and answer with JSON. The image endpoint takes multipart/form-data. The entity catalog is a GET.

Endpoint Reference

/analyze

Detect PII entities in text

POST /api/presidio/analyze
Authorization: Bearer KEY
Content-Type: application/json

{
  "text": "My email is john@example.com and SSN is 123-45-6789",
  "language": "en"
}

Response:
{
  "results": [
    {
      "entity_type": "EMAIL_ADDRESS",
      "start": 12,
      "end": 28,
      "score": 0.99
    },
    {
      "entity_type": "US_SSN",
      "start": 40,
      "end": 51,
      "score": 0.99
    }
  ]
}

/anonymize

Redact PII from text

POST /api/presidio/anonymize
Authorization: Bearer KEY
Content-Type: application/json

{
  "text": "My email is john@example.com and SSN is 123-45-6789",
  "language": "en",
  "analyzer_results": [
    { "entity_type": "EMAIL_ADDRESS", "start": 12, "end": 28, "score": 0.99 },
    { "entity_type": "US_SSN", "start": 40, "end": 51, "score": 0.99 }
  ],
  "operators": {
    "EMAIL_ADDRESS": { "type": "replace", "new_value": "<EMAIL>" },
    "US_SSN": { "type": "replace", "new_value": "<SSN>" }
  }
}

Response:
{
  "text": "My email is <EMAIL> and SSN is <SSN>",
  "items": [ ... ],
  "tokens_charged": 2
}

/batch

Detect PII in several texts in one call

POST /api/presidio/batch
Authorization: Bearer KEY
Content-Type: application/json

{
  "texts": [
    "SSN: 123-45-6789",
    "Email: alice@test.com"
  ],
  "language": "en"
}

Response:
{
  "results": [
    { "index": 0, "results": [ { "entity_type": "US_SSN", "start": 5, "end": 16, "score": 0.99 } ] },
    { "index": 1, "results": [ { "entity_type": "EMAIL_ADDRESS", "start": 7, "end": 21, "score": 0.99 } ] }
  ],
  "failedIndexes": [],
  "total": 2,
  "language": "en",
  "tokens_charged": 2
}

Maximum texts per call: 5 (Basic), 10 (Pro), 50 (Business)

/image

Detect or redact PII in a PNG or JPEG image

POST /api/presidio/image
Authorization: Bearer KEY
Content-Type: multipart/form-data

file: document.png
mode: analyze | redact
language: en

Response (mode=analyze, JSON):
{
  "entities": [
    { "entity_type": "PERSON", "score": 0.95, "left": 120, "top": 80, "width": 140, "height": 24 }
  ],
  "processing_time": 0.83,
  "tokens_charged": 4
}

Response (mode=redact): the redacted image as image/png

/deanonymize

Reverse text that was anonymized with the encrypt operator

POST /api/presidio/deanonymize
Authorization: Bearer KEY
Content-Type: application/json

{
  "text": "Contact ENC:base64... today",
  "anonymizer_results": [
    { "entity_type": "EMAIL_ADDRESS", "start": 8, "end": 21 }
  ],
  "deanonymizers": {
    "EMAIL_ADDRESS": { "type": "decrypt", "key": "YOUR_16_24_OR_32_CHAR_KEY" }
  }
}

Response:
{
  "text": "Contact john@example.com today",
  "items": [ ... ],
  "tokens_charged": 1
}

GET /api/public/entities

List publicly shared custom entity definitions (no authentication)

GET /api/public/entities?page=1&limit=20&search=employee

Response:
{
  "success": true,
  "entities": [
    { "id": "...", "name": "...", "description": "...", "data": { ... } }
  ],
  "pagination": { "page": 1, "limit": 20, "total": 1, "totalPages": 1 }
}

No. There is no SDK package. The REST API works with any HTTP client: call it with requests in Python or fetch in Node.js. Code examples are on the Code Examples page.

The MCP Server exposes 9 privacy tools, for example anonym_legal_analyze_text, anonym_legal_anonymize_text and anonym_legal_detokenize_text, that MCP-capable agents can call directly. MCP access is included in Pro and Business. Prevents PII leakage in RAG pipelines and agent workflows.

The API is synchronous. Batch endpoints process arrays of text in a single call. The API runs on EU servers. Document content is not stored after processing, unless you use the optional history.

The API runs on our EU-hosted infrastructure. Document content is not stored after processing, unless you use the optional history. For enterprise self-hosting requirements, contact us.

Yes. Send arrays of text strings in a single API call. The batch endpoint (POST /api/presidio/batch) takes up to 5 texts per request on Basic, 10 on Pro and 50 on Business.

Free tier: 200 tokens per 30 days in the web app (API access starts with Basic). Basic: €3/month (1,000 tokens). Pro: €15/month (4,000 tokens, adds the MCP Server). Business: €29/month (10,000 tokens). What a call costs depends on text length and the entities found, so one call can cost more than one token.

Code Examples

Python

import requests

response = requests.post(
  'https://anonym.legal/api/presidio/analyze',
  headers={
    'Authorization': 'Bearer YOUR_KEY'
  },
  json={
    'text': 'SSN: 123-45-6789',
    'language': 'en'
  }
)

results = response.json()['results']

Node.js (Fetch)

const response = await fetch(
  'https://anonym.legal/api/presidio/analyze',
  {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      text: 'SSN: 123-45-6789',
      language: 'en'
    })
  }
);

const data = await response.json();

cURL

curl -X POST \
  https://anonym.legal/api/presidio/analyze \
  -H 'Authorization: Bearer YOUR_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "SSN: 123-45-6789",
    "language": "en"
  }'

Error Handling

401 Unauthorized

Invalid or missing API key. Check token in Authorization header.

400 Bad Request

Invalid request body. Check JSON syntax and required fields.

429 Too Many Requests

Rate limit exceeded. Wait before retrying. Check Retry-After header.

500 Server Error

Unexpected error. Retry with exponential backoff. Contact support if persistent.

503 Service Unavailable

Maintenance or temporary outage. Retry later.

504 Gateway Timeout

Request took too long. Consider batch size or file size. Contact support.

Pricing Model

Token Consumption

  • Cost depends on text length and the entities found
  • Analyze: 2 + 1 per 1,000 characters + 0.2 per entity type + 0.1 per finding, then ×0.5, rounded up
  • Anonymize: 1 + 0.2 per operation + 0.2 per 1,000 characters + 0.1 per finding (+0.8 with encryption), then ×0.5
  • Batch: same per-text rates, up to 5 / 10 / 50 texts per call (Basic / Pro / Business)
  • Current rates: anonym.legal/docs/token-system

Free Tier

  • 200 free tokens per 30 days (web app)
  • API access from Basic (€3/month)
  • Public docs access
  • Community support
  • No credit card required

Watch the API In Action

See PII detection and anonymization via REST API and MCP Server

Start Making API Calls

Start free with 200 tokens in the web app. API keys from Basic (€3/month). 5 minutes to first request.

Get API Key

Frequently Asked Questions

Free tier: 200 tokens per 30 days, web app only (no API access). Basic (€3/mo): 1,000 tokens. Pro (€15/mo): 4,000 tokens. Business (€29/mo): 10,000 tokens. No per-minute rate limits — use tokens at any pace. Need more? Token top-ups are available on every paid plan.

The API follows RESTful conventions with JSON request/response. Endpoints: POST /api/presidio/analyze (detect PII), POST /api/presidio/anonymize (replace, mask, hash or encrypt PII), POST /api/presidio/deanonymize (reverse encryption), POST /api/presidio/batch (several texts), POST /api/presidio/image (images). The machine-readable specification is at anonym.legal/openapi.json. Full documentation at anonym.legal/docs.

The API is synchronous. To process several texts in one call, use POST /api/presidio/batch.