---
title: "The Phileas redaction policy schema"
description: "What a redaction policy is, how the JSON schema is structured, and how to use it to control exactly which PII is detected and how each type is redacted."
url: "https://philterd.ai/guides/redaction-policy-schema/"
---

[Knowledge base](https://philterd.ai/guides/) [Reference](https://philterd.ai/guides/?kind=reference)

# The Phileas redaction policy schema

What a redaction policy is, how the JSON schema is structured, and how to use it to control exactly which PII is detected and how each type is redacted.

For [Phileas](https://philterd.ai/support/phileas/) and [Philter](https://philterd.ai/support/philter/)

A **redaction policy** is the configuration that tells Phileas (and therefore [Philter](https://philterd.ai/philter/), which embeds it) two things: which types of sensitive information to detect, and how to transform each type when it is found. A policy is a single JSON file. This guide explains how that file is structured so you can read, write, and tune one with confidence.

The schema is the single source of truth for the [whole toolkit](https://philterd.ai/open-source-software/). The canonical definition is a JSON Schema file in the Phileas repository, and everything else tracks it: the [policy library](https://philterd.ai/policies/), the [Redaction Policy Editor](https://philterd.ai/redaction-policy-editor/), and the [PhiSQL](https://philterd.ai/phisql/) query language all produce or validate against this same shape.

## The smallest useful policy

A policy that detects email addresses and redacts them looks like this:

```json
{
  "identifiers": {
    "emailAddress": {
      "emailAddressFilterStrategies": [
        {
          "strategy": "REDACT",
          "redactionFormat": "{{{REDACTED-%t}}}"
        }
      ]
    }
  }
}
```

When an email address is detected, it is replaced with `{{{REDACTED-email-address}}}`. The `%t` placeholder expands to the filter type. That is the entire mental model: an `identifiers` object naming the things to detect, and for each one, a list of strategies describing what to do.

## The anatomy of a policy

The top level of a policy has a small number of optional sections. In practice most policies only use `identifiers`.

| Field | What it does |
| --- | --- |
| `identifiers` | The core of the policy. Defines which entity types to detect and how to handle each. |
| `config` | Global settings: text splitting for large inputs, PDF rendering, post-filters, and analysis options. |
| `ignored` | Lists of terms to ignore globally, so a known-safe word is never redacted. |
| `ignoredPatterns` | Regex patterns to ignore globally. |
| `crypto` | AES encryption settings used by the `CRYPTO_REPLACE` strategy. |
| `fpe` | Format-preserving encryption settings used by the `FPE_ENCRYPT_REPLACE` strategy. |
| `graphical` | Settings for redacting images and PDFs. |

## Identifiers: what to detect

Each key inside `identifiers` is an entity type. Phileas ships with a long list, including `ssn`, `creditCard`, `emailAddress`, `phoneNumber`, `date`, `age`, `ipAddress`, `firstName`, `surname`, `streetAddress`, `city`, `state`, `zipCode`, and `url`, along with detection driven by AI models (`pheyes`) and custom dictionaries (`dictionaries`).

Every identifier shares a set of common controls:

- `enabled` to turn the filter on or off
- `priority` to order it relative to other filters
- `ignored` and `ignoredPatterns` to suppress specific matches for that one identifier
- `windowSize` to tune how much surrounding context the detector considers

Alongside those, each identifier carries its own strategies array, named after the identifier: `ssnFilterStrategies`, `creditCardFilterStrategies`, and so on. That array is where you say what happens when the entity is found.

### Custom identifiers and validators

Beyond the built-in types, the `identifiers` object also holds an `identifiers` array for your own regex-based identifiers. Each entry has a `pattern`, a `classification` label, optional `caseSensitive` and `groupNumber`, and its own `identifierFilterStrategies`.

As of schema 1.1.0, a custom identifier can also carry an optional `validator`: a named, built-in checksum or structural check that keeps a match only if it passes, so a generic pattern rejects format-valid but invalid values such as a national ID that fails its check digit. Write it as a string (`"validator": "luhn"`), or as an object when the validator takes parameters (`"validator": { "name": "mod11", "params": { "variant": "cpf" } }`). An unknown or not-yet-implemented validator name is a policy error, not a silent skip.

The built-in validators cover national and financial identifiers such as the Canadian SIN, Brazilian CPF and CNPJ, Spanish DNI, French NIR, IBAN, and SWIFT/BIC. See [Redacting national and financial ID numbers](https://philterd.ai/guides/redacting-national-and-financial-id-numbers/) for the full list, ready-made policies, and copy-paste examples.

## Filter strategies: how to redact

A filter strategy is a single rule for transforming a detected value. The `strategy` field selects the transformation:

| Strategy | Effect |
| --- | --- |
| `REDACT` | Replace the value with a format string (the default). |
| `MASK` | Replace characters with a mask character such as `*`. |
| `STATIC_REPLACE` | Replace with a fixed string you choose. |
| `RANDOM_REPLACE` | Replace with a realistic random value of the same type. |
| `LAST_4` | Keep only the last four characters (common for card numbers). |
| `TRUNCATE` | Keep a leading portion and drop the rest. |
| `ABBREVIATE` | Shorten the value. |
| `HASH_SHA256_REPLACE` | Replace with a SHA-256 hash of the value. |
| `CRYPTO_REPLACE` | Replace with an AES-encrypted value (uses the policy `crypto` block). |
| `FPE_ENCRYPT_REPLACE` | Replace with a format-preserving encrypted value (uses the policy `fpe` block). |

Strategies also accept supporting fields, the most common being `redactionFormat` (the template for `REDACT`, supporting `%t` for type, `%v` for the original value, and `%l` for a label), `maskCharacter`, `staticReplacement`, and `replacementScope` (`DOCUMENT` or `CONTEXT`, which keeps the same value mapping consistent within a document or a context).

Because each identifier holds an array of strategies, you can apply different handling under different conditions. The first matching strategy wins, so a more specific conditional strategy can sit ahead of a general fallback.

## A worked example

Here is a small but realistic policy. It keeps the last four digits of credit cards, masks phone numbers, and redacts SSNs with a labeled format:

```json
{
  "identifiers": {
    "creditCard": {
      "creditCardFilterStrategies": [
        { "strategy": "LAST_4" }
      ]
    },
    "phoneNumber": {
      "phoneNumberFilterStrategies": [
        { "strategy": "MASK", "maskCharacter": "#" }
      ]
    },
    "ssn": {
      "ssnFilterStrategies": [
        { "strategy": "REDACT", "redactionFormat": "[SSN REMOVED]" }
      ]
    }
  }
}
```

The same policy expressed in [PhiSQL](https://philterd.ai/phisql/) is a few readable lines that compile to exactly this JSON:

```sql
POLICY example;

REDACT CREDIT_CARD WITH LAST_4;
REDACT PHONE_NUMBER WITH MASK(character='#');
REDACT SSN WITH REDACT(format='[SSN REMOVED]');
```

## How to get started

1. **Start from an existing policy.** The [policy library](https://philterd.ai/policies/) has ready-to-use files for HIPAA Safe Harbor, PCI DSS scope reduction, and more. Download one and adjust it.
2. **Or author it readably.** Write [PhiSQL](https://philterd.ai/phisql/) and compile it, or build the policy visually in the [Redaction Policy Editor](https://philterd.ai/redaction-policy-editor/).
3. **Validate against the schema.** Point your editor or CI at the canonical [redaction policy JSON schema](https://philterd.ai/schemas/redaction-policy/1.1.0/schema.json) so malformed policies are caught before they ship.
4. **Apply it.** Save the file and reference it by name from the Philter redaction API, or load it directly in an embedded Phileas instance.

For the exhaustive field-by-field reference and every supported filter strategy option, see the [Phileas filter policy documentation](https://philterd.github.io/phileas/filter_policies/filter_policies/).

## Frequently asked questions

Where does the canonical schema live?

It is published at [philterd.ai/schemas/redaction-policy/1.1.0/schema.json](https://philterd.ai/schemas/redaction-policy/1.1.0/schema.json) and authored in the [phisql repository](https://github.com/philterd/phisql/blob/main/schema/1.1.0/schema.json). That JSON Schema file is the single source of truth. Philter, Phileas, the policy library, and [PhiSQL](https://philterd.ai/phisql/) all track it, and each Phileas release supports exactly one schema version.

Do I have to write policies by hand?

No. You can hand-write JSON, generate it from [PhiSQL](https://philterd.ai/phisql/) (a readable query language that compiles to this schema), build it visually with the [Redaction Policy Editor](https://philterd.ai/redaction-policy-editor/), or start from a ready-made file in the [policy library](https://philterd.ai/policies/). Every path produces the same JSON.

What happens if a policy does not match the schema?

Philter and Phileas validate policies on load and reject malformed ones. The policy library also validates every contributed policy against a vendored copy of the schema in CI, so drift is caught before it ships.

How do I control which strategy applies to which entity?

Each identifier carries its own array of filter strategies. The first strategy whose condition matches is applied, so you can, for example, mask most credit cards but keep the last four digits when a condition holds. See the filter strategies section above.

## Related reading

- [PhiSQL: Author policies in a readable query language that compiles to this schema.](https://philterd.ai/phisql/)
- [Redaction policy library: Ready-to-use HIPAA, PCI DSS, and other policies you can download or fork.](https://philterd.ai/policies/)
- [Redaction Policy Editor: Build and edit policies visually, no JSON required.](https://philterd.ai/redaction-policy-editor/)
- [Phileas filter policy docs: The exhaustive reference for every field and filter strategy.](https://philterd.github.io/phileas/filter_policies/filter_policies/)
