# Enroll existing API key

`opensend api-keys enroll`

Makes a key you already use at Resend work here, so a program that holds it only needs a new address. The key is checked with Resend, kept as a hash like any other key, and gets the access it has there unless you narrow it.

Needs the scope: `api_keys:write`

## Flags

- `--name` (string, required): A name to recognise the key by, such as the app that holds it. Up to 120 characters.
- `--token` (string, required): The key itself, as Resend gave it. It starts with `re_`. It is checked with Resend, kept as a hash and never shown again.
- `--access` (string): What the key may do here: `full` or `sending`. Without it the key keeps what it may do at Resend. A key that only sends there cannot be given `full`. One of: `full`, `sending`.
- `--domain-id` (string): The id of the one domain the key may send from. Only for a key with `sending` access. Up to 64 characters.

## Returns

The command prints the answer: as JSON when its output goes to a file or another program, and as a table or a list of fields in a terminal. When the API refuses, the error goes to the error stream and the command ends with a code that names the failure. [Output and scripts](https://opensend.sh/docs/scripting) lists the codes.

- `object` ("api_key"): Always `api_key`.
- `id` (string): The id of the key.
- `name` (string): The name you gave the key.
- `access` (string): What the key may do: `full` for everything, `sending` for sending email and nothing else. One of: `full`, `sending`.
- `mode` (string): `live` for a key that sends real email, `test` for a key whose emails are simulated and reach nobody. One of: `live`, `test`.
- `preview` (string): The start of the key, enough to recognise it.
- `domainId` (string | null): The id of the one domain a sending key may send from, or `null` when it may send from any.
- `domain` (string | null): The name of that domain, or `null`.
- `lastUsedAt` (string | null): When the key last made a request, or `null` if it never has.
- `createdAt` (string): When the key was made.

## Example

CLI:

```bash
opensend api-keys enroll \
  --name 'Billing service' \
  --token re_full_access_sample_key
```

Answer:

```json
{
  "object": "api_key",
  "id": "key_05",
  "name": "Billing service",
  "access": "full",
  "mode": "live",
  "preview": "re_..._key",
  "domainId": null,
  "domain": null,
  "lastUsedAt": null,
  "createdAt": "2026-11-27T09:30:00.000Z"
}
```
