API Keys

Create a key, scope it, and store it — in four steps.

1

Create the key

Go to Dashboard → API Keys → Create key. Give it a name describing where it runs — production-backend, staging-worker — so you know what breaks if you revoke it later.

2

Grant only the permissions it needs

Pick one or both. A read-only integration should never hold emails:send.

PermissionGrants
emails:sendSend email via POST /v1/emails/send.
emails:readRead email status, events, and attachment metadata.
3

Copy it now — it is shown once

Keys start with cmd_. The full value appears exactly once, at creation. After that only a masked preview (cmd_ab12…) is stored and displayed — if you lose it, create a new key rather than hunting for the old one.

4

Store it in your environment

Never commit a key to source control. Put it in an environment variable and read it at runtime.

.env
CMDSEND_API_KEY=cmd_your_api_key
import { Cmdsend } from 'cmdsend';

const cmdsend = new Cmdsend(process.env.CMDSEND_API_KEY);

Use a separate key per environment, so revoking staging never touches production.

Rotating a key without downtime

Deleting a key takes effect immediately — the very next request using it fails auth. There is no grace period and no soft-disable, so always roll the replacement out first:

  1. Create a second key with the same permissions.
  2. Deploy it to your app and confirm traffic is flowing on the new key.
  3. Delete the old key.

If a key leaks

Delete it immediately — that is the revocation. Then create a replacement and redeploy. Check Analytics & Logs for sends you do not recognise while the key was live.

Using the key in requests is covered in Authentication. Full request/response shapes are in the API Keys reference.