Variable types
Every template declares its variables, which you can read from
GET /api/templates/{id}. There are three types.
string
Section titled “string”A piece of text inserted where the variable sits.
{ "client": "ACME Corp", "date": "November 4, 2026", "total": "$205.00" }- Values are inserted as-is: format dates, amounts and numbers in your code.
- If the variable declares
maxLength, a longer value is rejected withVARIABLE_TOO_LONG.
boolean
Section titled “boolean”Shows or hides part of the document — a discount row, a legal paragraph, a stamp.
{ "discount": true }Send true or false. When omitted, the variable’s default applies.
object-list
Section titled “object-list”A repeating block: invoice lines, agenda items, a table of results. Send an array of objects.
{ "lines": [ { "label": "A5 flyers", "price": "$85" }, { "label": "A3 posters", "price": "$120" }, { "label": "Business cards", "price": "$40" } ]}The variable declares the shape each item must have:
{ "type": "object-list", "name": "lines", "maxItems": 4, "itemFields": [ { "name": "label", "type": "string", "required": true, "maxLength": 24 }, { "name": "price", "type": "string", "required": true, "maxLength": 10 } ]}| Field | Meaning |
|---|---|
itemFields |
The keys each object accepts, with their own limits |
maxItems |
How many rows the layout was designed to hold |
Keep your array within maxItems: the template reserves room for that many rows.
Reading the declaration
Section titled “Reading the declaration”A quick way to see what a template expects:
curl -s https://app.imprime.io/api/templates/$ID -H "x-api-key: $IMPRIME_API_KEY" \ | jq '.variableData[] | { name, type, required, default }'{ "name": "client", "type": "string", "required": false, "default": "ImprimeCorp" }{ "name": "discount", "type": "boolean", "required": false, "default": true }{ "name": "lines", "type": "object-list", "required": false, "default": [ ... ] }