---
title: "Redact sensitive data from PDF"
method: POST
path: "/security/pdf/redact"
tags: ["Security"]
---

# Redact sensitive data from PDF

`POST /security/pdf/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/pdf/redact`
- Auth: API key in header `X-API-Key`

Automatically detect and redact sensitive information from PDF documents using AI.

## Compliance Presets

Choose a preset to match your regulatory requirements:

| Preset | Use Case |
|--------|----------|
| **auto** | General redaction - detects PII, financial, healthcare, legal data |
| **gdpr** | EU data protection - names, emails, IPs, phone numbers, national IDs |
| **hipaa** | Healthcare - patient names, medical records, insurance, prescriptions |
| **ferpa** | Education - student names, school records, educational IDs |
| **foia** | Government - classified content, addresses, government IDs |
| **glba** | Financial services - bank accounts, credit cards, loan records |
| **ccpa** | California privacy - purchase history, geolocation, online identifiers |
| **manual** | Custom rules only - use with `redaction_rules` parameter |

## Detection Categories

Enable specific detection types using boolean parameters (combine with presets for finer control):

| Parameter | Set to `true` to detect | Example data detected |
|-----------|------------------------|----------------------|
| `pii` | Personally identifiable information | Names, emails, phone numbers, addresses, birthdates |
| `phi` | Patient health information | Medical records, prescriptions, insurance info |
| `financial` | Financial data | Credit cards, bank accounts, transactions |
| `legal` | Legal/contractual data | Case numbers, contracts, legal clauses |
| `confidential` | Confidential business data | Trade secrets, internal communications, IP |

**Usage**: Pass each as a separate form field: `pii=true`, `phi=true`, etc.

## Custom Redaction Rules

For precise control, pass `redaction_rules` as JSON:

```json
[
  {"text": "john@domain.com"},
  {"detect": "Bank account number"},
  {"regex": "\\b\\d{3}-\\d{2}-\\d{4}\\b"}
]
```

## Example

```python
import httpx
import base64

response = httpx.post(
    "https://api.filegraph.ai/security/pdf/redact",
    headers={"X-API-Key": "your-api-key"},
    files={"file": open("sensitive.pdf", "rb")},
    data={
        "preset": "hipaa",
        "minimum_confidence": "0.7",
        "pii": "true",       # Enable PII detection
        "financial": "true"  # Also detect financial data
    }
)

result = response.json()
print(f"Redacted {result['redactions_found']} items")

# Save the redacted PDF
output = base64.b64decode(result["content_base64"])
with open("redacted.pdf", "wb") as f:
    f.write(output)
```

> **Note**: This endpoint applies visual redactions (black boxes) to PDFs.
> If you need text output with category tags like `[SSN]` or `[EMAIL]`,
> use `/security/text/redact` instead.

## Response `200`

Successful Response

- RedactResponse: Response for PDF redaction operation.
  - `filename` string, required: Output filename
  - `content_type` string, required: MIME type of the file
  - `size_bytes` integer, required: File size in bytes
  - `content_base64` string, required: Base64-encoded file content
  - `redactions_found` integer, required: Number of redactions applied to the document
  - `pages_processed` integer, required: Number of pages processed
  - `preset_used` string, required: Redaction preset that was applied

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/filegraph/apis/docconvert-api.md) · [All operations](https://skmtc.dev/filegraph/apis/docconvert-api/llms.txt) · [OpenAPI document](https://skmtc.dev/filegraph/apis/docconvert-api/revisions/436255c85bd4?raw)
