Help CenterJourneyTrigger nodes in the journeyTrigger journey through API

Trigger journey through API

Last updated May 6, 2024

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.

For setting up a journey through an API trigger:

Create a journey using API / Webhook as a trigger point.

Trigger journey through API

Then on the journey page, click on 'Enroll Contacts' as shown below.

Trigger journey through API

Use the API endpoint to start this journey.

Start API

Endpoint: https://api.mailmodo.com/hooks/start/<journeyid> (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" }

Abort API

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/<journeyid>

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);   });

If you have any queries, then reach out to us at  Mailmodo Support  or share your thoughts at  Mailmodo Product Feedback. 

Was this article helpful?