Skip to content

Convert JSON template to HTML

POST
/email/v1/json2html

Convert JSON template to HTML using MJML rendering engine. Authentication is done via the X-Secret-Key header.

If the template contains synced sections (any section node with a syncedId property), the matching content must be supplied through the optional syncedSections request field. Synced section references are resolved before merge tag evaluation and variant rendering: the endpoint looks up each syncedId in the supplied array, splices the section's full MJML into the template, regenerates child block UIDs to avoid collisions, and (for multilingual templates) merges per-locale translations into the template's langs array. Without this step, synced sections render as empty placeholders.

Authorizations

SecretKeyAuth

Secret key for authentication

Type
API Key (header: X-Secret-Key)

Request Body

application/json
JSON
{
  
"definition": "{"tagName":"mj-global-style","attributes":{"h1:color":"#000000","h1:font-family":"Helvetica, Arial, sans-serif","h2:color":"#000000","h2:font-family":"Helvetica, Arial, sans-serif","h3:color":"#000000","h3:font-family":"Helvetica, Arial, sans-serif",":color":"#000000",":font-family":"Helvetica, Arial, sans-serif",":line-height":"1.5","a:color":"#24bfbc","button:background-color":"#e85034","containerWidth":600,"fonts":"Helvetica,Arial,sans-serif","mj-text":{"line-height":1.5,"font-size":15,"font-family":"Helvetica, Arial, sans-serif"},"mj-button":{"font-size":"13px"}},"children":[{"tagName":"mj-body","attributes":{"background-color":"#FFFFFF","containerWidth":600},"children":[{"tagName":"mj-section","attributes":{"full-width":"600px","padding":"10px 10px","mj-class":"section"},"children":[{"tagName":"mj-column","attributes":{"width":"100%","vertical-align":"top"},"children":[{"uid":"9qJHlWzLp","tagName":"mj-text","content":"<p>This is your new text block with the first paragraph.</p>","attributes":{"align":"left","padding":"15px 15px 15px 15px","line-height":1.5,"containerWidth":600},"customKey":null}],"uid":"HJQ8ytZzW"}],"layout":1,"backgroundColor":null,"backgroundImage":null,"paddingTop":0,"paddingBottom":0,"paddingLeft":0,"paddingRight":0,"uid":"Byggju-zb"}]}],"style":{"h1":{"font-family":"Helvetica, Arial, sans-serif","font-size":"22px","font-weight":"bold"},"a":{"color":"#0000EE"},"h2":{"font-family":"Helvetica, Arial, sans-serif","font-size":"17px","font-weight":"bold"},"h3":{"font-family":"Helvetica, Arial, sans-serif","font-size":"13px","font-weight":"bold"},"p":{"font-family":"Helvetica, Arial, sans-serif","font-size":"11px"},"ul":{"font-size":"11px","font-family":"Helvetica, Arial, sans-serif"},"li":{"font-size":"11px","font-family":"Helvetica, Arial, sans-serif"},"ol":{"font-size":"11px","font-family":"Helvetica, Arial, sans-serif"},".rounded>table":{"border-collapse":"separate"}},"fonts":["Helvetica, Arial, sans-serif"],"feedBlocksApplyToAll":{},"langs":[{"key":"en","primary":true,"translations":{"9qJHlWzLp":{"content":"<p>This is your new text block with the first paragraph.</p>"}}}]}",
  
"options": {
  
  
"minify": true,
  
  
"fonts": "[{"label":"Open Sans","style":"Open Sans, sans-serif","url":"https://fonts.googleapis.com/css?family=Open+Sans:400,700"}]",
  
  
"emailServiceProvider": "mailchimp",
  
  
"mergeTags": [
  
  
],
  
  
"evaluateMergeTags": false,
  
  
"variants": {
  
  
  
"evaluate": false,
  
  
  
"enrichWithConditions": true
  
  
},
  
  
"desktopFirst": false,
  
  
"language": "en"
  
},
  
"syncedSections": [
  
  
{
  
  
  
"id": 1,
  
  
  
"definition": "string",
  
  
  
"translation": "string"
  
  
}
  
]
}

Responses

Template converted successfully

application/json
JSON
{
  
"html": "<html><body>Hello World</body></html>",
  
"warnings": [
  
  
{
  
  
  
"type": "missing_fonts",
  
  
  
"message": "Some fonts are missing",
  
  
  
"missing_fonts": [
  
  
  
  
[
  
  
  
  
  
"Arial",
  
  
  
  
  
"Helvetica"
  
  
  
  
]
  
  
  
]
  
  
}
  
]
}

Playground

Authorization
Body

Samples

Powered by VitePress OpenAPI