Authentication
Every API request is authenticated with an API key. The key decides which account you act for, whether you are in live or test mode, and what you are allowed to call.
Send your key
Put the key in the Authorization header as a bearer token on every request. The SDKs do this for you.
curl https://api.sendfern.com/v1/domains \
-H "Authorization: Bearer $SENDFERN_API_KEY"A request with no key returns 401 not_authenticated. A key that is wrong, malformed or revoked returns 401 authentication_failed:
{
"error": {
"type": "authentication_error",
"code": "authentication_failed",
"message": "Invalid or revoked API key."
}
}Call the API from your server only. Never put a key in a browser, a mobile app or a public repository.
Live and test keys
The prefix tells you the mode:
| Prefix | Mode | What it does |
|---|---|---|
sk_live_ | Live | Sends real email, once your account is approved and your domain verified |
sk_test_ | Test | Simulates every send. Sees only test emails and test broadcasts |
Your code is the same in both modes: swap the key to switch. See Test mode for what a test key can see and change.
Permissions
Each key has one of two permissions, chosen when you create it:
- Full (
full, the default) can call every endpoint the key's mode allows. - Send-only (
send_only) can call onlyPOST /v1/emailsandPOST /v1/emails/batch, including sends from a template. Every other call, even a read, returns 403permission_denied.
Give your application servers a send-only key. If it leaks, it can't read your email log, your contacts or your other keys. Send-only keys also work as the password for the SMTP relay.
Create a key
Create keys in the dashboard under API keys. Pick a name (up to 100 characters), the mode and the permission. The dashboard's mode switch sets the mode: in test mode you can only create test keys.
Keys can't be created with an API key. POST /v1/api-keys with a key returns 403 permission_denied, so a leaked key can't make copies of itself that outlive its revocation.
List keys
GET /v1/api-keys lists the active keys of your account, newest first. It needs a full-permission key. The list never includes the secret, only its first characters in prefix, so you can tell keys apart.
curl https://api.sendfern.com/v1/api-keys \
-H "Authorization: Bearer $SENDFERN_API_KEY"{
"data": [
{
"id": "key_...",
"name": "Production server",
"mode": "live",
"permission": "send_only",
"prefix": "sk_live_Xk3fQ9",
"last_used_at": "2026-11-28T09:12:44Z",
"created_at": "2026-11-02T14:03:10Z"
}
],
"has_more": false,
"next": null
}idstring- The key's id, used to revoke it.
namestring- The name you gave the key.
modestringliveortest.permissionstringfullorsend_only.prefixstring- The first characters of the key.
last_used_atstring | null- When the key last made a request.
created_atstring- When the key was created.
Revoke a key
Revoke a key from the dashboard or with DELETE /v1/api-keys/{id} and a full-permission key. It returns 204 with no body. The revoked key stops working at once (its next request gets 401) and drops out of the list. Revoking cannot be undone.
curl -X DELETE https://api.sendfern.com/v1/api-keys/key_... \
-H "Authorization: Bearer $SENDFERN_API_KEY"- A key cannot revoke itself: that returns 400
cannot_revoke_self. Use another key or the dashboard. - Revoking a key that is already revoked returns 404.
To rotate a key, create the new one, deploy it, then revoke the old one.
What test keys can manage
A test key lists and revokes only test keys. A live key's id is 404 to it, so a leaked test key can't see or revoke your live keys. A live key manages both live and test keys.