---
title: "PII redaction"
subtitle: "Mask personal data in requests before it reaches the provider and the log."
---

PII redaction finds personal information, such as names, emails, and card numbers, in the chat requests you send through the gateway and replaces each match with `[REDACTED]`. The provider receives the redacted request, and the log stores the redacted request, so the original text is kept nowhere in Respan. You turn it on once for the project in the platform, with no code changes.

Your app sends:

```json
{
  "model": "gpt-5.5",
  "messages": [
    {"role": "user", "content": "I'm Maya Patel, maya@example.com. My card 4242 4242 4242 4242 was charged twice."}
  ]
}
```

The provider and the log see:

```json
{
  "model": "gpt-5.5",
  "messages": [
    {"role": "user", "content": "I'm [REDACTED], [REDACTED]. My card [REDACTED] was charged twice."}
  ]
}
```

## Turn it on

<Steps>
<Step title="Open PII redaction">

Go to **Settings** › **PII redaction**. Anyone in the project can see these settings, but only admins can change them. Changes save as you make them.

<img src={"/docs/images/pii-redaction/settings-light.png"} className="block dark:hidden" alt="Redaction settings with the Gateway and Telemetry toggles, Categories set to 16 categories selected, and Sensitivity set to Low" />
<img src={"/docs/images/pii-redaction/settings-dark.png"} className="hidden dark:block" alt="Redaction settings with the Gateway and Telemetry toggles, Categories set to 16 categories selected, and Sensitivity set to Low" />

</Step>
<Step title="Choose what to detect">

Pick the **Categories** and the **Sensitivity**. See [What's redacted](#whats-redacted).

</Step>
<Step title="Test on sample text">

Paste sample text into **Test input**. **Redacted preview** labels each match with its category and counts the matches. The test uses your saved settings and doesn't touch live traffic.

<img src={"/docs/images/pii-redaction/test-light.png"} className="block dark:hidden" alt="The Test panel with sample text in Test input and a Redacted preview that replaces the name, address, email, phone, date of birth, SSN, and IP address with labels. 7 entities detected" />
<img src={"/docs/images/pii-redaction/test-dark.png"} className="hidden dark:block" alt="The Test panel with sample text in Test input and a Redacted preview that replaces the name, address, email, phone, date of birth, SSN, and IP address with labels. 7 entities detected" />

</Step>
<Step title="Turn on Gateway">

Switch on **Gateway**. From the next request on, chat requests through the gateway in the project are redacted.

</Step>
</Steps>

There's no per-request parameter: the setting covers every gateway request in the project.

## What's redacted

**Categories.** Email, Phone, Name, Address, Organization, Demographic, Credential, Credit card, Bank account, IBAN, National ID, Social Security number, Passport, Driver's license, Username, Date of birth, and IP address. All but **Organization** are on by default, since company names cause false positives. Keep at least one selected.

**Sensitivity.** From **Very low** to **Very high**; the default is **Low**. Higher settings catch more borderline text and also mask more ordinary words.

**How matches are found.** Pattern rules catch structured values such as card numbers and emails, and a named-entity detection model catches names, addresses, and other free text, for the categories you selected.

**Which parts of a request.** The input of a chat request only: messages, system prompts, and tool calls and tool results in the history. The model's response is not redacted.

## Where it applies

Redaction runs before anything else reads the request:

1. **The provider call.** The provider only ever receives the redacted text.
2. **Token counts for rate limits.** Tokens per minute are counted on the redacted request.
3. **The log.** The request stored in Logs is the redacted one.

The response is sent back to your app as the model wrote it, and logged as written.

<Warning>
Redaction changes what the model sees. If an answer depends on a masked value, such as an order number the user typed, the model can't use it. Test on real examples before you turn it on for production traffic. Detection is probabilistic, so don't treat redaction as a guarantee.
</Warning>

## In Logs

Open a request in **Gateway** › **Logs**. The **Input** shows `[REDACTED]` where a match was replaced, exactly as the provider received it. The original text isn't stored, so it can't be recovered from Respan.

To also hide personal data in logs and traces that your tracing SDK sends, switch on **Telemetry** in the same settings. **Telemetry** redacts inputs, outputs, metadata, errors, and names when Respan shows them, in the platform and through the API, without changing stored data. **Gateway** and **Telemetry** work independently. See [PII redaction](/docs/documentation/pii-redaction).

## If the detector is unavailable

Redaction fails closed. If the detector is down or times out, the gateway refuses the request with `503` instead of sending unredacted text, and no log is written. Retry with backoff.

## Endpoints that aren't redacted

Redaction covers chat requests only. Images, embeddings, speech, transcription, video, decisions, and realtime sessions are refused for an organization with **Gateway** redaction on, rather than served unredacted.

## Related

- [Data retention and ZDR](/docs/ai-gateway/security/zero-data-retention)
- [PII redaction settings](/docs/documentation/pii-redaction)
