API keys and authentication

How requests authenticate with an API key, the two kinds of key, restricting a key to one domain, and what each authentication error means.

Every request to https://api.exx.sh carries an API key in the Authorization header. A key belongs to one project: it sends from that project's verified domains and reads that project's emails, domains and webhooks. The SMTP relay takes the same keys as its password.

curl https://api.exx.sh/domains \
  -H "Authorization: Bearer $EXX_API_KEY"

An exx.sh key starts with exx_, followed by 32 letters and digits. The Bearer scheme name is case-insensitive.

Create a key

Create keys in the dashboard under API keys, or with POST /api-keys using a key with full access:

curl -X POST https://api.exx.sh/api-keys \
  -H "Authorization: Bearer $EXX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "production", "permission": "sending_access"}'
{ "id": "01a1b246-b422-7615-a9b9-09d31765fc52", "token": "exx_..." }

The token appears only in this answer. exx.sh stores a hash of it, so neither the dashboard nor the API can show it again. Put it in your environment or secret store right away; if it is lost, create a new key and revoke the old one.

Full access and sending access

PermissionWhat the key can do
full_access (the default)Every endpoint: send, read emails, attempts and metrics, and manage domains, keys, webhooks, templates and suppressions
sending_accessSend email only (POST /emails and POST /emails/batch, with or without a template)

Give each application the smallest key it needs. A server that only sends notifications needs sending_access; keep full_access keys for tooling that manages domains or webhooks.

A sending_access key can also be limited to one domain with domain_id. It then sends only from that domain, and a from address on another domain answers 403 validation_error. domain_id works with sending_access only.

Revoke a key

DELETE /api-keys/{id} or the dashboard revokes a key at once: its next request answers 401. GET /api-keys lists the project's keys with their permission and domain_id, and last_used_at, so you can find keys nobody uses any more.

Authentication errors

AnswerNameCause
401missing_api_keyNo Authorization header
401 on the sending endpoints, 400 elsewherevalidation_error ("API key is invalid")The key is unknown, revoked or malformed
401restricted_api_keyA sending_access key called an endpoint other than sending
403validation_errorA domain-restricted key sent from another domain

The split between 401 and 400 for an invalid key follows Resend, so code written for Resend handles it unchanged.

Requests without a valid key are rate limited by IP address: 2 a second, with bursts of 20. A client stuck on a revoked key therefore gets 429 answers soon. Valid keys share their organization's rate, described in rate limits and quotas.

Keys over SMTP

The SMTP relay at smtp.exx.sh takes the username exx and an API key of either permission as the password. A domain-restricted key sends only from its domain there too; another domain answers 550 5.7.1. The SMTP guide has the full settings.

Common questions

Can I use my Resend API key?

No. Resend keys (re_...) are Resend's; create an exx.sh key in the dashboard. Resend's SDKs accept an exx.sh key without changes, because they do not check the prefix.

Is a key tied to a person?

No. A key belongs to a project, not to the person who created it, so it keeps working when that person leaves the organization. Revoke the keys you no longer need.

On this page