To send messages in bulk, package the multiple messages inside the Messages property.
The messages’ order is preserved from the user input, allowing you to identify which message response corresponds to your original message payload.
# This call sends 2 messages to 2 different recipients.
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"
}
],
"Subject": "Your email flight plan!",
"TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!",
"HTMLPart": "<h3>Dear passenger 1, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!</h3><br />May the delivery force be with you!"
},
{
"From": {
"Email": "pilot@mailjet.com",
"Name": "Mailjet Pilot"
},
"To": [
{
"Email": "passenger2@mailjet.com",
"Name": "passenger 2"
}
],
"Subject": "Your email flight plan!",
"TextPart": "Dear passenger 2, welcome to Mailjet! May the delivery force be with you!",
"HTMLPart": "<h3>Dear passenger 2, welcome to <a href=\"https://www.mailjet.com/\">Mailjet</a>!<br />May the delivery force be with you!"
}
]
}'{
"Messages": [
{
"Status": "success",
"To": [
{
"Email": "passenger1@mailjet.com",
"MessageUUID": "123",
"MessageID": 20547681647433000,
"MessageHref": "https://api.mailjet.com/v3/message/20547681647433000"
}
]
},
{
"Status": "success",
"To": [
{
"Email": "passenger2@mailjet.com",
"MessageUUID": "124",
"MessageID": 20547681647433001,
"MessageHref": "https://api.mailjet.com/v3/message/20547681647433001"
}
]
}
]
}In case of errors on one or several of the messages, the API will not stop the processing of other successful messages. All validated messages will be processed for sending and the response will include both MessageIDs and Error reports.
{
"Messages": [
{
"Errors": [
{
"ErrorIdentifier": "88b5ca9f-5f1f-42e7-a45e-9ecbad0c285e",
"ErrorCode": "send-0003",
"StatusCode": 400,
"ErrorMessage": "At least \"HTMLPart\", \"TextPart\" or \"TemplateID\" must be provided.",
"ErrorRelatedTo": ["HTMLPart", "TextPart"]
}
],
"Status": "error"
},
{
"Status": "success",
"CustomID": "",
"To": [
{
"Email": "passenger2@mailjet.com",
"MessageUUID": "cb927469-36fd-4c02-bce4-0d199929a207",
"MessageID": 70650219165027410,
"MessageHref": "https://api.mailjet.com/v3/REST/message/70650219165027410"
}
],
"Cc": [],
"Bcc": []
}
]
}