Trigger Journeys via API
Last updated November 18, 2023
Journey building involves 2 steps:
1. Creating the journey
2. Selecting the recipient audience. This can be done through-
- sending to a contact list
- uploading a new CSV list
- using an API trigger
Below is the request structure for triggering and aborting journeys through API:
API Gateway URL:
The Mailmodo API Gateway URL is https://api.mailmodo.com/
You need to include this before each API endpoint to make API calls.
API Endpoint:
Start API: https://api.mailmodo.com/hooks/start/<journey id>
Abort API: https://api.mailmodo.com/hooks/abort/<journey id>
API Authorization:
Mailmodo APIs are completely RESTful. All Mailmodo APIs are authorized via an API key.
Generate API Key:
- Login to your Mailmodo account with appropriate credentials.
- Navigate to Settings → API Keys → Show API Key to view the default API key. (You may also create a new API Key by clicking on the 'Add new API Key' button)
Request:
- Header:
'mmApiKey': '<api key value>
'
'Content-Type': 'application/json
'
- Body:
Parameters:
email | - Required field - Trigger API: email address of the recipient of the journey - Abort API: email to be aborted |
data | - For Trigger API- Optional personalization fields in key-value pairs. ex-
"First Name": "Daniel" |
reason | - For Abort API. - Reason to abort journey |
Response:
Parameters:
success | true/false |
message | "journey Executed"/"Tried executing journey and Failed" |
Sample requests:
1. Start API:
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); });
2. Abort API:
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); });