Keys leak in ordinary ways: a commit to a public repository, a screenshot, a log file, a support ticket. Rotating takes a few minutes.
1. Decide how urgent it is
- Signs of abuse (emails you did not send, bounce spikes): revoke the old key first (step 4), then create and deploy a new one. Your app cannot send for a few minutes, but nobody else can either.
- No signs of abuse: follow the steps in order, so your app never stops.
2. Create the replacement
Open API keys and press Create API key. Give it the same permission and the same Limit to one domain as the leaked key, and a name that shows it is new, for example “Production web 2026-11”. Copy the key (it starts with mc_live_ and is shown once).
With the API (full-access key that is not the leaked one):
curl https://api.mailcandor.com/v1/api-keys \
-H "Authorization: Bearer $MAILCANDOR_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "Production web 2026-11", "permission": "sending"}'
3. Deploy the new key
Update every place the old key lived:
- environment variables or the secrets store (
MAILCANDOR_KEY), - SMTP settings, where the password is the key,
- CI secrets, staging, background workers.
Check the new key works:
curl https://api.mailcandor.com/v1/whoami -H "Authorization: Bearer $NEW_KEY"
On the API keys page, the new key’s Last used should change from Never, and the old key’s should stop moving.
4. Revoke the leaked key
In the dashboard: API keys → Revoke on the old key → Revoke key. “Anything still using this key stops working at once. This cannot be undone.”
With the API:
curl -X DELETE https://api.mailcandor.com/v1/api-keys/$OLD_KEY_ID \
-H "Authorization: Bearer $MAILCANDOR_ADMIN_KEY"
The answer is 204. Find the id with GET /v1/api-keys; the prefix (for example mc_live_a1b2c3) helps you match it.
5. Look for misuse
- Emails: filter by date and look for subjects or recipients you do not recognise.
- Deliverability: a sudden rise in bounces or complaints.
- Audit log (admins): filter API keys for
api_key.createdyou did not make, and Webhooks for new endpoints. A full-access key could have done either. Revoke and delete anything unknown. - Webhooks: check every endpoint URL is yours.
If a leaked key sent mail you did not authorise, write to hello@mailcandor.com with the time window, so we can help protect your sending reputation.
6. Remove the key from where it leaked
Revoked keys cannot be used again, but clean up anyway: delete the file or message, and if it was committed, remove it from the repository history so it does not trigger alerts later.
Prevent the next one
- Use sending-only keys, locked to a domain, in apps. A leaked one can only send as that domain.
- One key per place, named after it.
- Keep keys in a secrets store and add secret scanning to your repository.
If it does not work
- “This is the key making the request.” You tried to revoke the leaked key with itself. Use another full-access key or the dashboard.
- 403 forbidden “The person who created this API key cannot manage keys on this team any more.” Use a key made by a current admin or developer, or the dashboard.
- App gets 401 after revoking. Some place still has the old key. Search your config for its prefix.
Key endpoints are in the API reference.