How an email API helps optimize your transactional email

Amy Elliott Amy Elliott
· 15 min read · Tips and resources · November 29th, 2022
An email API helps grow your business by enabling you to create exceptional brand experiences that drive customer engagement and build relationships.

Email APIs play an important role in driving the interactive experience that we have come to expect when we transact online. From the start to the end of a customer journey, the email API is working tirelessly to automate email sending.

Come behind the scenes with us as we lift the curtain on email APIs. You’ll learn about what they are and how they work, and finish with a hands-on session to help you start using MailerSend’s API for your apps and websites.

Looking for an email API?

Learn more about MailerSend's flexible and reliable email API solution.

What is an email API?

An email API is an application programming interface (API) that enables other applications to use the functions of an Email Service Provider’s (ESP) platform. People use APIs to quickly integrate email services into their apps and websites using code. This includes sending transactional messages, scheduling bulk email, fetching email and recipient information, and managing accounts. 

For example, you may want to send an email triggered by recent activity on your app, like the example below. Grab, a major ride-hailing company in Southeast Asia automatically follows up with your ride by sending you a nice thank you email when you leave a tip.

Grab email to thank you for a tip

The alternative to using an ESP’s features via email API is to access them through the ESP’s Graphical User Interface (GUI). For example, you can head to the MailerSend Activity page and search for delivered emails by entering the time period, selecting the Delivered tag, and then clicking the search button.

MailerSend Activity tab

The same task can be done with the activity endpoint of MailerSend’s API. You can perform this task repetitively without the involvement of humans, and you can share the results with your technology stack. Here’s the code to retrieve delivered emails:


    "event" : ["delivered"]
Check out our email API glossary below to sharpen your knowledge of related terms.

How does an email API work?

An email API, like other APIs, is an intermediary that sits between an application and a server. It allows you to use HTTP POST requests to send outbound emails from your app or website. Users interact with the application via a GUI. Other applications can also talk directly to the API by making API calls using programming languages.

Example of API workflow

Technically speaking, an application sends a request to the API using the available endpoints listed in the API documentation. Authentication is done using an API token before the server accepts the request, sending a response using HTTP status code.

Here’s a post office metaphor to help illustrate the point. 📮

  • Parcel collection (the endpoint) is one of the many services (endpoints) offered in your local post office

  • You’re not allowed in the mailroom (the server) so you ask the kind postmaster (the API) to retrieve your parcel (the request)

  • The postmaster checks your ID (the API token) before disappearing into the mailroom and returning with your parcel (the response)

And there you have it, a simplified explanation of how an email API works using post-office-speak!

Email API use case examples

An email API enables you to automate your email sending, allowing important messages to be delivered instantaneously. This means that email API is ideal for sending transactional messages and notifications, including:

  • Order confirmations

  • Shipping notifications

  • 2-factor authentication emails

  • Password reset requests

  • Account creation notifications

  • Account activity alerts

  • Security alerts

  • Billing notifications

  • Terms of service updates

And many more.

Benefits of using an email API

An API enables you to harness the advanced features and functionality of your email platform quickly and easily, allowing for effective integration of email sending in any app. Combine this with a user-friendly interface provided by your ESP, and developers can seamlessly interact with the app using API calls while marketing teams work on email templates using various email editors.

It’s easy to manage compared to running your own email server and offers more advanced features and functionality than an SMTP relay service.

But the real reason why an email API rocks is that it will help you deliver a better customer experience and grow your business!

1. Drive customer engagement

You can keep customers engaged and motivate them to interact with your brand by sending timely updates and progress notifications. For example, MailerSend’s activity endpoint together with webhooks enables you to send triggered messages at the right time.

2. Build one-to-one relationships

A single mass email is unlikely to resonate with your customers! Instead, talk to individual people with highly personalized emails. Generate dynamic content on the fly for each recipient by using MailerSend’s email endpoint and templating engine.

3. Deliver a good experience

Your customers are on a journey that starts with your marketing emails and continues with your transactional emails. Give them a smooth and consistent brand experience by designing professional templates that get sent by an infrastructure optimized for deliverability.

4. Enable two-way communication

People love interacting, and with an email API, you can use an inbound routing endpoint to enable them to respond to comments, send messages and interact with your app via email. In MailerSend, we’ll receive the email on your behalf, parse the contents and then route it to your app or another email address.

5. Get started quickly

Email API integration is simple to set up and most third-party email API services, like MailerSend, will provide the SDKs and documentation you need to get started. Although knowledge of coding is necessary, developers can integrate email with an API in minutes.

6. Use with ease

Once you’re all set up, email sending is automated, making it an extremely efficient way to deliver transactional emails to your customers. What’s more, in MailerSend, non-technical users can easily edit templates and manage transactional emails through the GUI while developers can use the API to take care of the rest.

Start sending with email API

Sign up to MailerSend and get 12,000 emails/month free, forever.

Using email API to streamline transactional email

1. Send transactional emails

The programmatic nature of API is perfect for automating email workflows around transactions. These emails enjoy higher open rates than those sent by email marketing campaigns because recipients expect to receive them.

Check out 14 examples of transactional emails for e-commerce order confirmation emails, password resets, account activations, abandoned carts, and welcome emails.

