Hey there! 👋

Using APIs with Mailmodo can help you to

  • Integrate third-party apps and tools,

  • Trigger automated campaigns from third-party apps,

  • Set trigger endpoints for Journey emails.

Even if you are new to APIs and want to use them, there's no need to worry. Here's a step-by-step guide to help you trigger mails in Mailmodo using APIs.

What are API Endpoints?

Endpoints are used for interacting with server-side web APIs, as they specify where resources lie that can be accessed by third-party software. Usually, the access is via a URL to which HTTP requests are posted, and from which the response is expected.

Simply put, API Endpoints help you to get your apps to communicate with each other.

How to trigger mails via APIs:

Creating a POST request

Following are the parameters that you will need to create a POST request.

Endpoint

You can get the trigger endpoint URL from the corresponding Transactional Campaign in the following format:

https://api.mailmodo.com/api/v1/triggerCampaign/<campaign id>

You will get this URL on enabling a transactional campaign. You can also obtain this URL for any campaign by following this path: Mailmodo Dashboard > Go to 'Transactional' tab > Select the required campaign > Trigger Info

API key

An application programming interface key (API key) is a unique identifier used to authenticate a user, developer, or calling program to an API.

You can get API keys from Mailmodo using the following path:

Mailmodo Dashboard > Go to 'Settings' tab > API Keys

You need to provide the API key with the header 'mmApiKey' in the following format:

mmApiKey: <api key value>

Request

POST requests can be generated in multiple ways.

Here are sample CURL and axios request.

Sample CURL

curl --location --request POST 'https://api.mailmodo.com/api/v1/triggerCampaign/<campaign id>' \
--header 'mmApiKey: <api key>' \
--header 'Content-Type: application/json' \
--data-raw '{
"subject":"Hi, this email is from api trigger",
"email": "apurv.gpt@gmail.com",
"data":{
"firstName" : "John",
}
}

Sample axios

var axios = require('axios');
var data = JSON.stringify(
{"subject":"Hi, this email is from api trigger",
"email":"apurv.gpt@gmail.com",
"data":{"firstName":"John"}});

var config = {
method: 'post',
url: 'https://api.mailmodo.com/api/v1/triggerCampaign/<campaign id>',
headers: {
'mmApiKey': '<api key>',
'Content-Type': 'application/json'
},
data : data
};

axios(config)
.then(function (response) {
console.log(JSON.stringify(response.data));
})
.catch(function (error) {
console.log(error);
});

Personalization parameters:

You need to make the required personalizations in the parameters before using these. These have to be passed in the 'data' in the form of a 'key-value' pair and are meant to assign values to personalization used in the subject line/ body of the mail.

For eg. {"firstName" : "John"}

💡 Important notes

  • 'Subject' is optional, if not provided, the original subject set in the campaign will be used

  • Campaign Id can be provided in the URL path or in the payload with the ‘campaignId’ key

Did we miss something? Not to worry! ✌️

🔍 Use the search bar in our Help Center to find quick guides and walkthroughs ✅

💬 Feel free to ping us with your query over the Mailmodo chat.

📧 You can also send us your queries at support@mailmodo.com

Did this answer your question?