Keys / Mailgun

MAILGUN_API_KEY

The Mailgun API key your app sends email with. An account key has full access; a domain sending key can only send from one domain.

Expires
optional; you can set one when you create a key with the API
API
create, list and delete, with a full-access or Admin key

Get it

Create one on app.mailgun.com/settings/api_security. The steps aren't recorded yet.

Set it

MAILGUN_API_KEY=...

No official Mailgun SDK reads this variable. The Go SDK reads MG_API_KEY in NewMailgunFromEnv; other apps pass the key in. Or keep it out of .env with keypin: keypin run -- npm run dev

Replace it

  1. Create a new key with the same role, or a new sending key for the same domain.
  2. Deploy it everywhere that reads MAILGUN_API_KEY. Both keys work in the meantime.
  3. Check that nothing still uses the old key, then delete it.

Set rotate_every on the key in keypin.toml and a rotated date on its vault item, and keypin status shows when it's due.

Sources, checked 2026-11-16