# Secrets and contacts

> Store the API keys your flows sign in with, and list, read or erase the people a workspace talks to, through the REST API.

Two parts of a workspace are managed through the [REST API](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/developers/rest-api) only: the **vault** of secrets your flows sign in with, and the **contacts** your channels have talked to. The examples below run in the browser's console on a page of Ñomongeta, signed in (writes are only accepted from the same site; see [authorization](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/developers/rest-api#authorization)).

## Secrets

A secret is a credential an [HTTP request](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/flow-builder/http-request#signing-in-the-vault) step uses by name. Its value is encrypted, never returned by any route, and never reaches a flow's variables, test mode or messages.

| Route | Role | Does |
| --- | --- | --- |
| `GET /secrets` | Builder | Lists names, kinds, hosts and the value's last 4 characters (for values of 16 or more). |
| `PUT /secrets/<name>` | Admin | Creates the secret, or replaces it (`201` created, `200` replaced). |
| `DELETE /secrets/<name>` | Admin | Deletes it. Steps that still use it fail with `secret_missing`. |

```js
await fetch("/api/nomongeta/v1/secrets/reservations_api", {
  method: "PUT",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    kind: "bearer",
    value: "<the API key>",
    hosts: ["api.example.com"],
  }),
});
```

| Field | |
| --- | --- |
| `kind` | `bearer` (`Authorization: Bearer …`), `basic` (value `user:password`), `header` or `query`. |
| `param` | The header name (`header`) or the address parameter (`query`). |
| `value` | One line, up to 4,096 characters. |
| `hosts` | Where it may be sent: up to 20 names, exact (`api.example.com`) or a subdomain pattern (`*.example.com`). |

A name is up to 100 letters, digits and `_ . : -`. A workspace keeps up to 100 secrets.

> [!TIP]
> To rotate a key, `PUT` the new value under the same name: flows keep using the name, and the next request signs in with the new value.

## Contacts

A contact is one person on one channel, created on their first message: a phone number on WhatsApp, an address by e-mail, an anonymous visitor on the website chat. See [variables and contacts](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/concepts/variables-and-contacts).

| Route | Role | Does |
| --- | --- | --- |
| `GET /contacts` | Agent | Lists contacts, most recently active first. `q` searches names and addresses, `tag` filters, `limit` (up to 100), and `before` (the previous page's `next`) pages. |
| `GET /contacts/<id>` | Agent | One contact, with how many conversations it has. |
| `DELETE /contacts/<id>` | Admin | Erases the contact with their conversations, messages and flow runs. It can't be undone. |

```js
const res = await fetch("/api/nomongeta/v1/contacts?tag=vip&limit=50");
const { contacts, next } = await res.json();
```

Each contact carries its `name`, `tags`, the values of contact variables (`vars`), `lastInboundAt`, and `serviceWindowOpen`: whether WhatsApp's 24-hour window is open for it right now.

> [!NOTE]
> When someone asks you to delete their data, `DELETE /contacts/<id>` is how you erase them from a workspace. Repeat it for each channel they used: the same person on WhatsApp and by e-mail is two contacts. See [privacy](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/trust/privacy).
