Skip to main content

PII Removal

The PII Removal operation detects and removes personally identifiable information (PII) from messages to help ensure privacy compliance and data protection. It supports multiple PII types, replacement strategies, and format preservation options for comprehensive data sanitization.

Overview

Personally Identifiable Information (PII) poses significant privacy and compliance risks in AI systems. The PII Removal operation provides comprehensive protection by:

  • Detecting Multiple PII Types - Emails, phone numbers, SSNs, credit cards, addresses, and more
  • Flexible Handling Strategies - Redact, replace with realistic fake data, or remove entirely
  • Format Preservation - Maintain document structure and readability while protecting privacy
  • Compliance Support - Meet GDPR, CCPA, HIPAA, and other privacy regulations
  • Custom Pattern Support - Define organization-specific PII patterns

The operation uses advanced pattern matching and contextual analysis to accurately identify PII while minimizing false positives that could disrupt legitimate content.

Configuration

Basic Configuration

const config = {
types: ['email', 'phone', 'ssn', 'credit_card'], // PII types to detect
replacementStrategy: 'redact', // How to handle detected PII
preserveFormat: true, // Preserve original format
customPatterns: [] // User-defined patterns
}

Configuration Options

OptionTypeDefaultDescription
typesarray['email', 'phone', 'ssn']PII types to detect
replacementStrategystring'redact'How to handle detected PII
preserveFormatbooleantruePreserve original format when replacing
customPatternsarray[]Custom regex patterns for organization-specific PII
confidenceThresholdnumber0.8Minimum confidence score for PII detection

Supported PII Types

TypeDescriptionDetection Patterns
emailEmail addressesRFC 5322 compliant patterns
phonePhone numbersUS/International formats
ssnSocial Security NumbersXXX-XX-XXXX, XXXXXXXXX
credit_cardCredit card numbersVisa, MasterCard, Amex, Discover
ip_addressIP addressesIPv4 and IPv6 formats
addressPhysical addressesStreet addresses with context
namePerson namesFirst/last name combinations
date_of_birthBirth datesMultiple date formats
passportPassport numbersVarious country formats
license_plateLicense platesUS state formats
bank_accountBank account numbers8-17 digit sequences
routing_numberBank routing numbers9-digit ABA numbers

Replacement Strategies

StrategyBehaviorExample OutputUse Case
redactReplace with [REDACTED]Contact me at [REDACTED]Maximum privacy protection
replaceUse realistic fake dataContact me at jane@example.comMaintain readability
removeDelete PII entirelyContact me at Minimal data retention
maskPartially obscure dataContact me at j***@example.comBalance privacy and context

Examples

curl -X POST https://api.meta-prompt.com/v1/process \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"messages": [
{
"role": "user",
"content": "Please contact John Smith at john.smith@company.com or call 555-123-4567. His SSN is 123-45-6789."
}
],
"operations": [
{
"name": "piiRemoval",
"config": {
"types": ["email", "phone", "ssn", "name"],
"replacementStrategy": "redact",
"preserveFormat": true
}
}
]
}'

Response:

{
"messages": [
{
"role": "user",
"content": "Please contact [REDACTED] at [REDACTED] or call [REDACTED]. His SSN is [REDACTED]."
}
],
"operations": [
{
"name": "piiRemoval",
"result": {
"detectedPii": [
{"type": "name", "value": "John Smith", "position": [14, 24]},
{"type": "email", "value": "john.smith@company.com", "position": [28, 51]},
{"type": "phone", "value": "555-123-4567", "position": [60, 72]},
{"type": "ssn", "value": "123-45-6789", "position": [85, 96]}
],
"replacementCount": 4
}
}
]
}