# Database API keys (pk_): create, copy and revoke

> Create the keys that give API access to your container database, choose the scope and expiry, and revoke the ones you no longer use.

Database API keys start with `pk_` and are used to read and write your container database (Wascer DB) through the API. They have their own section in **Settings**, below the account API keys. Account keys start with `wc_us_` and are used to operate the account: see [How to create and revoke API keys](https://wascer.com/id/helpdesk/conta-equipe-e-seguranca/chaves-de-api).

## Create a key

1. Click your name at the bottom of the sidebar and choose **Settings**.
2. In the **Database API keys (pk_)** section, click **Create API Key**.
3. In **Name**, use 2 to 100 characters. **Description (optional)** takes up to 255.
4. In **Expiration**, choose 30, 90, 260 or 320 days, or **Never**. The default is 90 days.
5. In **Scopes**, check `database:access`.
6. Click **Create**.

| Scope | What it allows |
| --- | --- |
| `database:access` | Read and write the container database through the Database API. |
| `gtm:create` | Create and provision GTM containers. Only shown when GTM is active on the account. |

The scope descriptions are shown in Portuguese. The **IP Whitelist (optional)** field limits the key to some IP addresses, but it does not apply to the Database API: there, the key works from any IP.

## Copy the key

The **API key created** screen shows the **API Key** and the **API Secret**. The Database API uses only the API Key, the one that starts with `pk_`. The API Secret is not shown again after you close the screen.

The key starts working within 2 minutes and is valid for every container in the account.

## View and revoke

The list shows **Name**, **Status** (**Active**, **Revoked** or **Expired**), **Scopes**, **Expires on** and **Last used**. Use **Search by name...** and the status filter to find a key.

Click a key to open **API Key details**. There you can reveal and copy the full key again whenever you need it.

To revoke, open the details and click **Revoke**. The key is revoked right away, **without asking for confirmation**, and database access is cut within 2 minutes. This cannot be undone.

## Use the key

The key goes inside the API address:

```plaintext
https://<container domain>/wascer-api/<API Key>/v1/store
```

The domain is the same as your server-side GTM: the container's Wascer address or your custom domain. Since the key is in the address, treat the whole address as a password. Endpoints and examples are in the [Database API documentation](https://wascer.com/docs) and in the [Wascer DB](https://wascer.com/id/helpdesk/wascer-db/wascer-db-doc) article.

## If creating the key fails

These messages are shown in Portuguese:

- **O usuario nao possui um servico ativo.** (no active service): the account needs an active plan to create the key.
- **Limite maximo de chaves de API atingido.** (key limit reached): revoke the keys you no longer use and try again.
- **Enderecos de IP invalidos** (invalid IP addresses): check the addresses in **IP Whitelist (optional)**.

Source: https://wascer.com/helpdesk/conta-equipe-e-seguranca/chaves-da-database-api
