POST/v1/templates/check
Check a template with real values before rendering: text that does not fit, low contrast, failed images, layers off the canvas
Lays the template out in the browser that renders it, with your variables and modifications, and reports what would go wrong: text that overflows at its smallest size, was cut to max_lines or shrank a lot; low-contrast text; images, icons or fonts that did not load, or images drawn much bigger than they are; layers off the canvas or on top of each other; placeholders with no value. Each issue has a level (error, warning, info), the layer, a message and a fix; layers has each layer's measured facts; ok is true when nothing is an error. Free; render: true also renders the image for one unit. Check with the longest and the shortest real values before saving a design.
{
"template": "tpl_4nq8vzk2hdyw7bxme3rc",
"variables": {
"title": "A much longer headline than the one this card was designed around, to see what happens"
}
}
curl -X POST "https://api.imageapis.com/v1/templates/check" \
-H "X-API-Key: YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"template": "tpl_4nq8vzk2hdyw7bxme3rc",
"variables": {
"title": "A much longer headline than the one this card was designed around, to see what happens"
}
}'
import requests
r = requests.post("https://api.imageapis.com/v1/templates/check", headers={"X-API-Key": "YOUR_KEY"}, json={
"template": "tpl_4nq8vzk2hdyw7bxme3rc",
"variables": {
"title": "A much longer headline than the one this card was designed around, to see what happens"
}
})
print(r.status_code, r.headers.get("X-Gw-Remaining"))
print(r.json())
const r = await fetch("https://api.imageapis.com/v1/templates/check", {
method: "POST",
headers: { "X-API-Key": "YOUR_KEY", "Content-Type": "application/json" },
body: JSON.stringify({
"template": "tpl_4nq8vzk2hdyw7bxme3rc",
"variables": {
"title": "A much longer headline than the one this card was designed around, to see what happens"
}
})
});
console.log(r.status, r.headers.get("X-Gw-Remaining"));
console.log(await r.json());
200OK
{
"ok": false,
"errors": 1,
"warnings": 2,
"issues": [
{
"level": "error",
"code": "text_overflow",
"layer": "title",
"message": "title does not fit its box even at 8 px; the end is cut off",
"fix": "shorten the text, make the box bigger, or lower min_size"
},
{
"level": "warning",
"code": "low_contrast",
"layer": "site",
"message": "site has a contrast of 2.1:1 against what is behind it; 4.5:1 is the usual minimum for body text",
"fix": "darken or lighten the text or its background"
},
{
"level": "warning",
"code": "missing_variable",
"message": "{{author}} has no value, so it renders empty",
"fix": "send variables.author"
}
],
"layers": [
{
"name": "title",
"type": "text",
"x": 72,
"y": 160,
"width": 1056,
"height": 280,
"font_size": 8,
"start_size": 72,
"lines": 41,
"fits": false,
"contrast": 17.4
},
{
"name": "site",
"type": "text",
"x": 72,
"y": 72,
"width": 600,
"height": 40,
"font_size": 28,
"start_size": 28,
"lines": 1,
"fits": true,
"contrast": 2.1
}
],
"template": {
"id": "tpl_4nq8vzk2hdyw7bxme3rc",
"width": 1200,
"height": 630
}
}
401Missing or invalid API key (from the gateway)
404No such template or record on this account
{
"error": "string",
"message": "string",
"param": "string"
}