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
Quick Start Guide

Start Detecting PII in Minutes

Getting started with PII Detection API is simple. Sign up, grab your API key, and send a single JSON request to find, classify, and locate sensitive data in any text. One endpoint, structured results with character offsets and confidence scores, and an optional masked output when you need it.

5 min
Setup Time
150+
Entity Types
60+
Languages
Step by Step

Four Steps to Your First Detection

From signup to a parsed detected_entities array in under 5 minutes. No SDK required — any HTTP client works.

Create Your Account

Pick the plan that matches your monthly scanning volume on the pricing page and register. Every plan includes the full detection engine: all 150+ entity types, custom detection instructions, confidence scores, and every mask mode. If you want to see results before signing up, try the interactive demo first.

1 minute
1
2

Get Your API Key

Your API key is shown in the dashboard right after registration. It authenticates every request, so treat it like a password: keep it out of source control and load it from an environment variable or secret manager.

30 seconds
Environment Variable
export PII_API_KEY="your_api_key_here"

Send Your First Detection Request

POST a JSON body to the detection endpoint. Only three fields are required: your api_key, the api_type value "pii_detection", and the text to scan (up to 50,000 characters per request). Everything else — entity filters, mask mode, threshold — is optional.

2 minutes
cURL
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."
  }'
3
4

Read the Detected Entities

The response is structured JSON. Iterate over detected_entities to get each finding's type, matched text, character offsets, and confidence score — and use anonymized_text if you asked for a masked copy of the input.

1 minute
JSON Response
{
  "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}
  ],
  "anonymized_text": "Contact [NAME] at [EMAIL] ...",
  "entities_detected": 2,
  "processing_time_ms": 187,
  "mask_mode_used": "replace",
  "status": 200
}
Any Language

One REST Endpoint, Any HTTP Client

The API is plain JSON over HTTPS — no proprietary SDK to learn. These snippets send the same detection request from Python, Node.js, and PHP.

Python (requests)
import os, requests

resp = requests.post(
    "https://piidetectionapi.com/api/moderate.php",
    json={
        "api_key": os.environ["PII_API_KEY"],
        "api_type": "pii_detection",
        "text": "Contact John Doe at [email protected] or 555-123-4567.",
        "mask_mode": "replace",
    },
    timeout=30,
)
data = resp.json()
for e in data["detected_entities"]:
    print(e["type"], e["text"], e["start"], e["end"], e["confidence"])
JavaScript (Node.js 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.",
    mask_mode: "replace"
  })
});

const data = await resp.json();
for (const e of data.detected_entities) {
  console.log(e.type, e.text, e.start, e.end, e.confidence);
}
PHP (cURL)
<?php
$ch = curl_init("https://piidetectionapi.com/api/moderate.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    "api_key"  => getenv("PII_API_KEY"),
    "api_type" => "pii_detection",
    "text"     => "Contact John Doe at [email protected] or 555-123-4567.",
]));
$data = json_decode(curl_exec($ch), true);
foreach ($data["detected_entities"] as $e) {
    echo $e["type"] . ": " . $e["text"] . PHP_EOL;
}
?>

Reading detected_entities

Every response gives you a complete, machine-readable picture of what was found — not just a scrubbed string. That makes the API equally useful for compliance audits, DLP alerting, log scanning, and pre-processing text before it reaches an LLM.

type: The entity classification, such as PERSON_NAME, EMAIL_ADDRESS, SSN, or CREDIT_CARD_NUMBER — one of 150+ supported types listed on the entities page.

text, start, end: The exact matched text and its character offsets in your input, so you can highlight findings, build your own redaction layer, or map detections back to source documents.

confidence: A score from 0 to 1 for each detection. Combine it with the request-level threshold parameter to trade precision against recall for your use case.

anonymized_text & entities_detected: An optional masked copy of the input plus summary counts and processing_time_ms for monitoring.

Full API Reference

Choosing Which Entity Types to Detect

By default the API scans for all 150+ entity types. In production you usually want a narrower, faster signal — and the request body gives you precise control.

entities: An allowlist of types to detect, e.g. ["PERSON_NAME", "EMAIL_ADDRESS", "SSN"]. Anything not listed is ignored.

exclude_entities: The inverse — detect everything except the listed types. Handy when, say, URLs or countries are expected content rather than sensitive data.

threshold: Minimum confidence from 0 to 1 (default 0.5). Raise it to cut false positives in noisy text; lower it when missing a real identifier is the bigger risk.

custom_instruction: Up to 500 characters of natural-language guidance, such as "do not flag employee names of our own support staff" — no regex required.

