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

# Redaction policy

> A redaction policy sets which fields each collector keeps, removes, or nulls before data leaves your environment. Two endpoints read and replace it per data source.

A redaction policy is a set of rules that tells a collector, such as the Cloud Collector, which fields to keep. The collector applies it before a record leaves your environment for Operata. Each Operata Group has one policy per data source. Use this page to understand the rule model and path syntax before you call the two policy endpoints.

> [!NOTE]
>
> Redaction policies replace the legacy CTR-only redaction config. Cloud Collector releases before v1.2.3 still read it. See [Legacy redaction config](https://docs.operata.com/docs/api-data-redaction) for those endpoints.

## Endpoints

| Operation | Endpoint | Use it to |
| - | - | - |
| [Get redaction policy](https://docs.operata.com/docs/api-get-redaction-policy.md) | `GET /v1/config/source/{platform}/{dataSourceType}/redaction` | Read the rules in effect, including the Operata-managed defaults. |
| [Create redaction policy](https://docs.operata.com/docs/api-create-redaction-policy.md) | `POST /v1/config/source/{platform}/{dataSourceType}/redaction` | Replace your rules with a new policy version. |

Both endpoints take your Operata Group ID twice: as the username in HTTP Basic auth, and in a `GroupID` header. The two must match. See [Authentication](https://docs.operata.com/docs/api-authentication.md).

```bash theme={null}
curl -u "$OPERATA_GROUP_ID:$OPERATA_API_TOKEN" \
  -H "GroupID: $OPERATA_GROUP_ID" \
  "https://api.operata.io/v1/config/source/connect/ctr/redaction"
```

## Data sources

Each policy belongs to one `platform` and `dataSourceType` pair. Any other pair returns `400`.

| `platform` | `dataSourceType` | Data |
| - | - | - |
| `connect` | `ctr` | Amazon Connect Contact Trace Records (CTRs) |
| `connect` | `cfl` | Amazon Connect contact flow logs |
| `connect` | `lexv2` | Amazon Lex V2 conversation logs |
| `genesys` | `gcd` | Genesys Cloud conversation details |

## Rule types

A policy is a flat list of rules. Each rule has a `type` and a `fieldList` of field paths.

| Type | Effect | Who sets it |
| - | - | - |
| `MANDATORY` | Keeps the field. No other rule can remove it. | Operata. These are the fields Operata needs to identify a contact and place it on a timeline. |
| `DENY` | Removes the field and everything nested under it. | You. |
| `ALLOW` | Keeps the field and everything nested under it. | You. |

A field that no rule matches keeps its key, but its value arrives as `null`. To ship a field's value, a `MANDATORY` or `ALLOW` rule must match it.

The `MANDATORY` list differs per data source. Read your policy with [Get redaction policy](https://docs.operata.com/docs/api-get-redaction-policy.md) to see the current list. Operata can add mandatory fields over time, and the `rulesHash` in the response changes when it does.

### When rules overlap

The collector resolves overlapping rules in a fixed order: `MANDATORY`, then `DENY`, then `ALLOW`.

* **`DENY` beats `ALLOW`.** `DENY ["Attributes"]` with `ALLOW ["Attributes.OrderId"]` removes all of `Attributes`, including `OrderId`.
* **A narrower `DENY` inside an `ALLOW` still applies.** `ALLOW ["Attributes"]` with `DENY ["Attributes.CustomerName"]` keeps every attribute except `CustomerName`.
* **`MANDATORY` survives a `DENY` on its parent.** `DENY ["Queue"]` removes every `Queue` field except the mandatory ones, such as `Queue.Name`.

Rule order in the list doesn't matter.

## Field paths

Field paths follow the record's JSON structure. Paths descend into arrays automatically, so `participants.sessions.mediaType` reaches every session of every participant without an index. The syntax has no array indexes.

| Syntax | Example | Matches |
| - | - | - |
| Dotted keys | `CustomerEndpoint.Address` | That field and anything nested under it. |
| `*` segment | `Attributes.*.Value` | Any key at that level. |
| Key glob | `x-amz-lex:*`, `*Timestamp`, `*Id*` | Keys by prefix, suffix, or substring. |
| `**` | `**.PhoneNumber` | The key at any depth. `ALLOW ["**"]` matches the whole record. |
| Filter | `participants[purpose == 'customer'].sessions.dnis` | Only array elements where the condition holds. `!=` also works. |
| Leading filter | `[Channel == 'CHAT'].Queue.ARN` | The field only when the condition holds on the enclosing object. |
| Element filter | `participants[purpose == 'ivr']` | Whole array elements. `DENY` removes the matching elements from the array. |

Filter values are single-quoted strings. The left side of a filter can be a dotted path, such as `[bot.name != 'test']`.

## Versions and changes

Every successful `POST` creates a new policy version with a new `policyId`. Operata keeps earlier versions for audit. Reads always return the latest version.

* **Full replace.** A `POST` replaces all of your `ALLOW` and `DENY` rules for that data source. Rules you leave out are gone.
* **Reset.** A `POST` with `"rules": []` removes your rules. The policy then holds the `MANDATORY` defaults only.
* **No duplicate versions.** A `POST` whose rules match the latest version, in any order, returns that version and creates nothing. Retrying a write is safe.
* **Never set.** If you've never written a policy for a data source, `GET` returns the defaults with `createdBy: "system"`.

## How collectors apply the policy

The collector for each data source runs in your environment and fetches its policy from Operata. It refreshes the policy at most every five minutes, so a change takes effect within about five minutes. Records collected before the refresh use the previous policy.

The collector also caches the policy in AWS Secrets Manager in your account. If Operata is unreachable, it keeps applying the cached policy. If it has neither a fresh nor a cached policy, it fails the batch rather than ship data it hasn't redacted.

The Amazon Connect collectors read redaction policies from Cloud Collector v1.2.3. Earlier releases read the [legacy redaction config](https://docs.operata.com/docs/api-data-redaction).

## Moving from the legacy config

The legacy `REDACTION_CONFIG` covers CTRs only. This is how each legacy shape maps to a `connect/ctr` policy:

| Legacy config | Equivalent policy rules |
| - | - |
| `WHITELIST` with fields | `ALLOW` with the same fields |
| `BLACKLIST` with fields | `ALLOW ["**"]` plus `DENY` with the same fields |
| Empty `WHITELIST` | `[]`, the defaults only |
| Empty `BLACKLIST` | `ALLOW ["**"]` |

Two behaviors differ. A legacy `BLACKLIST` entry that was the parent of a mandatory field, such as `Queue`, left the whole parent untouched. The policy removes everything under it except the mandatory fields. Legacy array indexes, such as `Recordings.1.Location`, have no equivalent.

## Related

* [Get redaction policy](https://docs.operata.com/docs/api-get-redaction-policy.md) — read the rules in effect.
* [Create redaction policy](https://docs.operata.com/docs/api-create-redaction-policy.md) — replace your rules.
* [Legacy redaction config](https://docs.operata.com/docs/api-data-redaction) — the CTR-only config that Cloud Collector releases before v1.2.3 read.
* [Privacy and redaction](https://docs.operata.com/docs/concepts-privacy-and-redaction.md) — where redaction runs and why.
* [Contact trace records](https://docs.operata.com/docs/contact-trace-records.md) — the CTR fields that `connect/ctr` paths reference.
* [Authentication](https://docs.operata.com/docs/api-authentication.md), [Errors](https://docs.operata.com/docs/api-errors.md), [Rate limits](https://docs.operata.com/docs/api-rate-limits.md) — shared API conventions.


## Related topics

- [Create redaction policy](https://docs.operata.com/docs/api-create-redaction-policy.md)
- [Get redaction policy](https://docs.operata.com/docs/api-get-redaction-policy.md)
- [Privacy and redaction](https://docs.operata.com/docs/concepts-privacy-and-redaction.md)
