# API keys

## In the dashboard [#in-the-dashboard]

Owners make keys in **Workspace settings → API keys**. Pick a name and a scope:

| Scope | Can |
|---|---|
| Service and activity | Send service email and read activity |
| Send service email | Send, without reading activity |
| Send marketing email | Send service and marketing email |
| View activity | Read, without sending |
| Record events | Send your app's events, for automations |
| Manage API keys | Make and revoke this project's Email keys from code |

The secret is shown once. Keys made in [test mode](/docs/developers/test-mode)
start with `rlvt_test_`.

## From code [#from-code]

A key with **Manage API keys** can rotate keys in a deploy pipeline:

| | |
|---|---|
| `GET /email/api-keys` | The project's Email keys, never their secrets |
| `POST /email/api-keys` | Make a key: `name`, `scope`, optional `expires_at` and `replaces_key_id` |
| `DELETE /email/api-keys/{id}` | Revoke a key at once |

It can't make another key-managing key, and CRM and Schedule keys stay in the
dashboard, so a leaked key can't copy its own reach.

## Rotating a key [#rotating-a-key]

1. Make the new key, with `replaces_key_id` set to the old one.
2. Deploy it.
3. Revoke the old key.
