HTTP endpoints. Bearer token auth. Curl, Python, Node.js examples. Sub-200ms latency. No SDKs required. Full REST semantics.
Base URL: https://anonym.legal/api/presidio
Auth: Authorization: Bearer YOUR_API_KEY
All endpoints support POST with JSON body. Responses are JSON.
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": 13,
"end": 31,
"score": 0.99
},
{
"entity_type": "US_SSN",
"start": 42,
"end": 54,
"score": 0.99
}
]
}
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": [...],
"operators": {
"DEFAULT": {
"type": "mask",
"chars_to_mask": 4
},
"US_SSN": {
"type": "mask",
"chars_to_mask": 9
}
}
}
Response:
{
"text": "My email is ████████@example.com and SSN is █████-6789"
}
Process multiple texts in parallel
POST /api/presidio/batch_anonymize
Authorization: Bearer KEY
Content-Type: application/json
{
"texts": [
"SSN: 123-45-6789",
"Email: alice@test.com",
"Phone: 555-123-4567"
],
"language": "en",
"method": "mask"
}
Response:
{
"results": [
{ "original": "SSN: 123-45-6789", "anonymized": "SSN: █████-6789" },
{ "original": "Email: alice@test.com", "anonymized": "Email: █████@test.com" },
{ "original": "Phone: 555-123-4567", "anonymized": "Phone: ███-123-4567" }
]
}
Upload and scan PDF, DOCX, XLSX
POST /api/presidio/scan_file
Authorization: Bearer KEY
Content-Type: multipart/form-data
file:
language: en
Response:
{
"file_name": "contract.pdf",
"file_type": "pdf",
"pii_count": 47,
"entities": [
{ "entity_type": "EMAIL_ADDRESS", "count": 12, "confidence": 0.98 },
{ "entity_type": "US_SSN", "count": 3, "confidence": 0.99 },
{ "entity_type": "CREDIT_CARD", "count": 5, "confidence": 0.97 }
]
}
List all 285+ available entity types
GET /api/presidio/get_entities?language=en&domain=healthcare
Authorization: Bearer KEY
Response:
{
"entities": [
{ "type": "US_SSN", "category": "IDENTIFIER", "description": "US Social Security Number" },
{ "type": "EMAIL_ADDRESS", "category": "CONTACT", "description": "Email addresses" },
{ "type": "CREDIT_CARD", "category": "FINANCIAL", "description": "Credit card numbers" },
{ "type": "MEDICAL_LICENSE", "category": "HEALTHCARE", "description": "Medical license number" },
...
],
"total": 285,
"language": "en",
"domain_filtered": "healthcare"
}
Estimate token cost before processing
POST /api/presidio/estimate
Authorization: Bearer KEY
Content-Type: application/json
{
"text_length": 5000,
"entities_count": 15,
"method": "mask"
}
Response:
{
"estimated_tokens": 42,
"estimated_cost_usd": 0.021,
"processing_time_ms": 180,
"currency": "USD"
}
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']
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 -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"
}'
Invalid or missing API key. Check token in Authorization header.
Invalid request body. Check JSON syntax and required fields.
Rate limit exceeded. Wait before retrying. Check Retry-After header.
Unexpected error. Retry with exponential backoff. Contact support if persistent.
Maintenance or regional outage. Retry on different endpoint. Check status page.
Request took too long. Consider batch size or file size. Contact support.
See PII detection and anonymization via REST API and MCP Server
Also from anonym.legal