> ## 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.

# Redact PII

> Remove personal information from text before you store, share or send it to another model.

Send text and get the same text back with personal information replaced or
removed: names, email addresses, phone numbers, street addresses, URLs, dates
and account numbers such as cards, IBANs and US Social Security numbers.

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

For a walkthrough with four test cases you can run, including a patient
record, see [Remove PII and PHI](https://docs.zerodrift.com/guides/redact-pii-and-phi.md).

> [!WARNING]
>
> Detection is best-effort. A redacted result is **not** a guarantee of
> complete anonymization. Review the [known gaps](#known-gaps) before you rely
> on it for a regulated workflow.

## Request Body

**content** `string` *required* (default: Email Maria Gonzalez at [maria@example.com](mailto:maria@example.com))

Text to redact, up to 100,000 characters. Empty or whitespace-only text is
valid and returns no findings.

**style** `string` (default: label)

How each finding is replaced:

| Style | `Email Maria Gonzalez at maria@example.com` becomes |
| - | - |
| `label` (default) | `Email [PRIVATE_PERSON] at [PRIVATE_EMAIL]` |
| `mask` | `Email [REDACTED] at [REDACTED]` |
| `remove` | `Email  at ` |

Any other value returns `422 invalid_style`.

**mode** `string` (default: async)

`sync` returns the redacted text in the response for content up to 20,000
characters. `async` (the default) returns `202` with a `job_id` to poll via
[Get Verdict](https://docs.zerodrift.com/api-reference/validate/get-results.md). See
[Sync and async](#sync-and-async).

**priority** `string`

Which detector queue the request joins: `realtime` work is served first,
`standard` waits behind it. Defaults to `realtime` for `sync` and `standard`
for `async`. Use `standard` for bulk jobs so they don't slow down interactive
callers.

**metadata** `object`

Optional free-form object stored on the job, for example your own message ID.
At most 8,192 bytes as JSON.

## Response

A completed redaction returns `200` with the result nested under `result`.
Polling an async job returns the same envelope.

**api\_version** `string`

Always `v3`.

**job\_id** `string`

Unique identifier for the redaction job.

**job\_type** `string`

Always `redact`.

**status** `string`

`queued`, `processing`, `completed` or `failed`.

**mode** `string`

Mode the request was actually processed in. A `sync` request that fell back
reports `async`.

**priority** `string`

The detector queue the request joined: `realtime` or `standard`.

**submitted\_at** `string`

Time the job was submitted (ISO 8601).

**poll** `object`

Where to poll for the result (async only): `method` is `GET`, `url` is
`/api/v3/jobs/{job_id}`.

**error** `string`

Present when `status` is `failed`.

**result** `object`

Present when `status` is `completed`.

**result properties**

**redacted** `string`

The redacted text. Returned in the `sync` response and when polling a
completed async job. A completed sync job stores no text, so polling it
afterwards returns the summary without `redacted`.

**summary** `object`

What was found, as counts only. Removed values are never returned.

**summary properties**

**total** `integer`

Number of findings.

**by\_category** `object`

Findings per category, for example `private_person`,
`private_email`, `private_phone`, `private_address`, `private_url`,
`private_date` and `account_number`.

**validated\_identifiers** `object`

Account numbers confirmed by a checksum or format check, by type:
`card`, `iban`, `us_ssn`, `us_itin`, `us_routing_number`, `us_ein`
and `bic`. For example `{"iban": 1, "us_ssn": 1}`.

**detector** `object`

`name` and `revision` of the detector that ran.

**notice** `string`

Always reminds you that detection is best-effort.

**units** `integer`

Billed units for this job.

**cost** `object`

Billed cost for this job: `currency` and `amount`.

## Sync and async

| You send | What happens |
| - | - |
| `mode: "sync"`, content up to 20,000 characters | `200` with `result.redacted` in the response. ZeroDrift stores no text. |
| `mode: "sync"`, content over 20,000 characters | Falls back to async: `202` with a `job_id`. |
| `mode: "sync"` while the detector is starting up | Falls back to async: `202` with a `job_id`. The job keeps `realtime` priority. |
| `mode: "async"` | `202` with a `job_id`. Poll [Get Verdict](https://docs.zerodrift.com/api-reference/validate/get-results.md) until `status` is `completed` or `failed`. Results are kept for 24 hours. |

Always handle a `202`, even when you send `mode: "sync"`.

A redaction job can be read only with the API key that submitted it.

> [!NOTE]
>
> There is no fallback engine. If the detector is unavailable, a `sync`
> request returns `503 detector_unavailable` and an `async` job ends
> `failed`. ZeroDrift never returns unredacted text in place of a result.

## Errors

No error response echoes your content.

| Status | Code | Cause |
| - | - | - |
| `400` | `invalid_json`, `missing_content` | The body isn't valid JSON, or `content` is missing. |
| `402` | `insufficient_credits` | The workspace has no balance left. |
| `403` | `redact_not_enabled` | Redaction isn't enabled for this workspace. |
| `413` | `content_too_large` | `content` is over 100,000 characters. |
| `413` | `metadata_too_large` | `metadata` is over 8,192 bytes. |
| `422` | `invalid_content`, `invalid_style`, `invalid_mode`, `invalid_priority`, `invalid_metadata` | A field has the wrong type or value. |
| `422` | `unsupported_field` | `categories` or `return_spans` was sent. Neither is available yet. |
| `503` | `detector_unavailable` | Sync only. The detector couldn't answer. Retry, or send `mode: "async"`. |

Both full-access and read-only API keys can call this endpoint. Refused
requests and failed jobs are not billed.

## Pricing

Redaction is billed at **\$0.01 per message**, where a message is up to 2,000
input tokens of your text, rounded up. Each completed job reports its charge in
`result.units` and `result.cost`. See [Pricing](https://docs.zerodrift.com/pricing.md#pii-redaction).

## Known gaps

The detector combines a language model with checksum and pattern rules. These
are the cases it is known to miss or handle weakly:

* **Organization names** are not reliably detected. A customer name that is a
  company may be left in place.
* **Routing numbers, EINs and SWIFT/BIC codes** are confirmed only when a word
  naming them comes just before the number, such as `routing`, `EIN`, `tax ID`
  or `SWIFT`. Without one, they are left to the model and may be missed.
* **Cards**: Maestro and UnionPay numbers, and card numbers inside a longer run
  of digits, may be missed.
* **Addresses** are matched by rule only when they include a street-type word
  such as `Street` or `Avenue`. A PO box, a building name or a bare city and ZIP
  code is left to the model.
* **Not covered by the rules**: internal reference IDs, CVVs, PINs and
  lowercase first names in chat. These depend on the model alone.
* **Languages**: only English and Dutch have been measured.

## Example

```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": "Email Maria Gonzalez at maria@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",
}

resp = requests.post(
    f"{API}/api/v3/content/redact",
    headers=HEADERS,
    json={
        "content": "Email Maria Gonzalez at maria@example.com",
        "style": "label",
        "mode": "sync",
    },
    timeout=60,
)
resp.raise_for_status()
job = resp.json()

# A sync request can still fall back to async (202), so poll if needed.
while job["status"] in ("queued", "processing"):
    time.sleep(2)
    resp = requests.get(
        f"{API}/api/v3/jobs/{job['job_id']}", headers=HEADERS, timeout=30
    )
    resp.raise_for_status()
    job = resp.json()

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

print(job["result"].get("redacted"))
print(job["result"]["summary"])
```

```json 200 Response theme={null}
{
  "api_version": "v3",
  "job_id": "a1b2c3",
  "job_type": "redact",
  "status": "completed",
  "mode": "sync",
  "priority": "realtime",
  "submitted_at": "2026-11-02T16:30:00+00:00",
  "result": {
    "redacted": "Email [PRIVATE_PERSON] at [PRIVATE_EMAIL]",
    "summary": {
      "total": 2,
      "by_category": { "private_person": 1, "private_email": 1 },
      "validated_identifiers": {}
    },
    "detector": { "name": "privacy-filter", "revision": "7ffa9a04" },
    "notice": "Best-effort detection. Not a guarantee of complete anonymization.",
    "units": 1,
    "cost": { "currency": "USD", "amount": "0.01" }
  }
}
```


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