# Data classification, masking and reveal

> Mark fields as personal or sensitive data so they are masked, let the right people reveal a value with a reason, and log who opened which record.

Source: https://docs.ligament.ai/guides/access/data-classification/

Use this page when some fields hold personal or sensitive data, such as a salary, a home address or a personal email, and most people who can open the record shouldn’t read them. You’ll classify the fields, decide who reads them in clear, let a few people reveal a value when they need it, and switch on a log of who opened which record.

You need to be a workspace owner or admin. Everything here is in **Settings › Access › Classification**.

## Classify a field

1.  Open **Settings › Access › Classification** and pick the entity.
2.  For each field, choose **Personal data** or **Sensitive** (or leave it **Not classified**).
3.  Click **Save**.

\[Screenshot: Settings › Access › Classification for Person: Email is classified as Personal data, the other fields are not classified, and Audit reads is switched on\]

From then on a classified field is **masked** for everyone except owners and admins, unless one of their permission sets gives the field a level. Masked means the person sees the shape of the value, not the value:

| Value | Shown as |
| --- | --- |
| an email, `hannah.becker@northwind.example` | `h•••@northwind.example` |
| a text of 8 characters or more, such as an account number | `••••1234` (the last four characters) |
| a number, an amount, a date, a reference, a choice, or a short text | `•••••` |
| no value | empty |

A masked field can’t be changed, a filter on it matches nothing, and sorting, grouping and search leave it out, so nobody can work the value out by filtering. Its past values aren’t shown in the history either.

The two classifications mask in the same way. Use them to say what kind of data it is: personal data is about a person (contact details, identifiers), sensitive is data that needs extra care (pay, health, ratings).

### Who sees it masked

The **Who sees it masked** column lists the roles that see the field masked and the roles that read it in clear, from the roles’ permission sets. In Northwind Group, after classifying `email` on Person, it read “Masked for Member, Viewer and 2 more; in clear for Owner, Admin and 1 more.” Point at the line to see every role.

To let a role read the field, give it a level in a permission set the role holds, on the set’s **Field levels** or on one grant:

```json
{ "fields": { "person": { "email": "read" } } }
```

A level on one grant applies only to the rows that grant covers. That’s how a person reads their own salary while their reports’ salaries stay masked; the [HR example](https://docs.ligament.ai/guides/access/hr-example/index.md) shows it step by step.

Owners and admins read classified fields in clear. To mask a field for them too, add a restriction with a **masked** field cap and **Enforce on owners and admins too** switched on (see [Restrictions](https://docs.ligament.ai/guides/access/roles-and-permission-sets/index.md#restrictions)).

### Classification set by an app

An app can classify its own fields. The Classification page then shows **The `<app>` app** in the **Set by** column. You can still change it, but upgrading the app sets the app’s classification again. A field the app doesn’t classify keeps whatever you chose.

### Everywhere the same

Masks apply wherever the record is read: the record page, lists, search, reports, the REST API, MCP tools and exports. An export never contains more than the person can read: after Northwind classified `email`, a member’s CSV export of people had `h•••@northwind.example` in Hannah Becker’s row.

On the record page, open **More actions › Why can I see this?** to see which fields are masked for you: the See section lists them under **Masked**.

## Reveal a masked value

Some people need the real value now and then, for example payroll fixing a bank detail. Give them the capability `pii.reveal` in a permission set (or `pii.reveal@<app>` for one app’s records only). They then see a **Reveal** button next to a masked field on the record page.

\[Screenshot: Hannah Becker's person record as Alex Agent: Email shows h•••@northwind.example, marked Masked, with a Reveal button\]

1.  Click **Reveal** next to the field.
2.  Type why you need the value, at least three characters. For example: “Payroll correction requested in HR-2291”.
3.  Click **Reveal**. The value shows in the dialog.

\[Screenshot: The Reveal Email dialog with a reason typed in, before the value is shown\]

The value is only shown in the dialog. It isn’t kept on the page, and it’s gone when you close the dialog. Each reveal writes one entry to the access audit with who, which record, which fields and the reason; the value itself is never written there.

\[Screenshot: Settings › Access › Audit filtered to reveals: Alex Agent revealed email on a person record with the reason Payroll correction requested in HR-2291\]

Some limits:

-   Only a field that is masked for you on that record can be revealed. A field you can read doesn’t need it; a field that’s hidden can’t be revealed.
-   A field masked by a restriction can’t be revealed, unless the restriction allows it (**Reveal** on the restriction, `revealable: true`). Restrictions always win.
-   `reveal` is also a [record action](https://docs.ligament.ai/guides/access/roles-and-permission-sets/index.md#record-actions): once a set grants it on an entity, only people whose grants include it may reveal there, and a restriction can forbid it on some rows.

In Northwind Group, Alex Agent holds the role Payroll officer, whose set `hr.reveal_personal_data` holds `pii.reveal`. The same request without a reason is refused:

```http
POST /api/records/person/<id>/reveal
{ "fields": ["email"], "reason": "x" }
```

```json
{ "error": "A reason is required to reveal a value (it goes into the access audit)", "code": "reason_required" }
```

## Log who opened which record

Switch on **Audit reads** for an entity on the Classification page. Every time someone opens one record of that entity, in the app or with an API key, the access audit gets an entry **Record read** with who and which record. Opening the same record again within 10 minutes isn’t logged twice. Lists and searches aren’t logged, only opening a record.

To read the log, open **Settings › Access › Audit** and choose **Record reads (read audit)** under Kind. In Northwind Group, with Audit reads on for Person, Alex Agent opening Hannah Becker’s record added:

```text
record.read   person/cmx6ak62y00a16x6siotp0zme   Alex Agent
```

Classification changes are in the same audit, as **Classification**, with the fields before and after.

## Do it through the API

`PUT /api/access/classification` changes classifications and the read audit of one entity. Send only what changes; `null` removes a classification. Owners, admins and roles with the `build:access` permission may call it; a holder of `app.admin@<app>` may change that app’s entities. With an API key it needs the `members:write` scope.

```http
PUT /api/access/classification
{ "entity": "person", "fields": { "email": "pii" } }
```

```json
{
  "entity": "person",
  "fields": { "name": null, "email": "pii", "title": null, "department": null, "manager": null, "user": null, "location": null, "phone": null },
  "auditReads": false,
  "changed": 1
}
```

Reveal is `POST /api/records/<entity>/<id>/reveal` with `{ "fields": [...], "reason": "..." }`; the answer has the values under `values`. Apps declare classification in their manifest with `classification` on a field and `auditReads` on an entity (see the [app manifest reference](https://docs.ligament.ai/reference/app-manifest/index.md)).
