Render template design
Turns a design, the blocks a template can be built from, into the HTML and the plain text an email gets from it. Nothing is saved and nothing is sent. Give values for variables to see the message filled in.
/v1/templates/renderBody parameters
designobjectRequiredThe blocks to render, shaped like the
designof a template.design.previewstringThe line a mail app shows beside the subject before the message is opened.
{{NAME}}marks a variable. Up to 256 characters.design.styleRecord<string, string | number>CSS for the whole message, by property name. A background colour fills the page, a
maxWidthcentres the content, andfontFamily,fontSizeandlineHeightare what text gets unless a block sets its own.design.darkRecord<string, string | number>Colours for the whole message for a reader in dark mode, by property name:
backgroundColorfills the page, andcolorandborderColorgo to the content. It takes: color, backgroundColor, borderColor.design.fontsobject[]Fonts the message loads from an address of your own, 4 at most. A block or the page uses one by naming its
familyinfontFamily, and gets itsfallbackadded for the mail apps that load no web fonts.design.fonts[].familystringRequiredThe name of the font, such as
Inter. A block or the page uses the font by naming it infontFamily.design.fonts[].fallbackstringRequiredThe fonts to use where this one does not load, the one you want most first, such as
Helvetica, Arial, sans-serif. Pick fonts every device has.design.fonts[].urlstringRequiredThe full
httpsaddress of the font file, on your own domain or a CDN. It cannot be a variable. Up to 2,048 characters.design.fonts[].formatstringRequiredThe format of the file:
woff2,woff,truetypeoropentype.One of
woff2wofftruetypeopentypedesign.fonts[].weightnumber | stringThe weight this file holds: a number from 100 to 900 in hundreds, or
normalorbold. Without it, 400.design.fonts[].stylestringThe style this file holds:
normaloritalic. Without it,normal.One of
normalitalicdesign.cssstringCSS of your own for the whole message, up to 20000 characters. It goes into the head after the rules the design makes, and reaches a block by its
className. A rule that has to beat the style a block carries needs!important.</style,@import,expression(,javascript:,behavior:,-moz-bindingare refused.design.bodyobject[]RequiredThe blocks of the message, from top to bottom. Up to 500 items.
design.body[].kindstringRequiredWhat the block is.
Section,Row,ColumnandContainerhold other blocks.Text,Heading,Button,Link,Markdown,CodeBlockandCodeInlinehold text.Imgis an image,Hra line andHtmlcustom code: HTML of your own that goes into the message as it is.One of
SectionRowColumnContainerTextHeadingButtonLinkImgHrMarkdownCodeBlockCodeInlineHtmldesign.body[].idstringA name for the block that no other block of the design has: lowercase letters, digits and hyphens. Leave it out and the block gets one.
design.body[].styleRecord<string, string | number>CSS for the block, by property name, such as
{ "fontSize": "16px", "color": "#111111" }. Only properties that work in mail are taken.design.body[].alignstringWhere the block sits across its line:
left,centerorright.One of
leftcenterrightdesign.body[].classNamestringClass names for the block, one or several with one space between them, such as
hero wide, 200 characters at most. Thecssof the design reaches the block by them. A name cannot start withr-.design.body[].onlystringThe one kind of screen the block shows on:
desktophides it on a phone, andphoneshows it on a phone and nowhere else. Without it, the block shows everywhere.One of
desktopphonedesign.body[].phoneRecord<string, string | number>CSS that takes the place of the style of the block on a phone, a screen up to 600 pixels wide, by property name, such as
{ "fontSize": "14px", "padding": "12px" }. It takes: fontSize, lineHeight, textAlign, padding, paddingTop, paddingRight, paddingBottom, paddingLeft, margin, marginTop, marginRight, marginBottom, marginLeft, width, maxWidth, height.design.body[].darkRecord<string, string | number>Colours that take the place of the ones of the block for a reader in dark mode, by property name, such as
{ "color": "#f4f4f5" }. It takes: color, backgroundColor, borderColor.design.body[].textstringThe words of a block that holds text, up to 20000 characters.
{{NAME}}marks a variable. AMarkdownblock takes Markdown here, aCodeBlocktakes the code and anHtmlblock takes its HTML, up to 60000 characters.design.body[].childrenunknown[]The blocks inside a
Section, aRow, aColumnor aContainer, each shaped like a block ofbody. ARowtakesColumnblocks only, and aColumnsits in aRowonly. Up to 500 items.design.body[].hrefstringWhere a
Buttonor aLinkleads: a full address, or one variable as the whole value, such as{{URL}}. Up to 2,048 characters.design.body[].targetstringWhere the link opens:
_blankfor a new tab or_self. Without it,_blank.One of
_blank_selfdesign.body[].srcstringThe address of the picture of an
Img: a full address, or one variable as the whole value. Up to 2,048 characters.design.body[].altstringWhat the picture of an
Imgshows, in words, for someone who cannot see it. Up to 512 characters.design.body[].widthstring | numberThe width of an
Imgor aColumn: a number of pixels, or a length such as50%. Up to 32 characters.design.body[].heightstring | numberThe height of an
Img: a number of pixels, or a length. Up to 32 characters.design.body[].valignstringWhere the content of a
Columnsits:top,middleorbottom.One of
topmiddlebottomdesign.body[].asstringThe level of a
Heading, fromh1toh6. Without it,h1.One of
h1h2h3h4h5h6design.body[].languagestringThe language of a
CodeBlock, such astypescriptorbash. One it does not know is shown as plain text. Up to 64 characters.design.body[].themestringThe colours of a
CodeBlock:oneDark,oneLight,dracula,nord,vscDarkPlus,vs,ghcolorsormaterialLight. Without it,oneDark. Up to 64 characters.design.body[].lineNumbersbooleanWhether a
CodeBlocknumbers its lines.design.body[].stackbooleantrueputs the columns of aRowunder each other on a phone. Only aRowtakes it.variablesRecord<string, string>A value for a variable, by name. A variable with no value stays in the result as
{{NAME}}.marksbooleantrueto mark every block in the HTML withdata-blockand its id, every variable in text withdata-variableand its name, and the wrapper of custom code withdata-raw, so an editor can find them. Leave it out for the HTML a template stores and sends.
Returns
htmlstringThe HTML the design makes, as a whole document.
textstringThe same message as plain text.