Skip to content

Create a Template

Endpoint: POST https://api.mailjet.com/v1/REST/templates This endpoint allows you to create a new email template in the Mailjet system. Creating a template is the first step in the process and involves setting up the basic structure, such as the template name, description and purpose.

This step is necessary before you can proceed to add content to your template.

Once your template has been successfully created, refer to the Create Template Content section for detailed instructions on how to add and customize the content of your template.

Body Parameters

NameTypeDescription
NamestringRequired. A unique identifier for the template.
EditModeintegerSpecifies the mode in which the template can be edited. Default value: 2. Learn more about edit modes.
LabelIDsarray of integersLabels associated with the template. See how to retrieve a list of labels here.
Purposesarray of stringsRequired if you would like the template to appear in the UI. Accepted values: marketing, transactional, automation, and opt-in. Learn more about template purposes.
Descriptionstring or nullA brief description of the template.
IsStarredbooleanIndicates whether the template is marked as a favorite. True = favorite.
IsTextPartGenerationEnabledbooleanDetermines if text part generation functionality is enabled for this template. True = enabled.

Example Requests

curl --request POST \
  --url https://api.mailjet.com/v1/rest/templates/ \
  --header 'Authorization: Bearer 612d5125131d406081abb9cd2afdc4e3' \
  --header 'Content-Type: application/json' \
  --data '{
	"Name": "Welcome to Mailjet!",
	"EditMode": 2,
	"Purposes": ["marketing", "transactional"],
	"IsStarred": true
}'

Status code: `201``

Response Data Field Structure:

NameTypeDescription
IDintegerThe ID of the template.
NamestringThe name of the template.
EditModeintegerSpecifies the mode in which the template can be edited.
LabelIDsarray of integersAn array of IDs representing labels associated with the template.
Purposesarray of stringsThe type of template. Learn more about template purposes
ExternalIDstring or nullThe ID that must be used to send the template.
Descriptionstring or nullA brief description of the template.
IsPublishedbooleanIndicates whether the template is published.
IsStarredbooleanIndicates whether the template is marked as a favorite.
IsTextPartGenerationEnabledbooleanDetermines if text part generation functionality is enabled for this template.
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": 27,
            "OrganisationID": 2,
            "Name": "Welcome to Mailjet!",
            "EditMode": 2,
            "LabelIDs": [],
            "LastContentType": null,
            "PartialIDs": [],
            "Purposes": [
                "marketing",
                "transactional"
            ],
            "Categories": [
                "e-commerce"
            ],
            "Presets": null,
            "ExternalID": "123",
            "Description": null,
            "IsPublished": false,
            "IsStarred": true,
            "SoftDeleted": false,
            "IsTextPartGenerationEnabled": false,
            "CreatedAt": "2024-05-23T09:05:22.21546Z",
            "UpdatedAt": "2024-05-23T09:05:22.21546Z"
        }
    ]
}