mailenv
All guides

How to create an API key for Amazon SES sending.

With raw Amazon SES, an "API key" means an IAM user, an access key pair, and a policy that allows sending. With MailEnv, it's one key you create in the dashboard.

5 steps 4 min read

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.

Accounts can hold up to three API keys by default. If you need more, contact us.

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.
Never commit API keys to Git or ship them in browser or mobile code. Anyone with the key can send as you. Call MailEnv from your server.

04Send with the key

Put the key in the Authorization header of each request. Send the raw key, without a Bearer prefix.

send.js
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.

FAQ

Common questions

Stuck on a step? Talk to an engineer.

Is this the same as an Amazon SES API key?

It replaces it. With raw SES you'd create an IAM user and access keys, or SMTP credentials, and manage their permissions. A MailEnv API key authenticates you to MailEnv, and MailEnv sends through Amazon SES for you.

Can I use SMTP instead of the API?

MailEnv sends through its REST API. If a tool only supports SMTP, check our integrations, or contact us about your setup.

Should I use a different key for each environment?

Yes. Separate keys for production, staging, and each service make it easy to rotate or disable one without touching the others.

Ready to send?

Request access, verify your domain, and send your first email through Amazon SES with one API key.