Documentation

Everything you need to integrate Anonymize.dev into your workflow

MCP Server Setup

Configure your AI tools to use Anonymize.dev

Claude Desktop

Add this configuration to your claude_desktop_config.json:

JSON
{
  "mcpServers": {
    "anonymize": {
      "command": "npx",
      "args": ["-y", "@anonym-legal/mcp-server"],
      "env": {
        "ANONYM_API_KEY": "your-api-key"
      }
    }
  }
}
Config file locations:
macOS: ~/.config/claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json

Cursor IDE

Add to your Cursor MCP settings (Settings > Features > MCP):

JSON
{
  "mcpServers": {
    "anonymize": {
      "command": "npx",
      "args": ["-y", "@anonym-legal/mcp-server"],
      "env": {
        "ANONYM_API_KEY": "your-api-key"
      }
    }
  }
}

Environment Variables

Variable Required Description
ANONYM_API_KEY Yes Your API key from anonym.legal
ANONYM_METHOD No Default: replace. Options: replace, redact, hash, encrypt, mask
ANONYM_LANGUAGE No Default: auto. ISO 639-1 code (en, de, fr, etc.)

API Reference

REST API for direct integration

Base URL

https://api.anonym.legal/v1

Authentication

Include your API key in the Authorization header:

Authorization: Bearer your-api-key

POST /anonymize

Anonymize text and detect PII entities.

Request Body

JSON
{
  "text": "John Smith's email is john@example.com",
  "method": "replace",
  "language": "en",
  "entities": ["PERSON", "EMAIL"]
}

Response

JSON
{
  "anonymized": "Max Mueller's email is max.mueller@example.de",
  "entities": [
    {
      "type": "PERSON",
      "original": "John Smith",
      "replacement": "Max Mueller",
      "start": 0,
      "end": 10
    },
    {
      "type": "EMAIL",
      "original": "john@example.com",
      "replacement": "max.mueller@example.de",
      "start": 22,
      "end": 38
    }
  ],
  "tokens_used": 2
}

POST /deanonymize

Restore original values from tokenized text (only for encrypt method).

JSON
{
  "text": "enc_xK9mP2... email is enc_jL7nQ4...",
  "session_id": "abc123"
}

Code Examples

Ready-to-use code snippets

Python

Python
import requests

API_KEY = "your-api-key"
BASE_URL = "https://api.anonym.legal/v1"

def anonymize(text, method="replace"):
    response = requests.post(
        f"{BASE_URL}/anonymize",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json={
            "text": text,
            "method": method
        }
    )
    return response.json()

# Usage
result = anonymize("Contact John at john@example.com")
print(result["anonymized"])
# Output: "Contact Max Mueller at max.mueller@example.de"

JavaScript / Node.js

JavaScript
const API_KEY = 'your-api-key';
const BASE_URL = 'https://api.anonym.legal/v1';

async function anonymize(text, method = 'replace') {
  const response = await fetch(`${BASE_URL}/anonymize`, {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({ text, method })
  });
  return response.json();
}

// Usage
const result = await anonymize('Contact John at john@example.com');
console.log(result.anonymized);
// Output: "Contact Max Mueller at max.mueller@example.de"

cURL

Bash
curl -X POST https://api.anonym.legal/v1/anonymize \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Contact John at john@example.com",
    "method": "replace"
  }'

Anonymization Methods

Choose the right method for your use case

replace Default

Replaces PII with realistic fake data. Maintains document readability.

"John Smith" → "Max Mueller"
redact

Completely removes PII. Irreversible but maximum privacy.

"john@example.com" → "[REDACTED]"
hash SHA-256

One-way cryptographic hash. Consistent pseudonymization.

"555-0123" → "a7f3c9d2..."
encrypt AES-256-GCM

Military-grade encryption. Fully reversible with the correct key.

"DE89370400..." → "enc_xK9mP2..."
mask

Partial visibility with masked characters. Shows structure.

"4532-1234-5678-9012" → "4532-****-****-9012"

Need help?

Our team is ready to help you integrate Anonymize.dev into your workflow.