Skip to content
Last updated

Frequently Asked Questions

How do I give someone access to the Content API?

The Content API supports two types of authentication:

  1. Basic Authentication
  2. Bearer Token

Basic Authentication requires a Mailjet API Key and Secret Key which can be found on your API Key Management page in Mailjet.

Once authenticated, you can create a Bearer token with a POST to https://api.mailjet.com/v1/REST/tokens. You can assign permissions to the token. Consult the full list of permissions.

How do I create a template?

Creating a template is a two-step process.

  1. Use the Template Creation endpoint POST https://api.mailjet.com/v1/REST/templates to specify the name, description, and purpose of your template.

Be sure to retrieve the ID of your template. This is the equivalent of creating an envelope for your template content.

  1. Once your template has been created, use the Template Content endpoint POST https://api.mailjet.com/v1/REST/templates/:id/contents to add content to your template by specifying the ID of your template. Content includes body text, images, links and more.

How do I revert to a previous version of my template?

If you would like to revert your template content to a previous version, here are the necessary steps:

  1. Ensure you have the ID of the template you want to revert. *You can retrieve the template ID using this endpoint: GET https://api.mailjet.com/v1/REST/templates

  2. Retrieve the versions of the template content:

  • Use the following endpoint to get a list of all versions of the template content: GET http://api.mailjet.com/v1/REST/templates/:id/contents.
  • Replace :id with your template ID.
  1. Review the retrieved versions and identify the one to which you would like to revert.

  2. Copy the Headersas well as HTMLPart, MJMLPart and/or TextPart of the desired version and use the following endpoint to update the template: PUT http://api.mailjet.com/v1/REST/templates/:id/contents/types/:content_type.

  • Replace :id with your template ID and :content_type with the appropriate content type.

Accepted content types are: D (Draft) P (Published)

Note: A template with a content type of D (Draft) cannot be sent until its content is published using the following endpoint: POST https://api.mailjet.com/v1/REST/templates/:id/contents/publish.

How do I send an email with a template that I created using the Content API?

You've created your template using the Content API. Now you'd like to send it using Mailjet's Send API. To do this, you must:

  1. Ensure your template is published
  • If you created an HTML template via API or created a template using the Mailjet drag-and-drop editor: the template must be published either through the UI or via the API.
  • Use this endpoint to publish via API: POST https://api.mailjet.com/v1/REST/templates/:id/contents/publish.
  • If you created an MJML template via API (Edit Mode 4): the template must be published in the Mailjet UI.
  1. Retrieve Your Template's External ID
  • The ExternalID can be obtained with the following endpoint: GET https://api.mailjet.com/v1/REST/templates.

Once your template is publshed and you have its ExternalID, you can proceed to the Send API to send your email.

How do I add an image using the Content API?

Uploading images for use in the Mailjet image gallery is a two-part process:

  1. Upload the image content and meta data using this endpoint: POST https://api.mailjet.com/v1/data/images
  2. Upload a thumbnail for the image using this endpoint: PUT https://api.mailjet.com/v1/data/images/:id/:content_type

When you upload a thumbnail, you will need to specify the image ID and specify a content type of thumbnail. If you do not upload a thumbnail, the image will appear in the Mailjet image gallery with a generic placeholder.