Appearance
POST
/communication/template-text/blocks/renderRequired scope:
templatetext:readBuilds the body of an e-mail template from a block document, for the import of a mail and for the editor. Nothing is stored; it is stateless like POST /{id}/rendered. The document has the settings of the mail and sections of columns (with heading, text, image, divider and spacer items) or of html that is kept as it is. The texts are {t_*} keys with their source-language values in translations. The request is forgiving: it fixes what it safely can (a mail setting that is left out gets a default, colours to #RRGGBB, a block or formatting tag, a comment or a marker in a text, the markers and head elements of an html section, a font family without a generic family, an image that is wider than its column, a font link that is not allowed, a block tag in a text, a declaration of a style that a setStyle would refuse, the classes and the repairable findings of an html section, texts that nothing uses) and lists every fix in adjustments with the JSON pointer of the part of the document, and it refuses only what can not be made safe, with the pointer and a reason. The response has canonicalBody (a full HTML document, already cleaned, so it is what a save stores), translations (the texts that the body uses), the adjustments, findings (the checker on the result, with the data fields of the populate source) and preview (the body rendered for the source language and its default country with the merged preview data, with data-edit-id on the elements, the ids that the findings use). An html section that has a layout that mail clients do not support (flex, grid, float, position, a div around a table) is dropped and listed as html-section-dropped. The mail is 600 pixels wide, and the renderer writes no lang on the html element.
Request body ​
JSON
{
"document": {
"version": 1,
"mail": {
"pageBackground": "#F4F4F4",
"contentBackground": "#FFFFFF",
"fontFamily": "Arial, Helvetica, sans-serif",
"fontSize": 16,
"lineHeight": 24,
"textColour": "#222222",
"linkColour": "#0066CC",
"preheader": "{t_preheader}",
"fontLinks": [
"..."
],
"outerPadding": {
"top": 24,
"right": 20,
"bottom": 24,
"left": 20
}
},
"sections": [
{
"kind": "columns",
"background": "#FFFFFF",
"padding": {
"top": 24,
"right": 20,
"bottom": 24,
"left": 20
},
"border": {
"top": {...},
"right": {...},
"bottom": {...},
"left": {...}
},
"radius": 12345,
"align": "...",
"gap": 12345,
"mobile": {
"stack": true,
"padding": 12345,
"fontSize": 12345,
"lineHeight": 12345,
"style": {...}
},
"style": {
},
"columns": [
{...}
],
"html": "..."
}
]
},
"populateSource": 0,
"channel": "email",
"sourceLocale": "sv",
"translations": {
}
}
Response ​
The body, the texts, what was adjusted, the findings and a preview.
JSON
{
"canonicalBody": "...",
"translations": {
},
"adjustments": [
{
"path": "/sections/1/columns/0/items/0/colour",
"code": "colour-normalised",
"message": "..."
}
],
"findings": [
{
"code": "not-a-full-document",
"severity": "info",
"elementId": "e-1-0",
"message": "...",
"repairable": false
}
],
"preview": {
"body": "...",
"unresolvedTokens": [
"..."
]
}
}
| Error code | Description |
|---|---|
blocks-not-supported | channel is sms or invoicetext; only an e-mail can be built from blocks. |
invalid-block-document | A part of the document was refused. path is the JSON pointer of the part of the request (such as /document/sections/3/columns/1/items/2/src or /translations/t_title, with ~ and / of a name written as ~0 and ~1) and reason is one of: unsupported-version, missing-value, invalid-value (a colour with an alpha or hsl(), a length outside its range, a value that is not one of its choices), unknown-section-kind, unknown-item-type, no-columns, too-many-columns (more than 3), widths-do-not-add-up (the widths of the columns plus the gaps are not the width of the content minus the side padding and the side borders of the section), unsafe-url (a link or an image address that setLink or setImage would refuse, or one that is only a {t_*} text), image-type-not-supported (not a png, jpg, jpeg or gif), not-inline-content (a table, a list, an image, a form, a media element, a conditional comment or any other tag that a text may not have; the block and formatting tags are unwrapped and plain comments dropped), marker-in-content (a country or repeat marker in a text item), unbalanced-markup (an html section with an Outlook, country or repeat comment that opens in it and closes outside it), missing-translation (a {t_*} key of the document has no value in translations; path is the first place that uses it), translation-too-long (more than 65536 characters), marker-in-text (a text with a country or repeat marker), too-many-sections (more than 200), too-many-items (more than 100 in a column or 1000 in all), html-too-large (an html section of more than 64 KB), unknown-property (the request has a property that it does not have, such as a misspelled one; path is the property), invalid-value also for a value of the wrong type, and body-too-large (the body is longer than 2097152 characters). |
invalid-channel | channel is not email, sms or invoicetext. |
invalid-populate-source | populateSource is not an available populate source. |
language-not-found | sourceLocale is not in the supported 1:1 language↔country map. |