01Open the API Keys page
Sign in and open API Keys in the dashboard. You'll need a reviewed account with onboarding complete. If you haven't finished onboarding yet, start here.
02Create a key
Enter a name and click Create API Key. Name keys after where they're used, such as production-web, staging, or billing-worker, so you can tell them apart later.
Leave Master Key (Admin Operations) unchecked. A standard key is all you need to send email, and keeping admin access out of your app limits the damage if a key leaks.
03Copy and store it safely
Keys are hidden in the dashboard. Click the copy icon next to a key to copy it. Then put it where your app reads secrets:
- An environment variable, such as
MAILENV_API_KEY. - Your platform's secret store, such as Vercel, Render, Heroku, or AWS Secrets Manager.
- Your CI provider's encrypted secrets.
04Send with the key
Put the key in the Authorization header of each request. Send the raw key, without a Bearer prefix.
await fetch('https://pub-api.mailenv.com/api/v1/send-mail', {
method: 'POST',
headers: {
Authorization: process.env.MAILENV_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({ to, from, subject, message, email_type: 'tx' }),
});A missing or unknown key returns 401. A key you've disabled returns 401 Authorization disabled.
05Disable, rotate, or delete keys
Each key on the API Keys page can be:
- Disabled with the Disable button: requests with it fail immediately, and Enable turns it back on. Use this first if you suspect a leak.
- Deleted with the Delete button: removed for good.
To rotate a key without downtime, create a new key, deploy it to your app, confirm sends succeed in Email Logs, then disable and delete the old one.