With our email HTML importer, you can convert any HTML into our email document JSON format. You can directly load it into any of our plugins, and you can save it in your system. This documentation is for the API request, if you would like to learn about the import plugin click here.
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/v2/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 0
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/v2/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 a JSON object with one property:
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. |
images | array | Image URLs present in the document object. |
You can find the imported JSON document on result.document
.
If everything goes well with the import, you will not get any 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.",
}]