# Deletes unmasking window by customer ID

> DELETE /v1/customers/{id}/unmasking-windows · Core resources API

Source: https://developer.kustomer.com/api/core-resources/deletes-unmasking-window-by-customer-id

```http
DELETE https://{orgname}.api.kustomerapp.com/v1/customers/{id}/unmasking-windows
Authorization: Bearer <API key>
```

## Authorization

Requires any one of these roles: `org.permission.unmasking_window.delete`; or legacy `org.user.customer.write`. The API key or user must hold at least one of them. Legacy roles predate permission sets and still work.

Deletes an unmasking window based on the unique customer ID.

### Note
> If an unmasking window is deleted for a customer, any sensitive attributes for the customer and for the customer's conversations, messages, and custom objects will be returned masked.

## About Unmasking windows

An unmasking window temporarily reveals a customer's sensitive data. While it is open, attributes marked sensitive on the customer and on their conversations, messages and custom objects are returned unmasked instead of hidden.

Kustomer can mask sensitive fields, such as an account number or a date of birth, so they are hidden in the agent desktop and in API responses. An attribute becomes sensitive through its [custom attribute metadata](https://developer.kustomer.com/api/core-resources#custom-attributes) (`sensitive`). Sometimes an agent or an integration legitimately needs to see the real values for one customer, for example to verify identity during a call. An unmasking window grants that for a limited time.

Creating a window starts it immediately and sets its end from your org's data masking settings, 24 hours by default. A customer has at most one window: creating another replaces it and restarts the clock. When the window ends, or when you delete it, sensitive values are masked again.

#### What a window covers

The window lives on the customer, and the create response returns the customer with an `unmaskingWindow` object holding `requestedBy` (the user who opened it), `startDate` and `endDate`. While the current time is between `startDate` and `endDate`, sensitive attributes are returned unmasked on:

- the customer,
- the customer's conversations,
- the customer's messages and notes,
- the customer's custom objects (KObjects).

The values are unmasked for anyone who can read those objects, not only for the user who opened the window, and masking is unchanged for every other customer. Opening or closing a window counts as an update to the customer: it changes the customer's `updatedAt` and `rev`.

#### Which endpoint to use

| To | Call |
| --- | --- |
| Reveal a customer's sensitive data for a limited time, or restart the timer | [`POST /v1/customers/{id}/unmasking-windows`](https://developer.kustomer.com/api/core-resources/create-unmasking-window-by-customer-id) |
| Mask the data again before the window ends | [`DELETE /v1/customers/{id}/unmasking-windows`](https://developer.kustomer.com/api/core-resources/deletes-unmasking-window-by-customer-id) |

Neither request takes a body. Both return `404` if the customer doesn't exist. Close the window as soon as the task that needed it is done, rather than waiting for it to expire.

Related: [Custom attributes](https://developer.kustomer.com/api/core-resources#custom-attributes), [Customers](https://developer.kustomer.com/api/core-resources#customers), [Custom attributes concepts](https://developer.kustomer.com/docs/concepts/custom-attributes)

### Recipes

#### 1. Reveal a customer's sensitive data for one task, then mask it again

Unmask one customer's sensitive attributes while an agent or integration verifies their identity, and close the window as soon as the task is done.

**Step 1.** [`GET /v1/customers/email={email}`](https://developer.kustomer.com/api/core-resources/get-customer-by-email.md). Find the customer's ID. Sensitive attributes are masked in this response.

```bash title="cURL"
curl "https://api.kustomerapp.com/v1/customers/email=$EMAIL" \
  --header "Authorization: Bearer $KUSTOMER_API_KEY"
```

```bash title="kusty"
CUSTOMER_ID=$(kusty api GET /v1/customers/email=$EMAIL | jq -r '.data.id')
```

**Step 2.** [`POST /v1/customers/{id}/unmasking-windows`](https://developer.kustomer.com/api/core-resources/create-unmasking-window-by-customer-id.md). Open the window. There's no body; it starts now and ends after the length set in your org's data masking settings, 24 hours by default. The response is the customer, and `attributes.unmaskingWindow.endDate` says when the window closes. Creating a window for a customer who already has one restarts it.

```bash title="cURL"
curl --request POST "https://api.kustomerapp.com/v1/customers/$CUSTOMER_ID/unmasking-windows" \
  --header "Authorization: Bearer $KUSTOMER_API_KEY"
```

```bash title="kusty"
kusty api POST /v1/customers/$CUSTOMER_ID/unmasking-windows --fields attributes.unmaskingWindow
```

**Step 3.** [`GET /v1/customers/{id}`](https://developer.kustomer.com/api/core-resources/get-customer-by-id.md). Read the customer, or their conversations, messages and custom objects. Sensitive attributes now come back unmasked, for anyone who can read them, until the window closes.

```bash title="cURL"
curl "https://api.kustomerapp.com/v1/customers/$CUSTOMER_ID" \
  --header "Authorization: Bearer $KUSTOMER_API_KEY"
```

```bash title="kusty"
kusty api GET /v1/customers/$CUSTOMER_ID --fields attributes.custom
```

**Step 4.** [`DELETE /v1/customers/{id}/unmasking-windows`](https://developer.kustomer.com/api/core-resources/deletes-unmasking-window-by-customer-id.md). Close the window as soon as you're done, rather than leaving it open for the rest of its time. The call returns `204` even if the window had already ended.

```bash title="cURL"
curl --request DELETE "https://api.kustomerapp.com/v1/customers/$CUSTOMER_ID/unmasking-windows" \
  --header "Authorization: Bearer $KUSTOMER_API_KEY"
```

```bash title="kusty"
kusty api DELETE /v1/customers/$CUSTOMER_ID/unmasking-windows --confirm --yes
```

> Opening and closing a window are both updates to the customer: each changes the customer's `rev` and `updatedAt` and sends a `kustomer.customer.update` event. Close the window in a `finally` block or equivalent, so an error part-way through doesn't leave the data unmasked.

#### 2. Check whether a customer's data is unmasked, and mask it again

Find out if a customer has an open unmasking window and when it ends, and close it if nobody needs it any more.

**Step 1.** [`GET /v1/customers/{id}`](https://developer.kustomer.com/api/core-resources/get-customer-by-id.md). Read the customer and look at `attributes.unmaskingWindow`. Data is unmasked only while the current time is between `startDate` and `endDate`; the object can still be there after the window has ended, so compare the dates instead of checking that it exists.

```bash title="cURL"
curl "https://api.kustomerapp.com/v1/customers/$CUSTOMER_ID" \
  --header "Authorization: Bearer $KUSTOMER_API_KEY"
```

```bash title="kusty"
kusty api GET /v1/customers/$CUSTOMER_ID \
  | jq -r --arg now "$(date -u +%Y-%m-%dT%H:%M:%SZ)" '.data.attributes.unmaskingWindow
    | if . and .startDate <= $now and $now < .endDate
      then "unmasked until \(.endDate), opened by \(.requestedBy)" else "masked" end'
```

**Step 2.** [`DELETE /v1/customers/{id}/unmasking-windows`](https://developer.kustomer.com/api/core-resources/deletes-unmasking-window-by-customer-id.md). If the window is open and the task that needed it is finished, close it. Check with the user in `requestedBy` first if you didn't open it yourself.

```bash title="cURL"
curl --request DELETE "https://api.kustomerapp.com/v1/customers/$CUSTOMER_ID/unmasking-windows" \
  --header "Authorization: Bearer $KUSTOMER_API_KEY"
```

```bash title="kusty"
kusty api DELETE /v1/customers/$CUSTOMER_ID/unmasking-windows --confirm --yes
```

> Comparing the strings works because both are UTC ISO 8601 timestamps. It can be off by up to a second, because Kustomer's timestamps include milliseconds and the `date` value doesn't.

### Relationships

- Points to **Customers** via `relationships.customer`: An unmasking window belongs to one customer and is stored on the customer as `unmaskingWindow`. A customer has at most one window at a time.

### Permissions

Fewest roles for a read-only integration: any valid key. For every endpoint: `org.permission.unmasking_window.create`, `org.permission.unmasking_window.delete`.

## Path parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Customer ID. |

## Responses

### 204

No Content

### 401

Unauthorized

### 403

Forbidden

### 404

Not Found

## Example request

```bash
curl --request DELETE \
  --url 'https://api.kustomerapp.com/v1/customers/5f8efdd5d3de932f344ca367/unmasking-windows' \
  --header "Authorization: Bearer $KUSTOMER_API_KEY"
```
