With the email JSON converter, you can convert any version of our email document JSON to the latest available version. Our plugins do this on the document load, but if you want to store the latest available versions you can use these API endpoints.
There are 2 available routes to convert: email documents and email blocks. And another route to validate the result with the version schema that we provide.
Currently, these are the available versions for our email JSON:
2.0.0
3.0.0
4.0.0
(or latest
)Check below to see how to use each route.
cURL example:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <YOUR-API-KEY>" -d '{"document": <DOCUMENT-JSON>}' https://sdk-api.chamaileon.io/api/v2/emails/convert/document
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 convertDocRequest = await fetch("https://sdk-api.chamaileon.io/api/v2/emails/convert/document", {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
document,
targetVersion: "4.0.0", // optional
})
})
if (!convertDocRequest.ok) throw new Error("Auth error")
const { result } = await convertDocRequest.json()
These are the properties you can send on the body
:
Property | Type | Description |
---|---|---|
document | object | The email document object. |
targetVersion | string | The version to convert to. If not specified, it defaults to latest. |
The response is a JSON object, and you will find the converted email JSON on the result
property.
cURL example:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <YOUR-API-KEY>" -d '{"blocks": <BLOCKS-ARRAY>}' https://sdk-api.chamaileon.io/api/v2/emails/convert/blocks
You can try it from the client-side with Javascript as well, but keep in mind, that it's preferable to call this route from your backend.
const convertBlockRequest = await fetch("https://sdk-api.chamaileon.io/api/v2/emails/convert/blocks", {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
blocks,
targetVersion: "4.0.0", // optional
})
})
if (!convertBlockRequest.ok) throw new Error("Auth error")
const { result } = await convertBlockRequest.json()
These are the properties you can send on the body
:
Property | Type | Description |
---|---|---|
blocks | array | Array of email blocks object. |
targetVersion | string | The version to convert to. If not specified, it defaults to latest. |
The response is a JSON object, and you will find the converted block JSON array on the result
property.
cURL example:
curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <YOUR-API-KEY>" -d '{"document": <DOCUMENT-JSON>}' https://sdk-api.chamaileon.io/api/v2/emails/validate/document
You can try it from the client-side with Javascript as well, but keep in mind, that it's preferable to call this route from your backend.
const validateDocRequest = await fetch("https://sdk-api.chamaileon.io/api/v2/emails/validate/document", {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
document,
targetVersion: "4.0.0" // optional
})
})
if (!validateDocRequest.ok) throw new Error("Auth error")
const { result } = await validateDocRequest.json()
These are the properties you can send on the body
:
Property | Type | Description |
---|---|---|
document | object | The email document object. |
targetVersion | string | The version to be validated against. If not specified, it defaults to latest. |
The response is a JSON object, and you will find the result of the validation on the result
property.
This object includes the following properties:
Property | Type | Description |
---|---|---|
success | boolean | The result of the validation. |
errors | array | If there were any errors, they will be detailed here. |