Skip to content

Publish Template Content

Endpoint: POST https://api.mailjet.com/v1/REST/templates/:id/contents/publish

You can publish the content of your template to make it available for sending.

Info

When you publish your template content, it is always the most recent draft content that is published. Be careful to verify that your most recent draft is the content that you wish to publish as that is what will be sent.

URL Paarmeters

id = The ID of the template.

Example Request

curl --request POST \
  --url https://api.mailjet.com/v1/rest/templates/1/contents/publish \
  --header 'Authorization: Bearer 612d5125131d406081abb9cd2afdc4e3' \
  --header 'Content-Type: application/json' \'

Status code 200

Response Data Field Structure

NameTypeDescription
IDintegerThe ID of the content version.
TemplateIDintegerThe ID of the template.
ContentTypestring"D", "P" or "A". Always "D" when created.
Authorstring or nullThe name of the person or entity creating the template content.
NamestringThe name of the template content.
IsLockedbooleanIf this field is true (locked), the template content cannot be edited.
LocalestringSpecifies the locale (language and region) for the template content.
MJMLPartstring or nullThe MJML code for the template.
HTMLPartstring or nullThe HTML code for the template.
TextPartstring or nullThe plain text version of the template content.
Headersjson stringAdditional headers for the template in JSON format.
CreatedAtDate RFC3339The date and time when the template was created.
UpdatedAtDate RFC3339The date and time when the template was last updated.

Example API Response

{
    "Count": 1,
	"Total": 1,
	"Data": 
	[{
		"ID": 24,
		"OrganisationID": 2,
		"UserID": 2,
		"TemplateID": 27,
		"ContentType": "P",
		"Author": "John Doe",
		"Name": "New Name",
		"IsLocked": false,
		"Locale": "fr_FR",
		"Headers": {
			"Subject": "Welcome to Mailjet",
			"From": "MyCompany <info@mycompany.com>",
			"Reply-To": "",
			"SenderName": "My Company",
			"SenderEmail": "info@mycompany.com"
		},
		"HTMLPart": "<!doctype html><html><body><p>May the delivery force be with you!</p></body></html>",
		"TextPart": "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
		"CreatedAt": "2024-05-23T09:56:00.667109Z",
		"UpdatedAt": "2024-05-23T09:56:00.667109Z"
    }]
}