piidetectionapi.com
Home
Solutions - Fundamentals
What Is PII Detection? NER vs Regex vs Rules Accuracy, Precision & Recall PII in Test Data
Solutions - Compliance
GDPR Personal Data HIPAA PHI Detection CCPA / CPRA PCI DSS Card Data
Solutions - AI & LLM Safety
LLM Guardrails Chatbot PII Filtering RAG Pipelines
Solutions - Data Discovery & DLP
Data Loss Prevention Log File Scanning Support Tickets Email Scanning Documents & PDFs Database Discovery ETL & Streaming Pipelines
Industries - Financial
Banking Fintech Insurance
Industries - Healthcare
Healthcare Pharma & Clinical Trials Telehealth
Industries - Public Sector & Legal
Government & FOIA Law Enforcement Law Firms & eDiscovery Education (FERPA)
Industries - Technology
SaaS Platforms Cybersecurity & IR Telecommunications Gaming & Platforms
Industries - Other
HR & Recruiting Retail & E-commerce Call Centers & BPO Real Estate Travel & Hospitality Marketing & AdTech
How-to Guides - Identity & Contact
Detect Names Detect Email Addresses Detect Phone Numbers Detect Physical Addresses Detect Dates of Birth
How-to Guides - IDs & Financial
Detect SSNs Detect Passport Numbers Detect Drivers Licenses Detect Credit Card Numbers Detect Bank Accounts & IBAN
How-to Guides - Technical & Health
Detect IP & Device IDs Detect Medical Records & PHI
Resources
Pricing API Docs Supported Entities Languages About Contact Sign In Try the Live Demo Get Started

Your First PII Detection Request

A step-by-step tutorial that takes you from zero to a working detection call in about five minutes: get an API key, send one POST request, and read back every sensitive entity in your text with its type, position, and confidence.

~5 minutes cURL · Python · JavaScript 150+ entity types
1

Get your API key

Every request is authenticated with an API key. Create an account on the Get Started page — after signing up you will find your key in the dashboard. It looks something like this:

Your API key: pk_a1b2c3d4e5f67890abcdef1234567890

Treat the key like a password: keep it in an environment variable or a secrets manager, never in client-side code or a public repository. If you just want to see detection results before signing up, the live demo runs without a key.

2

Send your first request with cURL

The API has a single endpoint that accepts a JSON body: POST https://piidetectionapi.com/api/moderate.php. Three fields are required — your api_key, the api_type (always "pii_detection"), and the text to scan (up to 50,000 characters per request). Paste this into a terminal, replacing YOUR_API_KEY:

Terminal
curl -X POST https://piidetectionapi.com/api/moderate.php \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "YOUR_API_KEY",
    "api_type": "pii_detection",
    "text": "Contact John Doe at [email protected] or 555-123-4567."
  }'
 No language or format hints needed. The model auto-detects the language (60+ supported — see supported languages) and scans for all 150+ entity types by default.
3

Read the response

The API answers with a JSON object. The heart of it is detected_entities: one item per finding, with the entity type, the exact matched text, its character offsets in your input, and a confidence score:

Response — 200 OK
{
  "detected_entities": [
    {"type": "PERSON_NAME", "text": "John Doe", "start": 8, "end": 16, "confidence": 0.95},
    {"type": "EMAIL_ADDRESS", "text": "[email protected]", "start": 20, "end": 36, "confidence": 0.98},
    {"type": "PHONE_NUMBER", "text": "555-123-4567", "start": 40, "end": 52, "confidence": 0.99}
  ],
  "anonymized_text": "Contact [NAME] at [EMAIL] or [PHONE].",
  "entities_detected": 3,
  "processing_time_ms": 187,
  "mask_mode_used": "replace",
  "status": 200
}
FieldMeaning
detected_entitiesArray of findings. Each has type, text (exact match), start/end (character offsets in your input), and confidence (0–1).
anonymized_textYour input with detected values masked — the optional redaction step, controlled by mask_mode.
entities_detectedTotal number of findings.
processing_time_msServer-side processing time in milliseconds.
status200 on success; any other value comes with an error message.
 That's a complete detection. The offsets let you highlight or redact entities yourself; anonymized_text gives you a ready-made masked copy for free.
4

The same request in Python and JavaScript

In an application you will usually call the API from code. With Python's requests:

Python 3 — requests
import requests

resp = requests.post(
    "https://piidetectionapi.com/api/moderate.php",
    json={
        "api_key": "YOUR_API_KEY",
        "api_type": "pii_detection",
        "text": "Contact John Doe at [email protected] or 555-123-4567.",
    },
    timeout=30,
)
data = resp.json()
for e in data["detected_entities"]:
    print(e["type"], e["text"], e["start"], e["end"], e["confidence"])

And with JavaScript (Node 18+ or any modern runtime with fetch):

JavaScript — fetch
const resp = await fetch("https://piidetectionapi.com/api/moderate.php", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    api_key: process.env.PII_API_KEY,
    api_type: "pii_detection",
    text: "Contact John Doe at [email protected] or 555-123-4567.",
  }),
});
const data = await resp.json();
console.log(data.entities_detected, "entities found");
data.detected_entities.forEach(e =>
  console.log(`${e.type}: "${e.text}" @ ${e.start}-${e.end} (${e.confidence})`)
);
5

Narrow the scan to the entities you care about

By default every entity type is scanned. Two optional arrays give you precise control: entities is an allowlist, exclude_entities a blocklist. For a PCI sweep of support tickets, for example, you only need payment data and direct identifiers:

Request body — entity filtering
{
  "api_key": "YOUR_API_KEY",
  "api_type": "pii_detection",
  "text": "Card 4111 1111 1111 1111, CVV 123, cardholder Jane Roe",
  "entities": ["CREDIT_CARD_NUMBER", "CVV_NUMBER", "PERSON_NAME", "IBAN_CODE"]
}

The full catalogue — from SSN and PASSPORT_NUMBER to DIAGNOSIS, API_KEY, and GPS_COORDINATES — is on the supported entity types reference, grouped by category with examples.

6

Tune confidence and masking

Two more optional fields shape the result. threshold (default 0.5) sets the minimum confidence a finding needs to be reported — raise it toward 0.8–0.9 when false positives are costly, lower it when you must not miss anything. mask_mode chooses how anonymized_text is built:

mask_modeBehaviorExample output
replace (default)Substitutes typed placeholders.Contact [NAME] at [EMAIL]
redactRemoves the sensitive values entirely.Contact  at  ...
hashReplaces each value with a consistent hash, so the same person stays linkable across records without being identifiable.Contact e3b0c44a at a5f2d1c9
Request body — threshold + mask_mode + custom instruction
{
  "api_key": "YOUR_API_KEY",
  "api_type": "pii_detection",
  "text": "Escalated by Jane Roe ([email protected]) about Acme Corp invoice 4482.",
  "threshold": 0.8,
  "mask_mode": "replace",
  "custom_instruction": "Do not flag the company name 'Acme Corp' or invoice numbers"
}
 Handle non-200 statuses. Check status in every response: 400 means a malformed request (e.g. missing api_key), 401/403 an invalid key, 429 a rate limit. The error field explains what went wrong — log it, back off, and retry where appropriate.