Email HTML Importer

With our email HTML importer, you can convert any HTML into our JSON document format. You can directly load it into any of our plugins, and you can save it in your system.

cURL example:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <YOUR-API-KEY>" -d '{"html": <HTML-STRING>}' https://sdk-api.chamaileon.io/api/v1/emails/import

You can try it from the client-side with Javascript as well, but keep in mind, that you should only do it for testing purposes. This route needs your API key in the "Authorization" header field, so if you push the following code to production, your API key will be compromised. That is why you should always call this route from your backend.

const genRequest = await fetch('https://sdk-api.chamaileon.io/api/v1/emails/import', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${apiKey}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    html: htmlString
  })
})

if (!genRequest.ok) {
  throw new Error("Auth error")
}

const response = await genRequest.json()

importedJsonTextArea.value = response.result.document

You have to send two properties on a JSON object:

Property Type Description
html string The HTML document you want to import.

The response is a JSON object, with a result property:

Property Type Description
success boolean Indicates that the import process was successful or not.
document object The imported document object.
warnings array Objects, describing warnings from the import backend. If there are no warnings, then this value is null.

You can find the imported JSON document on result.document.

If everything goes well with the import, you will not get errors or warnings.

If there were any warnings, for example, the importer found unsupported elements, then there will be a warnings array on the result object.

For example:

[
  {
    "type":"Unsupported DOM element",
    "description":"An unsupported element VIDEO was replaced with a placeholder."
  }
]