Skip to content
Last updated

Add email contents

By using a template

Using a template is convenient, when you have reusable content that you want to save for multiple sendings. You need to create the template beforehand with a POST on /template , or by using our drag-and-drop Email Editor builder in the Mailjet app.

The template can be personalized using contact properties, depending on your needs.

Once the template is created, do a PUT on /campaigndraft to link the template ID to your draft.

By adding custom content

When the content of your campaigns changes frequently and you have no need to store templates, you can add the Text / HTML contents directly into your campaign draft. To accomplish that, do a POST /campaigndraft/{draft_ID}/detailcontent call:

Example

curl -s \
	-X POST \
	--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
	https://api.mailjet.com/v3/REST/campaigndraft/$draft_ID/detailcontent \
	-H 'Content-Type: application/json' \
	-d '{
      "Headers":"object",
      "Html-part":"<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!",
      "MJMLContent":"",
      "Text-part":"Dear passenger, welcome to Mailjet! May the delivery force be with you!"
	}'

API Response

{
	"Count": 1,
	"Data": [
		{
			"Headers": "object",
			"Html-part": "<h3>Dear passenger, welcome to Mailjet!</h3><br />May the delivery force be with you!",
			"MJMLContent": "",
			"Text-part": "Dear passenger, welcome to Mailjet! May the delivery force be with you!"
		}
	],
	"Total": 1
}