Skip to main content
The PII filter scans LLM responses flowing through the MeshAI proxy for personally identifiable information. You choose how PII is handled: block the response entirely, redact PII inline, or allow it through with logging. Configured as a standard governance policy.

Supported PII Types

PII TypePatternRedacted As
emailEmail addresses[EMAIL_REDACTED]
phonePhone numbers (international formats)[PHONE_REDACTED]
ssnUS Social Security Numbers[SSN_REDACTED]
credit_cardCredit/debit card numbers (Luhn-validated)[CREDIT_CARD_REDACTED]
ip_addressIPv4 and IPv6 addresses[IP_REDACTED]
passportPassport numbers (common formats)[PASSPORT_REDACTED]
ibanInternational Bank Account Numbers[IBAN_REDACTED]
date_of_birthDate of birth patterns[DOB_REDACTED]

Three Modes

ModeBehaviorHTTP Status
blockReject the entire response if any PII is found403
redactReplace PII with placeholder tokens and return the modified response200
allowPass the response through unchanged, but log PII occurrences200

Configure via Policy

Create a pii_filter policy to enable PII detection:
curl -X POST https://api.meshai.dev/governance/policies \
  -H "Authorization: Bearer msh_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "redact-pii-in-responses",
    "policy_type": "pii_filter",
    "config": {
      "mode": "redact",
      "pii_types": ["email", "ssn", "credit_card", "phone"]
    },
    "scope": "global",
    "enabled": true
  }'
{
  "success": true,
  "data": {
    "id": "pol_pii_001",
    "name": "redact-pii-in-responses",
    "policy_type": "pii_filter",
    "config": {
      "mode": "redact",
      "pii_types": ["email", "ssn", "credit_card", "phone"]
    },
    "scope": "global",
    "enabled": true,
    "created_at": "2026-03-18T10:00:00Z"
  }
}

Mode Examples

Block Mode

Block any response containing PII. The agent receives a 403:
curl -X POST https://api.meshai.dev/governance/policies \
  -H "Authorization: Bearer msh_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "block-all-pii",
    "policy_type": "pii_filter",
    "config": {
      "mode": "block",
      "pii_types": ["email", "ssn", "credit_card", "phone", "ip_address", "passport", "iban"]
    },
    "scope": "global",
    "enabled": true
  }'
The agent sees:
{
  "error": "Policy violation: pii_filter — response blocked due to detected PII (email, ssn)",
  "policy_id": "pol_pii_001",
  "status": 403
}

Redact Mode

PII is replaced inline before the response reaches the agent: Original LLM response:
Please contact John at john.doe@example.com or call 555-123-4567.
After redaction:
Please contact John at [EMAIL_REDACTED] or call [PHONE_REDACTED].

Allow Mode

The response passes through unchanged. PII occurrences are logged in the audit trail for review:
curl -X POST https://api.meshai.dev/governance/policies \
  -H "Authorization: Bearer msh_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "log-pii-only",
    "policy_type": "pii_filter",
    "config": {
      "mode": "allow",
      "pii_types": ["email", "ssn", "credit_card"]
    },
    "scope": "global",
    "enabled": true
  }'

Selective PII Types

You control exactly which PII types to scan for. Only the types listed in pii_types are checked — unlisted types are ignored:
{
  "mode": "redact",
  "pii_types": ["email", "ssn"]
}
This configuration redacts emails and SSNs but allows phone numbers, credit cards, and other PII through unchanged.

Audit Trail

Every PII detection event is logged:
Event TypeDescription
pii.detectedPII found in response (includes types found, mode, and action taken)
policy.violatedResponse blocked due to PII (block mode only)
Query PII-related audit events:
curl "https://api.meshai.dev/governance/audit-trail?event_type=pii.detected" \
  -H "Authorization: Bearer msh_YOUR_API_KEY"

Enforcement Architecture

  • Scan path: Proxy scans LLM response body after receiving it from the provider, before returning to the agent.
  • Latency: PII scanning adds < 5ms overhead per response.
  • Streaming: For streaming responses, PII detection runs on buffered chunks.
  • Fail-open: If the scanner errors, the response proceeds unchanged (logged as a warning).