Skip to main content
TemplatesVersion: v3New

Create an email template

POST/emails/locations/{locationId}/templates

Create a reusable email template (a design saved to the Templates list, not sent by itself). Use it when the user asks for a template or a design to reuse; to send an email to contacts, create a campaign with Create Email Campaign (optionally from this template with templateId).

Authorizations

Authorizationstringheaderrequired

Bearer authentication header of the form Bearer <token>, where <token> is your access token.

Scope:emails/templates.write
Auth methods:OAuthPrivate Integration
Token type:Sub-Account Token

Request​

Headers

Idempotency-Keystring

Unique key per intended write (max 255 chars). Retrying with the same key and body within 24 hours returns the first response instead of creating another resource. Reusing the key with a different body returns 422; a retry while the first request is still running returns 409.

Example:0f8fad5b-d9cb-469f-a165-70867728950e
Versionstringrequired

API Version

Available optionsv3
Example:v3

Path Parameters

locationIdstringrequired

Location ID

Example:ve9EPM428h8vShlRW1KT

Body

namestringrequired

Template name

Example:Newsletter Template
editorTypestringrequired

Editor type for the new template. html = code editor (raw HTML string), text = plain-text email (string), builder = design (drag-and-drop) editor (JSON, see BuilderEditorContentPublicV2Dto). Merge fields are Handlebars: {{contact.first_name}}, a fallback is {{default contact.first_name "there"}}, a condition is {{#if contact.city}}...{{/if}}. Liquid filters such as {{contact.first_name | default: "there"}} are not supported and block the send. Send editorType alone to create a blank template.

Available optionshtmlbuildertext
Example:html
editorContentobject

Optional initial editor content: an HTML or plain-text string for html/text, or design-editor JSON for builder. Design-editor (builder) JSON. elements is the layout tree: mj-section > mj-column > leaf elements. Every node has a unique id and a tagName. attrs is a flat map keyed by node id (one entry for every node in the tree, sections and columns included): { tagName, content, attributes: [{ name, default, unit? }] }. content holds the text/HTML of leaf elements such as mj-text and mj-button. Each attribute is { name, default, unit? }: default is the value, and sizes are a number plus unit (px or %), e.g. { name: "font-size", default: 16, unit: "px" }. Padding is split into padding-top, padding-right, padding-bottom and padding-left with enable-padding set to true; the padding shorthand and inline style are not read by the editor. Send the full attribute set below for every element, changing only the values you need. When an element is selected in the editor, every listed attribute missing from the JSON is written in with the default shown here, so a partial list changes the design (background, padding, font) on first click. Text and image backgrounds use container-background-color; section and button backgrounds use background-color. Element attributes and the editor defaults: mj-section: enable-padding=true, padding-top=10px, padding-right=20px, padding-bottom=10px, padding-left=20px, background-color=#ffffff, background-url="", background-size=auto, background-repeat=repeat, full-width=false, text-align=center, border-radius=0px, border-width=0px, border-color="". mj-column: enable-padding=true, padding-top=0px, padding-right=0px, padding-bottom=0px, padding-left=0px, is-unstacked=false. mj-text: enable-padding=true, padding-top=12px, padding-right=24px, padding-bottom=12px, padding-left=24px, font-family=arial, helvetica, sans-serif, font-size=14px, line-height=1.5, container-background-color="". mj-image: enable-padding=true, padding-top=10px, padding-right=20px, padding-bottom=10px, padding-left=20px, src=https://..., alt="", href="", width=null, height=null, align=center, border-radius=0px, container-background-color="". mj-button: enable-padding=true, padding-top=10px, padding-right=20px, padding-bottom=10px, padding-left=20px, background-color=#00a4bd, color=#ffffff, font-family=Ubuntu, Helvetica, Arial, sans-serif, font-size=14px, align=center, border-radius=6px, border-width=0px, border-color=#00a4bd, redirectAction=url, url="". mj-divider: enable-padding=true, padding-top=10px, padding-right=20px, padding-bottom=10px, padding-left=20px, border-width=2px, border-color=#99acc2, border-style=solid, width=100%, align=center. mj-spacer: height=20px, container-background-color="". Buttons are mj-button elements (text in content, colors and link in attributes). mj-text content is edited as rich text and keeps only paragraphs, headings <h1>-<h6>, text-align, <span style> font/size/color, <strong>, <em>, <u>, <s>, links <a href>, lists and <br>; other markup (a link styled as a button with background or padding, tables, <div>, block styles) renders in the email but the editor drops it on edit, so the canvas shows something different from what is sent. Images: mj-image needs src set to a public https URL of the image (upload a file first with the Medias API and use its URL); without src the editor shows a placeholder. Set alt for accessibility and href to make the image a link. Leave width and height as null for the natural size (capped to the column) or set a number with unit: "px"; never omit them or send "". templateSettings holds template-wide theme settings as lists of { name, default, unit? } grouped by body (width, background-color, body-color, border, background image), button, divider, text (fonts, line-height, link styles) and header (customCss). To keep the current theme, send back the templateSettings that Get returned. Text fonts: inside mj-text content set font-family, font-size and color on a <span style="..."> around the text (e.g. <h1><span style="font-family: georgia, palatino, serif; font-size: 32px">Title</span></h1>); the editor toolbar reads fonts only from these spans, so styles on <h1>/<p> themselves show as the default font and size. Use one of these exact font-family values: arial, helvetica, sans-serif, helvetica, arial, sans-serif, verdana, geneva, sans-serif, georgia, palatino, serif, 'times new roman', times, serif, 'trebuchet ms', geneva, sans-serif, 'arial black', sans-serif, 'andale mono', monospace, Ubuntu, Helvetica, Arial, sans-serif. Google fonts: use 'Font Name', <fallback from the list above> (quotes only when the name has a space) and list every Google font used in templateSettings.text as { name: "custom-fonts", default: "Font One;Font Two" }; fonts not listed there are not loaded and fall back. Brand-board fonts: use 'Brand Font Name', <fallback> and list their brand font ids in { name: "brand-custom-fonts", default: "id1;id2" }. Keep both entries when sending back templateSettings. Supported leaf tags: mj-text, mj-image, mj-logo, mj-button, mj-divider, mj-spacer, mj-social, mj-video, mj-raw, mj-footer, mj-accordion, mj-carousel, mj-countdown-timer, mj-form, mj-product, mj-shopping-cart, mj-review-link, mj-rss-header, mj-rss-item, mj-preview-url. For tags not listed above, copy an existing element of that tag from a Get response. Buttons link through redirectAction (url, mail, telephone, sms, skype, other, file) plus the attribute it names, e.g. { name: "redirectAction", default: "url" } with { name: "url", default: "https://..." }; href alone renders no link. Nodes without an attrs entry are skipped when rendering. Merge fields are Handlebars: {{contact.first_name}}, a fallback is {{default contact.first_name "there"}}, a condition is {{#if contact.city}}...{{/if}}. Liquid filters such as {{contact.first_name | default: "there"}} are not supported and block the send.

Example:<html><body>Hello World</body></html>
parentFolderIdstring

Parent folder ID

Example:67f15c2ae99226d5bcccb8f0
subjectLinestring

Email subject line

Example:Welcome to our newsletter
fromNamestring

Sender name

Example:John Doe
fromEmailstring

Sender email address

previewTextstring

Preview text

Example:Email preview text
userIdstring

ID of the user performing this action

Example:507f1f77bcf86cd799439011

Response

Success

idstringrequired

Template ID

Example:507f1f77bcf86cd799439011
namestringrequired

Template name

Example:Newsletter Template
editorTypestringrequired

Editor type. html = code editor (raw HTML string), text = plain-text email (string), builder = design (drag-and-drop) editor (JSON, see BuilderEditorContentPublicV2Dto). Merge fields are Handlebars: {{contact.first_name}}, a fallback is {{default contact.first_name "there"}}, a condition is {{#if contact.city}}...{{/if}}. Liquid filters such as {{contact.first_name | default: "there"}} are not supported and block the send.

Available optionshtmlbuildertext
Example:html
isPlainTextbooleanrequired

Whether template is plain text

Example:false
parentFolderIdstring

Parent folder ID

Example:67f15c2ae99226d5bcccb8f0
fromNamestring

Sender name

Example:John Doe
fromEmailstring

Sender email address

subjectLinestring

Email subject line

Example:Welcome to our newsletter
previewTextstring

Preview text

Example:Email preview text
previewUrlstring

Preview URL

Example:https://example.com/preview/template123
createdAtstring

Created timestamp

Example:2025-07-24T11:55:43.598Z
updatedAtstring

Updated timestamp

Example:2025-07-24T11:55:43.598Z
traceIdstring

Trace ID of request

Example:019e4ef5-a65e-4198-8cf9-8e93dca9bda4