Security

Redact PII from extracted text

Extract text from any document and redact PII with category tags.

How It Works

  1. Extract text from any supported format (PDF, DOCX, XLSX, PPTX, images, HTML, etc.)
  2. Detect PII using pattern matching and intelligent entity recognition
  3. Redact by replacing PII with category tags like [SSN], [EMAIL], [NAME]
  4. Return redacted text with audit metadata

PII Types Detected

TypeExample OutputConfidence
ssn[SSN]0.90
credit_card[CREDIT_CARD]0.95
email[EMAIL]0.98
phone[PHONE]0.85
ip_address[IP_ADDRESS]0.95
date_of_birth[DATE_OF_BIRTH]0.70
name[NAME]0.85
address[ADDRESS]0.85
organization[ORGANIZATION]0.85

Parameters

  • pii_types: Comma-separated list of types to detect, or "all" (default)
  • use_ner: Enable intelligent name/address/organization detection (default: true)
  • minimum_confidence: Threshold 0.0-1.0 (default: 0.8)
  • ocr_language: OCR language if needed (default: "eng")
  • ocr_fallback: Use OCR if text extraction fails (default: true)

Audit Metadata

The response includes masked values for compliance logging:

  • SSN: ***-**-6789
  • Email: j***@example.com
  • Phone: ***-***-7890
  • Credit Card: ************1234

Example

import httpx

response = httpx.post(
    "https://api.filegraph.ai/security/text/redact",
    headers={"X-API-Key": "your-api-key"},
    files={"file": open("document.pdf", "rb")},
    data={
        "pii_types": "ssn,email,phone,name",
        "use_ner": "true",
        "minimum_confidence": "0.8"
    }
)

result = response.json()
print(f"Found {result['pii_found']} PII instances")
print(result['redacted_text'])

# Audit log
for match in result['matches']:
    print(f"{match['pii_type']}: {match['masked_value']}")
post/security/text/redact

Request

  • Base URL: https://api.filegraph.ai (the document declares no server; this is the origin it was published from)
  • URL: https://api.filegraph.ai/security/text/redact
  • Auth: API key in header X-API-Key

Response

Successful Response

redacted_textstring required

Text with PII replaced by category tags

format_detectedstring required

Detected input format (pdf, docx, image, etc.)

word_countinteger required

Number of words in extracted text

char_countinteger required

Number of characters in extracted text

used_ocrboolean required

Whether OCR was used for text extraction

pii_foundinteger required

Total number of PII instances detected and redacted

pii_by_typeobject required

Count of PII by type: {'ssn': 3, 'email': 5}

processing_time_msinteger required

Total processing time in milliseconds

ner_enabledboolean required

Whether intelligent entity detection was used for names/addresses

Example response

{
  "char_count": 892,
  "format_detected": "pdf",
  "matches": [
    {
      "confidence": 0.85,
      "end_position": 16,
      "masked_value": "J*** D***",
      "pii_type": "name",
      "redacted_tag": "[NAME]",
      "start_position": 8
    },
    {
      "confidence": 0.98,
      "end_position": 36,
      "masked_value": "j***@example.com",
      "pii_type": "email",
      "redacted_tag": "[EMAIL]",
      "start_position": 20
    }
  ],
  "ner_enabled": true,
  "pii_by_type": {
    "email": 1,
    "name": 1,
    "phone": 1,
    "ssn": 1
  },
  "pii_found": 4,
  "processing_time_ms": 245,
  "redacted_text": "Contact [NAME] at [EMAIL] or [PHONE]. SSN: [SSN]",
  "used_ocr": false,
  "word_count": 150
}

Changes

No recorded changes to this operation across all 1 revision of this API.