PIIGuard / Detectors

Passport

Detects US passport numbers. Two formats: NGP (letter + 8 digits, current) and legacy (9 digits). No checksum exists — confidence is context-dependent.

Endpoint: POST /v1/pii/detect/passport

Validation & Confidence

Pattern match + optional context. NGP with prefix C/M/A scores highest.

NGP + context: 0.7–0.9. NGP without context: 0.4 (filtered by default). Legacy requires context: 0.8. Severity: high.

Example

from instructeer.guards import PIIGuard

# api_key = os.environ["INSTRUCTEER_API_KEY"]
pii = PIIGuard(api_key="rg_your_key")
result = pii.detect_passport("Passport number: A12345678")
// Response
{
  "entity_type": "US_PASSPORT",
  "value": "A12345678",
  "severity": "high",
  "confidence": 0.7,
  "extra": { "format": "ngp", "has_context": true }
}

Reference

ConditionConfidence
NGP (C/M/A prefix) + context0.9
NGP + context0.7
NGP, no context0.4 (filtered by default)
Legacy 9-digit + context0.8
Legacy 9-digit, no contextnot returned

Notes

  • Lower threshold: Immigration/travel apps can lower to min_confidence: 0.4 to catch NGP numbers without context.