Mailjet Send API allows you to leverage the Mailjet templating language in your transactional messages.
The Mailjet Templating Language enables you to achieve:
- variable substitution
- conditions, including usage of contacts segments
- loops
- and a lot more...
Info
The TemplateLanguage property in the payload provided to Send API is optional, but if you want to have the templating language interpreted, it will be mandatory and must have a true value.
Find our dedicated guide here.
# This call sends a message to the given recipient with vars and custom vars.
curl -s \
-X POST \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3.1/send \
-H 'Content-Type: application/json' \
-d '{
"Messages":[
{
"From": {
"Email": "pilot@mailjet.com",
"Name": "Mailjet Pilot"
},
"To": [
{
"Email": "passenger1@mailjet.com",
"Name": "passenger 1"
}
],
"TextPart": "Dear passenger, welcome to Mailjet! On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
"HTMLPart": "<h3>Dear passenger, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br /> On this {{var:day:\"monday\"}}, may the delivery force be with you! {{var:personalmessage:\"\"}}",
"TemplateLanguage": true,
"Subject": "Your email flight plan!",
"Variables": {
"day": "Tuesday",
"personalmessage": "Happy birthday!"
}
}
]
}'