Python — targeted detection
resp = requests.post(
    "https://piidetectionapi.com/api/moderate.php",
    json={
        "api_key": os.environ["PII_API_KEY"],
        "api_type": "pii_detection",
        "text": ticket_text,
        "entities": ["PERSON_NAME", "EMAIL_ADDRESS", "PHONE_NUMBER"],
        "threshold": 0.7,
    },
    timeout=30,
)
Browse All Entity Types
Optional Masking

Pick a mask_mode for the Output

Detection always returns the entity list. The mask_mode parameter controls how anonymized_text is produced when you also want a safe copy of the input.

mask_mode What it does Example output Best for
replace Default. Substitutes each entity with a typed placeholder, preserving readability and meaning. Contact [NAME] at [EMAIL] Support tickets, chat logs, LLM prompts where context must survive
redact Removes the detected entities from the text entirely. Contact at Publishing, FOIA-style disclosure, strict minimization
hash Replaces each entity with a consistent hash, so the same value always maps to the same token. Contact 3f9a1c… at b82e77… Analytics, deduplication, joining records without exposing identities
cURL — hashed masking
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": "Refund issued to [email protected] for card 4111 1111 1111 1111.",
    "entities": ["EMAIL_ADDRESS", "CREDIT_CARD_NUMBER"],
    "mask_mode": "hash"
  }'
Pricing

Plans That Scale With Your Scanning Volume

Every plan includes all 150+ entity types, custom detection instructions, and every mask mode. Pick a monthly word volume — upgrade any time.

Advanced

$499/month

9 million words per month — scale with confidence

  • Everything in Pro
  • Higher monthly volume
  • Production-scale scanning
  • Ideal for log & pipeline scans
  • Upgrade path to 100M+ words
Compare All Plans

Enterprise Plus

Custom

500M+ words, tailored terms for large organizations

  • Unlimited-scale volumes
  • Dedicated support & SLA
  • On-premise deployment options
  • Compliance-focused onboarding
  • Custom entity types
Contact Sales

Best Practices for Integration

A few habits make PII detection reliable in production, whether you are scanning support tickets, application logs, or text headed into an LLM.

Chunk large inputs: Each request accepts up to 50,000 characters. Split longer documents on natural boundaries (paragraphs, log lines) and remember that offsets in detected_entities are relative to the text you sent in that request.

Handle errors and retries: Check the response status field, apply retries with exponential backoff for transient network failures, and set a sensible client timeout (30 seconds is a good default).

Tune the threshold per use case: Start at the default 0.5, then review real detections. Compliance scans usually favor recall (lower threshold); user-facing filters favor precision (higher threshold).

Watch your quota: Usage is measured in words and returned in every response, so you can alert before hitting your monthly plan limit and upgrade in time.

What Is PII Detection?
Keep Going

Next Steps and Resources

Deepen your integration with entity references, language coverage, and use-case guides.

FAQ

Getting Started Questions

Common questions about setting up and using the PII Detection API.

What do I need to make my first request?
Just an API key and any HTTP client. Send a POST request to https://piidetectionapi.com/api/moderate.php with a JSON body containing your api_key, the api_type value "pii_detection", and the text to scan. Optional fields like entities, mask_mode, threshold, and custom_instruction refine the results but are not required.
Can I try detection before signing up?
Yes. The interactive demo at /demo-18.php runs the same detection engine as the API: paste any text and see the detected entities and masked output immediately, no account required. When you are ready to integrate, pick a plan on the pricing page and you will get an API key right away.
How is my usage counted?
Usage is measured in words. Each request deducts the words in your submitted text plus a fixed allowance of 1,500 words for the detection instruction set that accompanies every request to the model. The exact figures come back in every API response, so your application can track consumption and alert before you reach your monthly plan volume.
How long can the text in one request be?
Up to 50,000 characters per request. For longer documents, split the content into chunks on natural boundaries such as paragraphs or log lines and send one request per chunk. Character offsets in detected_entities are relative to the text submitted in that request, so keep track of each chunk's position if you need document-level offsets.
What is the difference between the mask modes?
"replace" (the default) swaps each detected entity for a typed placeholder like [NAME] or [EMAIL], keeping the text readable. "redact" removes the entities entirely for strict minimization. "hash" substitutes a consistent hash so the same value always produces the same token — useful for analytics and joining records without exposing identities. In every mode you still receive the full detected_entities list.
Does the API store the text I send?
Requests are processed in real time over HTTPS and content is not retained after the response is returned; only operational metadata such as word counts and timestamps is kept for billing and monitoring. Organizations with strict data residency requirements can also ask about on-premise deployment via the contact page.

Ready to Find Sensitive Data?

Detect, classify, and locate PII with context-aware AI. Try the live demo or pick a plan and send your first request today.