Template syntax
The Mattermix API uses the Handlebars templating syntax to dynamically update values in HTML or CSS. For example, you could have the following in your HTML: <p>{{title}}</p>. The title value could be updated with the API by passing a title value in the content object of the request body.
Below is an example using the Fetch API from JavaScript:
1
const body = {
2
html: "<html><body><p>{{title}}</p></body></html>",
3
content: {
4
title: "Hello World!"
5
}
6
}
7
8
const res = await fetch("mattermix.com/api/v1/image", {
9
method: "POST",
10
headers: {
11
"Content-Type": "application/json",
12
Authorization: `Bearer ${process.env.MATTERMIX_API_KEY}`
13
},
14
body: JSON.stringify(body)
15
});
Copied!
Copy link