Skip to content
Menu · Concepts

Get started

Concepts

Templates and versions, variables and the data object, and the outputs Composa sends back.

Three ideas cover most of Composa: the template you print from, the data you send, and the file you get back.

Templates and versions

A template is one document design of your Team. It holds pages, text, pictures, tables and rules. Every template has an id, a UUID you copy from the app.

Each time someone presses Publish, the template gets a new version, numbered 1, 2, 3 and so on. The API prints the published version, never the draft open in the editor. So you can edit a template freely: callers see nothing until you publish.

  • Leave version out and the API prints the template's active version.
  • Send "version": 3 to pin one. Pinning a version depends on your plan; see Pricing.
  • A template that was never published answers 409.

Variables

A variable is a part of the template that changes per document: a name, a number, a colour, a picture, a list of rows. You fill variables with the data object, by their names:

json
{  "template_id": "85416813-8d99-46e8-be2b-1d61cee5db38",  "data": {    "full_name": "Ada Lovelace",    "total": 1250.5,    "paid": true,    "photo": "https://example.com/ada.jpg",    "items": [      { "product": "Notebook", "qty": 2 },      { "product": "Pen", "qty": 10 }    ]  }}

Each variable has a kind:

KindWhat to send
textA string.
numberA number, or a string that reads as one (1234.5, 1.234,5).
color#RGB, #RGBA, #RRGGBB or #RRGGBBAA.
booleantrue or false (also yes, no, 1, 0).
imageAn https:// address, or a data URL for a small picture. JPG, PNG, WebP, GIF or SVG, up to 5 MB.
listAn array of objects, one per row, keyed by the list's columns.

A name the template does not have is ignored. Read a template's fields to see every name and kind.

When a field has no usable value

A field has no usable value when it is missing, null, or holds something it cannot use, like a word for a number. Each field carries one setting, chosen by whoever made the template:

  • Stop. The call is refused with 422 and code: "no_usable_value". Nothing prints and nothing is charged. The answer names every such field at once, in problems.
  • Fallback. The document prints the value chosen for that field, and the answer says so in the composa-fallbacks header.

New fields start as stop. A refusal looks like this:

json
{  "error": "1 field has no usable value, so nothing was printed: total (not a number).",  "code": "no_usable_value",  "problems": [    { "field": "total", "reason": "not_a_number", "message": "total: not a number." }  ]}

Some fields work out their own value from a formula, a table of cases or an AI model. You do not need to send them; a value you send still wins.

Outputs

A call prints one of five formats: pdf (the default), png, jpg, webp or svg. A picture or SVG of two or more pages comes back as a zip.

You get the file in one of two ways:

  • The file itself ("output": "bytes", the default). The answer's body is the file, with its Content-Type.
  • A link ("output": "url"). The answer is JSON with a url to the file. A batch always answers with links.

A link works for one hour (24 hours for a batch's files), and the file is kept for a day. Download it; do not store the link. To keep a file at a permanent address, store it in your own storage.

Each page you print counts toward your plan's pages for the month, whatever the format. See Pricing.