Take advantage of this high engagement by sharing your personality, building relationships and driving conversions. Use your emails to put your brand in front of recipients, share attachments, and utilize templates using an email endpoint.

2. Fetch email information

An API can retrieve email information, pushing the data to your app or integrating it with the apps in your stack. With the domains endpoint, you can fetch a list of your domains, the recipients for each domain, and the emails sent to each recipient.

Or you could get insights into customer engagement by building a real-time digital dashboard, for example. Use the analytics endpoint to parse email metrics like the country, user agents and reading environment, then optimize your emails for your recipients.

3. Manage your account

Enjoy total control over your account settings without having to use your ESP’s app. Easily manage webhooks, tokens and domains by making API calls to add, update and delete them—including those of an app’s customers! Or pause your domain and update its tracking options with the settings endpoint.

4. Schedule bulk email

Bulk or batch emailing enables you to schedule multiple emails to be sent at a more optimal time. With bulk email, you can time messages for maximum impact, for example, by syncing them with an event. 

You can also avoid peak sending times to boost email deliverability, as well as bypass rate limiting, as bulk emailing allows you to send thousands of emails in a single request. Use a bulk email endpoint to optimize your sending in this way.

5. Manage templates

Sending emails via API allows you to create and use templates to give your messages a professional look. You can use the API to quickly fetch a list of templates or view an individual template’s data, such as bounces, sent, and delivered, without needing to scour through tons of templates to find the information you need. You can also quickly delete any template by sending a DELETE request to the templates endpoint.

6. Enhance emails with personalization

You can easily personalize your emails by inserting variables into your template to be populated in the API call. Make use of simple personalization for basic information such as name or account number. Use advanced personalization with conditional statements, for loops and filters to add dynamic tables, fallback values and conditional dynamic messaging.

Getting started with MailerSend’s API

It’s time to move beyond the theory of APIs, and talk about the fun, practical ways you can use MailerSend’s API. Before we begin, you first need to have a MailerSend account, a verified sending domain, and a terminal app like Postman or Insomnia.

Note: MailerSend is a RESTful API, meaning that it communicates using web standards to make requests using HTTP methods, responding with HTTP status codes, and formatting data in JSON. Read more at the API documentation.

All good? Let’s start!

1. Navigate to the Domains page of your MailerSend dashboard.

2. Click on Manage next to the domain that you wish to send an email from.

3. Click on Generate new token to create an API token so that you can link your app and MailerSend.

4. Scroll down to the Sending instructions section of the page. You’ll find a few code examples to send your emails using cURL, PHP, Laravel, Java, Ruby, Node.js, Go and Python.

Official MailerSend client libraries are available for PHP, Laravel, Node.js, Go and Python. You can also check out our blog post on how to send emails in your favorite programming language.

5. Copy and paste the cURL command into your terminal. You’re going to send an email by making an HTTP POST request to the API at

curl -X POST \ \
-H 'Content-Type: application/json' \
-H 'X-Requested-With: XMLHttpRequest' \
-H 'Authorization: Bearer {place your token here without brackets}' \
-d '{
"from": {
"email": ""
"to": [
"email": ""
"subject": "Hello from MailerSend!",
"text": "Greetings from the team, you got this message through MailerSend.",
"html": "Greetings from the team, you got this message through MailerSend."
Note: Remember to replace the API token and to values with your own. The from email address should be the same verified domain that you create an API token for.

6. Check the status of your email message in the Activity tab of your MailerSend dashboard.

Congratulations, you just sent your first email using MailerSend’s API! 🎉

The next step is to learn how to send email attachments, personalize your emails and use email templates with our handy guide: How to start sending emails.

Essential API glossary

Email API

A software intermediary that provides the functionality of an email service provider to other applications via code.


The touchpoint of an API where two applications communicate with each other. APIs have many endpoints, for example, to send emails, fetch email activity, and so on.

HTTP method

Request actions that you can perform with a REST API, including GET to retrieve data and PUT to replace data.


Stands for JavaScript Object Notation, a lightweight data format used to exchange data between a web server and a client.


REpresentational State Transfer is a software architectural style that uses web standards like HTTP to create interactive web applications.

SMTP relay

An email delivery service that routes messages through email servers based on the industry-standard Simple Mail Transfer Protocol.


An HTTP callback that makes HTTP requests to a URL endpoint. It is used for real-time messaging triggered by events in a web app.

You’ve taken the first few steps

An email API is an efficient way to gain maximum control over your transactional email sendings, templates, data and accounts. It gives an incredible level of additional functionality that developers can implement quickly and efficiently.

Now that you’ve been introduced to APIs and sent your first message with MailerSend, continue this momentum by studying our API documentation and creating your first calls to MailerSend’s endpoints!

How would your use cases benefit from MailerSend’s API endpoints? Share in the comments below.

Ready to transform the way you do transactional email?

Sign up now for free and get 12,000 emails per month.

Amy Elliott
I’m Amy, Content Writer at MailerSend. As a child, I dreamt about writing a book and practiced by tearing pages from an A4 notepad and binding them with sugar paper. The book is pending but in the meantime, I love taking a deep dive into technical topics and sharing insights on email metrics and deliverability.
Stop War! Help Ukraine! See what you can do