> For the complete documentation index, see [llms.txt](https://docs.nected.ai/nected-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nected.ai/nected-docs/audit/pii-data-masking.md).

# Mask Sensitive Data

Nected's Audit Trail supports **PII Data Masking**. PII (Personally Identifiable Information) is any data that can identify a person, such as an Aadhaar number, a PAN, a card number, a phone number or an email address. PII Data Masking is part of **Auditing**: you list the keys in your rule or workflow that carry PII, and Nected masks their values every time a run is logged.

Rules and workflows often receive PII as input. With **Auditing** turned on, Nected records the values of every run in the [Audit Trail](https://docs.nected.ai/nected-docs/audit/audit-trail) so you can review and debug it later. That record is useful, but it also means anyone with access to the audit logs can read the raw PII that passed through. PII Data Masking lets you keep a full audit trail without exposing that data:

* **Audit without exposing PII**: Runs are still logged, but the values of the keys you mark as PII are partly hidden, for example `********2346`.
* **Key-level control**: You choose exactly which keys to mask, rule by rule and workflow by workflow. Every other key is logged as usual.
* **Category-aware**: Each key is tagged with a PII category, such as **IN AADHAAR** or **Email Address**, which tells Nected what the value looks like and how to mask it.
* **No change to your logic**: Masking applies only to what is logged and displayed. The rule or workflow still receives and uses the real value.

{% hint style="info" %}
PII Data Masking is available for both **Rules** and **Workflows**. It is a part of **Auditing**, in the **Settings** section of the editor, and appears only when **Auditing** is turned on.
{% endhint %}

#### Example

Suppose a KYC rule has three inputs, `aadhar`, `email` and `name`, and returns the Aadhaar number in a result also named `aadhar`. You mask two keys:

| Key Name | Category      |
| -------- | ------------- |
| `aadhar` | IN AADHAAR    |
| `email`  | Email Address |

The rule receives this input:

```json
{
  "aadhar": "234123412346",
  "email": "test.user@example.com",
  "name": "Test User"
}
```

The rule checks the Aadhaar number as usual, but in **Execution Logs** the run is logged as:

```json
{
  "aadhar": "********2346",
  "email": "t*******@example.com",
  "name": "Test User"
}
```

`name` is logged as it is because it isn't in the list of masked keys. The `aadhar` result in the output is logged as `********2346` too.

#### Where to Find PII Data Masking?

1. **Open a Rule or Workflow**: Open an existing rule or workflow, or create a new one.
2. **Open Settings**: In the right-hand panel, expand **Settings**. It holds **Start Time**, **End Time**, **Status** and **Auditing**.
3. **Turn on Auditing**: Switch the **Auditing** toggle on. Auditing is off by default on a new rule. A **Mask Sensitive Data** section appears below it with a **+ Add Data** button. This is where you set up PII Data Masking.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FqvJn8D3o5Dm7t47YIegd%2F01-settings-mask-sensitive-data.png?alt=media&#x26;token=a80ffeee-8ebe-41bf-acf8-29dbd5318a7e" alt="Settings section with Auditing turned on and the masked keys aadhar and email shown as chips"><figcaption></figcaption></figure>

Once you have added keys, the section shows each masked key as a chip, for example `aadhar` and `email`, followed by an **edit** (pencil) icon. Click the icon to add, change or remove keys.

{% hint style="warning" %}
If you turn **Auditing** off, the **Mask Sensitive Data** section is hidden. Nothing is logged while Auditing is off, so there is no PII to mask.
{% endhint %}

#### Adding PII Keys to Mask

Click **+ Add Data** (or the **edit** icon, if keys are already set) to open the **Mask Sensitive Data** popup.

Each row in the popup is one key to mask, with two fields:

1. **Key Name**: The name of the key that holds PII, exactly as it appears in your rule or workflow. For example, `aadhar`.
2. **Category**: The type of PII the key holds, picked from the dropdown. For example, **IN AADHAAR** for an Aadhaar number.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2Fc5KrVf3R0gbqzxEK5nD3%2F02-mask-sensitive-data-popup.png?alt=media&#x26;token=f34ef1d3-3928-43f7-9551-e3f2fd0fc7d8" alt="Mask Sensitive Data popup with two keys, aadhar as IN AADHAAR and email as Email Address, and the Mask data in Test console toggle on"><figcaption></figcaption></figure>

To set up masking:

1. **Enter the Key Name**: Type the name of the key that holds PII.
2. **Choose a Category**: Open the **Category** dropdown and select the matching PII type. You can type to filter the list, for example `aadh` to find **IN AADHAAR**.<br>

   <figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2F21VIyMMdu6l7NZ0Jj5UY%2F03-category-dropdown.png?alt=media&#x26;token=27e3c106-da52-4529-8d42-1f17a34e2a76" alt="Category dropdown open, listing Credit Card, Crypto, Date Time, Email Address, IBAN Code, IP Address and Location"><figcaption></figcaption></figure>
3. **Add More Keys**: Click **+ Add Key** to add another row. Repeat for every key that holds PII.
4. **Remove a Key**: Click the **delete** (bin) icon at the end of a row.
5. **Submit**: Click **Submit**. The button stays disabled until every row has both a key name and a category. The keys now show as chips in the **Mask Sensitive Data** section.

**How Matching Works**

A value is masked only when **both** of these are true:

* **The key name matches.** The value must sit under a key with exactly the name you entered. If you mask `aadhar`, a value under `aadhaar_number` or `idcopy` is **not** masked, even if it is a valid Aadhaar number.
* **The value matches the category.** The value must look like the PII category you picked. A value that doesn't fit the format of its category is logged as it is. For example, `123456789012` is not a valid Aadhaar number, so under **IN AADHAAR** it is not masked, while a valid number such as `234123412346` is.

Masking covers both the **input** and the **output** of a run. If a result key has the same name as a masked key, for example a result named `aadhar` that returns `{{aadhar}}`, its value is masked in the logged output too.

{% hint style="warning" %}
Pick the category that matches the real data, and test with values in the real format. If the category doesn't match the format of your data, the PII is logged unmasked.
{% endhint %}

**What a Masked Value Looks Like**

Nected hides most of the value and keeps a small part of it, so you can still tell records apart in the logs:

| Category      | Original value          | Logged as              |
| ------------- | ----------------------- | ---------------------- |
| IN AADHAAR    | `234123412346`          | `********2346`         |
| Email Address | `test.user@example.com` | `t*******@example.com` |

**Supported PII Categories**

The **Category** dropdown has 36 PII categories:

<table data-search="false"><thead><tr><th>Group</th><th>Categories</th></tr></thead><tbody><tr><td>General</td><td>Credit Card, Crypto, Date Time, Email Address, IBAN Code, IP Address, Location, Phone Number, Medical License</td></tr><tr><td>United States</td><td>US Bank Number, US Driver License, US ITIN, US Passport, US SSN</td></tr><tr><td>United Kingdom</td><td>UK NHS, UK NINO</td></tr><tr><td>Spain</td><td>ES NIF, ES NIE</td></tr><tr><td>Italy</td><td>IT Fiscal Code, IT Driver License, IT VAT Code, IT Passport, IT Identity Card</td></tr><tr><td>Poland</td><td>PL PESEL</td></tr><tr><td>Singapore</td><td>SG NRIC FIN, SG UEN</td></tr><tr><td>Australia</td><td>AU ABN, AU ACN, AU TFN, AU Medicare</td></tr><tr><td>India</td><td>IN PAN, IN AADHAAR, IN Vehicle Registration, IN Voter, IN Passport</td></tr><tr><td>Finland</td><td>FI Personal Identity Code</td></tr></tbody></table>

**Mask Data in Test Console**

The **Mask data in Test console** toggle at the bottom of the popup is on by default. It controls only what you see when you click **Test Run** in the editor:

* **On**: PII is masked in the test result too. For example, the output shows `"aadhar": "********2346"`.
* **Off**: The test result shows the real values, which can make debugging easier.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2F4Vh5MF7sFe3aaT7CQ1Pe%2F04-test-run-masked-output.png?alt=media&#x26;token=a7ad9fe4-86e4-43d9-89c1-0b5eaac216b3" alt="Test Run result where the aadhar output is shown as ********2346"><figcaption></figcaption></figure>

Either way, the run is still masked in the **Audit Trail**. Turning this toggle off never exposes PII in the audit logs.

{% hint style="warning" %}
Leave **Mask data in Test console** on if you test with real customer data, or if other people can see your screen or test results.
{% endhint %}

#### Where PII Data Masking Applies

| Where                                                   | Masked?                                               |
| ------------------------------------------------------- | ----------------------------------------------------- |
| **Audit Trail → Execution Logs**: Input and Output tabs | Always, while Auditing is on                          |
| **Test Run** result in the editor                       | Only when **Mask data in Test console** is on         |
| The data the rule or workflow uses to run               | Never. Your conditions and actions see the real value |

To check a run, go to **Audit Trail** → **Execution Logs**, and click the run. The **Input** and **Output** tabs under **Execution Details** show the masked values.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FrovjznV2McfsI5IQ3wjT%2F05-audit-trail-execution-details.png?alt=media&#x26;token=978d9af0-2c8f-4559-96fe-352369685ba2" alt="Execution Details in the Audit Trail, with aadhar logged as ********2346, email as t********@example.com and name unmasked"><figcaption></figcaption></figure>

#### Editing or Removing Masked Keys

1. **Open Settings**: Open the rule or workflow and expand **Settings**.
2. **Open the Popup**: Click the **edit** (pencil) icon in the **Mask Sensitive Data** section.
3. **Make Your Changes**: Change a **Key Name** or **Category**, click **+ Add Key** to add a key, click the **delete** icon to remove one, or switch **Mask data in Test console** on or off.
4. **Submit**: Click **Submit**. The button is enabled once you have changed something.

#### Best Practices

* **Cover every key that holds PII**: Add every key that can carry personal or financial data, not only the obvious ones. Check your inputs and your results. A result that returns PII is masked only if its key name is in the list.
* **Match the category to the data**: A value that doesn't fit its category's format is logged unmasked, so pick the PII category that matches the real data.
* **Update masking when you rename keys**: When you rename an input or result, update the masked keys too. A renamed key is no longer masked.
* **Check a run in the Audit Trail**: After setting up PII Data Masking, run the rule or workflow once with realistic test data, then open the run in **Audit Trail → Execution Logs** and confirm the values are masked.
