Skip to content
Messaging · Secret guide

Leaked MailerSend API Token: what to do in the first hour

High severityDetected onlyLast verified · 5 min read

A MailerSend API token lets whoever holds it send email through your MailerSend account, and in many setups read the messages, recipients and delivery records that the account holds. Email is a powerful channel for an attacker: a token can send password-reset messages, invoices or phishing emails that come from your verified domain and pass the checks that recipients trust. Sending is also billed against your plan. Delete the token first, then check what was sent under your domain.

Check your GitHub account for leaked secrets — free

Provider
MailerSend
Severity
High
Impact
SaaS account access and billing
Checked live by LeakWatch
No

What a MailerSend API Token looks like

MailerSend API tokens start with mlsn., followed by a long run of letters and digits:

mlsn.…XXXX   MailerSend API token (masked)

The mlsn. prefix is specific to MailerSend, so a match in a file should be treated as a live credential until you have checked it. It is usually stored as MAILERSEND_API_KEY or MAILERSEND_API_TOKEN, in a .env file, in a CI variable or in an application’s configuration. Each token can be given its own permissions when it is created. A token with full access can send email, manage domains and read activity, while a token limited to sending is much less useful to someone who steals it.

MailerSend shows a token in full only once, when it is created. If the value is lost, a new token must be made, which is why teams often copy a token into several places. Every copy is a place a leak can start.

How MailerSend API Tokens get leaked

  • Environment files. A .env file with the token in it, committed to a repository that was public for a time or later shared with people who should not have it.
  • Front-end code. A token placed in a browser script or a mobile app to send mail directly. Anyone who loads the page can read it.
  • Framework configuration. A mail configuration file in a web framework or a WordPress plugin that stores the token in plain text, copied into a backup or a public theme.
  • Build logs. A deployment or test run that prints the environment, or an error message that includes the request headers.
  • Support requests. A token pasted into a support ticket, a forum post or a chat message to ask why sending fails.

What to do in the first hour

  1. Delete the token. Open the Integrations page in MailerSend, go to the API tokens list, and delete the token that leaked. The MailerSend help documentation describes deletion from the list with a confirmation step.
  2. Review sending activity. Check the activity log for emails sent in the period since the token may have been exposed. Look for messages to addresses you do not know, for templates you did not use, and for a sudden rise in volume.
  3. Check your domains. Review the verified sending domains and their DNS records, and make sure no unexpected sending domain was added. Changes to DNS are a sign that someone may have tried to take over the domain’s reputation.
  4. Create a replacement with only the permissions the application needs, usually sending only. Store it in your secret manager or CI variables.
  5. Warn your recipients if the activity shows phishing or fake invoices. A short notice from a different channel is better than silence.
  6. Clean the code. Remove the value from the files, switch the application to read the token from its environment, and check the history for older copies. See I accidentally pushed an API key to GitHub.

Not sure what else leaked from the same project? Run a free scan.

Not sure what else leaked? Run a free scan.

Revoke it at MailerSend

Tokens are listed on the API tokens page, which you can reach from the Integrations page of your MailerSend account. MailerSend’s help article on managing API tokens describes deleting a token from the menu next to it and confirming in the pop-up window. MailerSend’s help article on managing API tokens is a useful reference, and you should check the wording against the page itself. Deleting a token stops every application that uses it, so update those applications right after you create the replacement.

How LeakWatch detects it

The rule is called “MailerSend API Token”. It looks for the prefix mlsn., followed by between thirty and one hundred letters or digits, and the match must end at a quote, a space, a semicolon, a line break or the end of the line. A value shorter than the minimum, or with a different prefix, is not reported. The severity is high, with the impact class for SaaS accounts. This type is not checked live: LeakWatch does not send mail or call MailerSend with the token it finds.

LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.

FAQ

Can someone send email from my domain with this token?

Yes, if the token has sending permission. Email from a verified domain passes the checks that recipients rely on, which is why a leaked sending token is taken seriously. Review the activity log and remove any unknown sending.

Should I reuse the same token for every application?

No. Give each application its own token with the narrowest permissions it needs. A leak then affects one application and one set of permissions, rather than every service that sends mail.

Is a token that was shown only once still a risk if I deleted the copy on my laptop?

Only if it was copied elsewhere first. Check the places where the value was pasted, such as chat messages, tickets and shared notes, and remove it from each of them.

Get alerted next time a secret leaks — create a free account

LeakWatch is not affiliated with MailerSend.