> 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.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.veilio.xyz/documentation/basics/db-search.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
