Skip to content

Sandbox Mode

The Send API v3.1 allows to run the API call in a Sandbox mode, where all validations of the payload will be done without delivering the message.

By setting the SandboxMode property to a true value, you will turn off the delivery of the message while still getting back the full range of error messages that could be related to your message processing. If the message is processed without error, the response will follow the normal response payload format, omitting only the MessageID and MessageUUID.

Info

NOTICE: The SandboxMode property is a Send API JSON payload root property like Messages, not a message JSON property.

Example

# This call sends a message to one recipient in sandbox mode.
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>!<br />May the delivery force be with you!"
				}
		],
		"SandboxMode":true
	}'

API Response

{
  "Messages": [
    {
      "Status": "success",
      "CustomID": "",
      "To": [
        {
          "Email": "passenger1@mailjet.com",
          "MessageUUID": "",
          "MessageID": 0,
          "MessageHref": "https://api.mailjet.com/v3/message/0"
        }
      ],
      "Cc": [],
      "Bcc": []
    }
  ]
}

The main content of the Send API payload will be the Messages property, which is a collection of messages, represented as a JSON array. This is the only mandatory property within the payload.

Additionally, you can use the "Globals" property to specify values for properties to be applied to all objects within the Messages array.

Finally, you can enable Sandbox mode by setting the SandboxMode property to true.

Full descriptions of the properties of each message can be found in the Email API reference