Skip to content

Get Template Content by Status

Endpoint: GET https://api.mailjet.com/v1/REST/templates/:templateid/contents/types/:content_type

You can retrieve the most recent content of your template. This endpoint allows you to access specific versions of your template content based on their status: Draft, Published, or Autosave. This can be useful for reviewing the content before making further modifications or publishing.

URL Parameters:

templateid: The ID of the template. content_type: The content status that you wish to retrieve. Accepted values: D (Draft), P (Published), A (Autosave).

Example Request

curl --request GET \
  --url https://api.mailjet.com//v1/rest/templates/1/contents/types/D \
  --header 'Authorization: Bearer 612d5125131d406081abb9cd2afdc4e3'

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 stringHeaders 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.

API Response Example

{
	"Count": 1,
	"Total": 1,
	"Data": [
		{
			"ID": 22,
			"OrganisationID": 2,
			"UserID": 2,
			"TemplateID": 27,
			"ContentType": "D",
			"Author": "",
			"Name": "First content",
			"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:21:23.672175Z",
			"UpdatedAt": "2024-05-23T09:21:23.672175Z"
      }
	]
}