Endpoint: POST https://api.mailjet.com/v1/REST/templates/:id/contents
Once you have created your template, you should use this endpoint to add content to your template. You will need to specify the template ID and include either MJML, HTML or plain text.
URL Parameters: id = The ID of the template.
| Name | Type | Description |
|---|---|---|
Author | string | The name of the person or entity creating the template content. |
Name | string | The name of the template content. |
Locale | string | Required. Specifies the locale (language and region) for the template content. See the full list of accepted locales. |
MJMLPart | string | The MJML code for the template. Either MJMLPart, TextPart or HTMLPart must be provided. |
HTMLPart | string | The HTML code for the template. Either MJMLPart, TextPart or HTMLPart must be provided. |
TextPart | stringThe plain text version of the template content. Either MJMLPart, TextPart or HTMLPart must be provided. | |
Headers | json string | Additional headers for the template in JSON format. This can be used to set custom headers for the email content. |
curl --request POST \
--url https://api.mailjet.com/v1/rest/templates/27/contents \
--header 'Authorization: Bearer 612d5125131d406081abb9cd2afdc4e3' \
--header 'Content-Type: application/json' \
--data '{
"Name": "First content",
"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!",
"Locale": "en_US"
}' status code 201
| Name | Type | Description |
|---|---|---|
ID | integer | This is the ID of the version of your content. |
TemplateID | integer | This is the ID of the template. |
ContentType | string | "D", "P" or "A". Always "D" when created. |
Author | string or null | The name of the person or entity creating the template content. |
Name | string | The name of the template content. |
IsLocked | boolean | If this field is true (locked), the template content cannot be edited. |
Locale | string | Specifies the locale (language and region) for the template content. |
MJMLPart | string or null | The MJML code for the template. |
HTMLPart | string or null | The HTML code for the template. |
TextPart | string or null | The plain text version of the template content. |
Headers | json string | Headers for the template in JSON format. |
CreatedAt | Date RFC3339 | The date and time when the template was created. |
UpdatedAt | Date RFC3339 | The date and time when the template was last updated. |
{
"ID": 16,
"OrganisationID": 2,
"UserID": 2,
"TemplateID": 1,
"ContentType": "D",
"Author": "Toto",
"Name": "New Name",
"IsLocked": true,
"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-04-19T15:19:08.322718Z",
"UpdatedAt": "2024-04-19T15:19:08.322718Z"
}