Documentation/Redaction

Redaction

Experimental10 credits

GDPR-compliant PII detection and redaction. Automatically find and remove sensitive information from text with configurable masking or replacement.

Production Recommendation

This is a direct endpoint for development and testing. For production workloads, use the Data Intelligence Pipeline -- it provides structured Data Packages with quality metrics, is async by default, and is covered by Enterprise SLAs.

Overview

GDPR-compliant PII detection and redaction. Automatically find and remove sensitive information from text with configurable masking or replacement.

Key features:

  • 50+ PII types detected
  • Mask or replace modes
  • LLM refinement for accuracy
  • Confidence scores and audit trail
  • Custom regex patterns for domain-specific PII

API Reference

POSThttps://api.latence.ai/api/v1/redaction/detect_pii
Detect and redact PII from text

Request Parameters

ParameterTypeRequiredDefaultDescription
textstringInput text
config.redactbooleanWhether to redact detected PII
config.redaction_modestringRedaction mode: mask or replace
config.modestringDetection mode: balanced or strict
custom_labelsarrayCustom PII patterns (regex)

Response Fields

FieldTypeDescription
original_textstring
redacted_textstring
pii_detectedarray
successboolean
usageobject

Response Example

200 OKJSON
{
  "original_text": "Contact john.doe@email.com or call 555-123-4567",
  "redacted_text": "Contact [EMAIL] or call [PHONE_NUMBER]",
  "pii_detected": [
    {"text": "john.doe@email.com", "label": "EMAIL", "start": 8, "end": 26, "score": 1.0},
    {"text": "555-123-4567", "label": "PHONE_NUMBER", "start": 35, "end": 47, "score": 1.0}
  ],
  "success": true,
  "usage": { "credits": 1.0 }
}

Code Examples

from latence import Latence

client = Latence(api_key="YOUR_API_KEY")

# Detect and redact PII
result = client.experimental.redaction.detect_pii(
    text="Contact john.doe@email.com or call 555-123-4567 for support.",
    config={
        "redact": True,           # Actually redact, not just detect
        "redaction_mode": "mask"  # or "replace"
    }
)

print(result.redacted_text)
# Output: "Contact [EMAIL] or call [PHONE_NUMBER] for support."

print(f"Found {len(result.pii_detected)} PII entities:")
for pii in result.pii_detected:
    print(f"  - {pii.label}: {pii.text}")

Explore Tutorials & Notebooks

Deep-dive examples and interactive notebooks in our GitHub repository

View on GitHub

Looking for production-grade processing?

The Data Intelligence Pipeline chains services automatically and returns structured Data Packages.