Here's a guide to trigger journeys in Mailmodo using an API.

Journey building involves 2 steps:

1. Creating the journey

2. Selecting the recipient audience. This can be done through:

For setting up a journey through an API trigger:

Create a journey using API / Webhook as a trigger point. Then on the journey page, click on 'Enroll Contacts' as shown below. Use the API endpoint to start this journey.

 

 

 


StartApi

Endpoint: https://api.mailmodo.com/hooks/start/<journey id> (this will be used to trigger the particular journey every time a user-defined action occurs)

API key: Api key can be obtained from API Keys tab in Settings

Go to Settings -> API Keys

Request:

Sample CURL

curl --location --request POST
'https://api.mailmodo.com/hooks/start/<journey id>' \
--header 'mmApiKey: <MAILMODO_API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
   "email": "email for journey",
   "data": {
       "personalisation_param1": "value 1",
       "personalisation_param2": "value 2"
   }
}'


Sample Axios

var axios = require('axios');
var data = JSON.stringify({
   email: 'email for journey',
   data: { personalisation_param1: 'value 1' },
});
var config = {
   method: 'post',
   url: 'https://api.mailmodo.com/hooks/start/<journey id>',
   headers: { mmapikey: 'MAILMODO_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: to be passed in the 'data' in the form of a 'key-value' pair. These are meant to assign values to personalization used in the subject line/ body of the mail. For eg. {"firstName" : "John" }

AbortApi

You may need to abort/terminate a running journey on a particular event (eg. customer completes a CTA) or after a fixed time (if set in journey). You can use the Abortapi below to do that-

Endpoint: https://api.mailmodo.com/hooks/abort/<journey id>

API key: Api key can be obtained from API Keys tab in Settings

Go to Settings -> API Keys

Request:

Sample CURL

curl --location --request POST
'https://api.mailmodo.com/hooks/abort/<journey id>' \
--header 'mmApiKey: <MAILMODO_API_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "email to be aborted",
"reason":"reason to abort"
}'


Sample Axios

var axios = require('axios');
var data = JSON.stringify({ email: 'email to be aborted', reason: 'reason to abort' });
var config = {
   method: 'post',
   url: 'https://api.mailmodo.com/hooks/abort/<journey id>',
   headers: { mmapikey: 'MAILMODO_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);
   });
 

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.