> For the complete documentation index, see [llms.txt](https://docs.veilio.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.veilio.xyz/documentation/basics/db-search.md).

# Token Database: Search & Profiles

The **Tokenized database** page (`/dashboard/database`) is an advanced browser for tokens you are allowed to see (RBAC + organization policies).

### Search by plaintext value (blind index)

Find tokens without storing searchable plaintext in your app database:

1. Enter a value (e.g. email) and optional type filter.
2. Veilio hashes the value with your user key and matches `lookupHash` in the Clients DB.
3. Results respect the same visibility rules as the token list.

API (session only):

```http
POST /api/tokens/lookup
Content-Type: application/json

{
  "value": "user@example.com",
  "type": "email"
}
```

> Search actions are audited. The searched value is **never** written to audit logs.

### Search by profile (`entityId`)

Group tokens belonging to the same person or business record:

* Set `entityId` when tokenizing (`metadata.entityId` or `entityIdColumn` on datasets / bulk / format).
* Filter the database view by `entityId` to see all tokens for one profile.

### Bulk reveal

Select rows and **Reveal** to detokenize up to 100 tokens at once (`POST /api/tokens/reveal-bulk`). Requires write access (not VIEWER).

### Crypto-shred (destroy)

| Action               | Scope                           | API                                                                       |
| -------------------- | ------------------------------- | ------------------------------------------------------------------------- |
| Shred one token      | Single row                      | `DELETE /api/tokens/[id]` (session) or `POST /api/tokens/shred` (API key) |
| Shred selection      | Up to 200 IDs                   | `POST /api/tokens/shred-bulk` with `{ "ids": [...] }`                     |
| Shred entire profile | All tokens with same `entityId` | `POST /api/tokens/shred-bulk` with `{ "entityId": "customer_42" }`        |

Shredding is **irreversible**: encrypted payload and blind index are erased.

The dashboard asks for confirmation; profile shred requires typing the `entityId`.

### Visibility consistency

List, search, reveal, and shred all use `buildTokenVisibility` so a user never sees tokens outside their org role, dataset policies, or VIEWER whitelist.
