> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zerodrift.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Remove PII and PHI

> Strip names, contact details, account numbers and other personal identifiers from text before you store it, share it, or send it to another model.

Personal information ends up in places it shouldn't: support tickets, chat logs, prompts sent to an LLM, and datasets shared with a vendor. The [Redact PII](https://docs.zerodrift.com/api-reference/redact/redact-text.md) endpoint returns your text with that information replaced or removed, so you can pass the clean version on.

Redaction runs on ZeroDrift's own PII detector. Your text is not sent to a third-party model API.

> [!WARNING]
>
> Redaction is best-effort, not a guarantee of complete anonymization. Read the
> [known gaps](https://docs.zerodrift.com/api-reference/redact/redact-text.md#known-gaps) before you rely on
> it in a regulated workflow.

## What it removes

| Category | Examples |
| - | - |
| `private_person` | Names of people |
| `private_email` | Email addresses |
| `private_phone` | Phone numbers |
| `private_address` | Street addresses |
| `private_date` | Dates tied to a person, such as a date of birth |
| `private_url` | URLs that point to a person |
| `account_number` | Card numbers, IBANs, US Social Security and tax ID numbers, routing numbers, SWIFT/BIC codes |

The detector supplements model findings with checksum or format checks for supported account-number types. Some valid card numbers can still be missed; see the [known gaps](https://docs.zerodrift.com/api-reference/redact/redact-text.md#known-gaps).

### Health information (PHI)

In health records, redaction removes the identifiers that tie a record to a patient: names, dates such as birth and admission, addresses, phone and fax numbers, email addresses, and ID numbers such as medical record numbers and health plan member IDs. Clinical content, such as diagnoses and medications, stays in the text.

Redaction is one step in a de-identification process, not a HIPAA de-identification on its own.

## Prerequisites

* An API key ([Quickstart](https://docs.zerodrift.com/quickstart.md), Step 1). Full-access and read-only keys both work.

## The pattern

```
text  →  POST /api/v3/content/redact  →  redacted text  →  store | share | send to a model
```

Use `mode: "sync"` for content up to 20,000 characters to get the redacted text back in the same response. Larger content, or a request that reaches the detector while it is starting up, comes back as `202` with a `job_id` to poll. Always handle both. See [Sync and async](https://docs.zerodrift.com/api-reference/redact/redact-text.md#sync-and-async).

## Choose a style

| Style | `Email Maria Gonzalez at maria@example.com` becomes | Use it when |
| - | - | - |
| `label` (default) | `Email [PRIVATE_PERSON] at [PRIVATE_EMAIL]` | A person or model still needs to know what kind of value was there. |
| `mask` | `Email [REDACTED] at [REDACTED]` | You want to hide even the type of value. |
| `remove` | `Email  at ` | The text is going somewhere placeholders would get in the way. |

## Code

```bash cURL theme={null}
curl -X POST "https://api.zerodrift.ai/api/v3/content/redact" \
  -H "x-api-key: $ZERODRIFT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "content": "Hi, this is Daniel Brooks. Call me at (415) 555-0132 or email daniel.brooks@example.com.",
    "style": "label",
    "mode": "sync"
  }'
```

```python Python theme={null}
import os
import time

import requests

API = "https://api.zerodrift.ai"
HEADERS = {
    "x-api-key": os.environ["ZERODRIFT_API_KEY"],
    "Content-Type": "application/json",
}


def redact(text: str, style: str = "label") -> dict:
    resp = requests.post(
        f"{API}/api/v3/content/redact",
        headers=HEADERS,
        json={"content": text, "style": style, "mode": "sync"},
        timeout=60,
    )
    resp.raise_for_status()
    job = resp.json()

    # A sync request can still come back as 202, so poll until it finishes.
    deadline = time.monotonic() + 120
    while job["status"] in ("queued", "processing"):
        if time.monotonic() >= deadline:
            raise TimeoutError("Timed out waiting for redaction")
        time.sleep(2)
        poll_resp = requests.get(
            f"{API}/api/v3/jobs/{job['job_id']}", headers=HEADERS, timeout=30
        )
        poll_resp.raise_for_status()
        job = poll_resp.json()

    if job["status"] == "failed":
        raise RuntimeError(job.get("error"))
    return job["result"]


result = redact(
    "Hi, this is Daniel Brooks. Call me at (415) 555-0132 "
    "or email daniel.brooks@example.com."
)
print(result["redacted"])
print(result["summary"])
```

## Try these four test cases

Each example uses made-up data and covers a different kind of personal information. Send them with `style: "label"` and compare your output with the one shown.

### 1. Client email

Names and contact details in everyday correspondence.

```text Input theme={null}
Hi Maria, this is Daniel Brooks from Harbor Wealth. Call me at (415) 555-0132 or email daniel.brooks@example.com before Friday.
```

```text Output theme={null}
Hi [PRIVATE_PERSON], this is [PRIVATE_PERSON] from Harbor Wealth. Call me at [PRIVATE_PHONE] or email [PRIVATE_EMAIL] before Friday.
```

The firm name stays. Organization names are not redacted reliably; see the [known gaps](https://docs.zerodrift.com/api-reference/redact/redact-text.md#known-gaps).

### 2. Wire instructions

Bank account details, with checksum or format checks for each identifier.

```text Input theme={null}
Please wire the funds to IBAN GB82 WEST 1234 5698 7654 32. For US transfers use routing number 011000015 and SWIFT code DEUTDEFF.
```

```text Output theme={null}
Please wire the funds to IBAN [ACCOUNT_NUMBER]. For US transfers use routing number [ACCOUNT_NUMBER] and SWIFT code [ACCOUNT_NUMBER].
```

`summary.validated_identifiers` reports `iban`, `us_routing_number` and `bic`. Routing numbers and SWIFT/BIC codes are confirmed only when a word naming them, such as "routing" or "SWIFT", comes just before the number.

### 3. Tax and payment details

Government ID and card numbers in a form or support ticket.

```text Input theme={null}
Applicant SSN: 123-45-6789. Business EIN: 12-3456789. Card on file: 4111 1111 1111 1111.
```

```text Output theme={null}
Applicant SSN: [ACCOUNT_NUMBER]. Business EIN: [ACCOUNT_NUMBER]. Card on file: [ACCOUNT_NUMBER].
```

`summary.validated_identifiers` reports `us_ssn`, `us_ein` and `card`.

### 4. Patient intake note (PHI)

A health record, to see what is removed and what stays.

```text Input theme={null}
Patient Jordan Ellis, DOB 03/14/1982, lives at 2400 West Pioneer Parkway, Peoria, IL 61615. Phone (309) 555-0187. Presents with chest pain; started on atorvastatin 20 mg.
```

```text Output theme={null}
Patient [PRIVATE_PERSON], DOB [PRIVATE_DATE], lives at [PRIVATE_ADDRESS]. Phone [PRIVATE_PHONE]. Presents with chest pain; started on atorvastatin 20 mg.
```

The identifiers are gone, but the symptom and medication stay. That is expected: redaction removes who the record is about, not the clinical content. See [Health information (PHI)](#health-information-phi).

## Pricing

Redaction is billed at \$0.01 per message of up to 2,000 input tokens. Each of the test cases above is one message. See [Pricing](https://docs.zerodrift.com/pricing.md#pii-redaction).

## Next

> [card] [Redact PII API reference](https://docs.zerodrift.com/api-reference/redact/redact-text.md)
>
> Every field, response property and error code.

> [card] [Handle errors](https://docs.zerodrift.com/guides/handle-errors.md)
>
> Retries and fallbacks for production traffic.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.