Workflows
Image variables
Vary an image from one document to the next: declare an image variable or an image column, cite it with a token, give it a shape, and understand what Doclift downloads, keeps and refuses.
An image variable varies an image from one document to the next: a client
logo, a signature, a photograph. You declare the variable once, you cite it
in the content with a token, and each generation request sends the
https:// address of the image to print. Doclift downloads the image when
it generates the document.
This page is the entry point on the subject. For a fixed image (a logo identical in every document), import it once instead, as described in Images: the rendering engine fetches nothing over the network (variable images are the exception: Doclift downloads them before rendering), so an image cited by an external address is removed from the PDF.
Workflows are in private beta, available on request at [email protected]; see Workflows.
Capabilities are authoritative
Every limit on this page is your organization's own, read live from
GET /api/v1/workflows/capabilities (see
Capabilities are authoritative, not a copy).
This page names the key to read; it copies no value, because a copied value
ends up wrong.
| What you are looking for | capabilities key |
|---|---|
| image | variable.field_types |
| The types of a collection column | variable.collection.fields.row_field_types |
| The types of a sub-collection column, and the depth allowed | variable.collection.fields.nested.nested_field_types, variable.collection.fields.nested.max_depth |
| The image shapes and the radius of the rounded shape | image_shapes.shapes (class, radius_px) |
| The token of an image | content.tokens.image |
| The number of images, the weight and the download time of a document | limits.image_variables (max_images, document_pixels, document_bytes, band_bytes, download_seconds) |
| The same limits in sandbox, including the number of downloads per minute | limits.image_variables.sandbox (max_images, document_pixels, download_seconds, fetches_per_minute) |
| source_url | limits.author_images (formats, svg_max_bytes, max_pixels, source_url_fetch_seconds, parallel_fetches_per_organization, upload_link_lifetime_minutes) |
| The rows of a collection and of a sub-collection | limits.collections (max_rows, max_nested_rows, max_depth) |
Declaring an image variable
An image variable is created like any workflow variable, with
field_type: "image". Image variables exist only in workflows: custom
templates do not know them (see Variables).
curl https://app.doclift.io/api/v1/workflows/templates/100050/variables \
--request POST \
--header "X-Api-Key: <your-api-key>" \
--header "Content-Type: application/json" \
--data '{
"variable": {
"name": "logo",
"description": "Company logo",
"field_type": "image",
"required": true,
"seed_value": "https://example.com/logo.png"
}
}'
{
"id": 200100,
"name": "logo",
"description": "Company logo",
"field_type": "image",
"allowed_values": [],
"seed_value": "https://example.com/logo.png",
"required": true,
"fields": []
}
seed_value is the example that the preview and the payload contract show.
For an author, it is either an https:// address (neither to Doclift nor to
an SVG), or, as a test value, the path /workflows/images/<token> of an
image of the same organization. The value of a generation request, on the
other hand, is always a public https:// address (see
The value sent to generation). An image
variable does not accept allowed_values. See
Variables for the other
fields and the 422 cases.
Citing the image in the content
An image is cited in the content of a section with a token. Like every
token, it is recognized by its class and not by its tag, and the name of
the variable is its text. Take the exact class from content.tokens.image:
<variable class="editor-img-variable non-editable-content editor-parsed" width="150" height="75">logo</variable>
width and height are in pixels and describe a maximum frame: the
image is scaled down to fit inside it while keeping its proportions, and is
never enlarged. A small image therefore prints at its own size. It is
never wider than the box that contains it. Always write both.
The smaller the frame, the less the image costs (in time, in memory, and
in limits.image_variables.document_pixels): an image is prepared for the
frame you draw, not for the page. An image placed in a header or a footer
weighs on a much smaller budget (limits.image_variables.band_bytes):
choose a small logo there, no taller than authoring.band.picture_px_at_minimum.
An image variable can also be cited in a repeated section (repeat_over)
or in a table row, when it is a collection column: see
Images in a collection.
Giving the image a shape
An image, imported or variable, can carry a shape. The shape is a class added to the image or to its token, as the last class:
<variable class="editor-img-variable non-editable-content editor-parsed wf-shape-circle" width="120" height="120">logo</variable>
The list of shapes is image_shapes.shapes in capabilities; with no shape
class, the image is a rectangle.
| Shape | Class | Effect |
|---|---|---|
| Rounded | wf-shape-rounded | Rounds the corners with a single radius, published under radius_px, and nothing else: the frame stays a maximum in which the image is scaled down, never enlarged, and the image is not cropped. |
| Circle | wf-shape-circle | Requires a width or a height in pixels. The side is the smaller of the two, the image fills that square and is cropped to fit it, and an image smaller than the square is enlarged. |
If several shape classes are present, the first one in the list wins (in
the order of image_shapes.shapes, not in the order you wrote them).
The circle behaves differently depending on what it is applied to:
- on an image variable token with no size in pixels, no shape is
applied and the non-blocking anomaly
image_shape_adjustedis raised; - on an imported image (an
<img>) with no size in pixels, the circle is applied from the width the image already has, with no anomaly.
In both cases, a circle on a frame that is not square (different width and
height) prints at its smaller side and raises image_shape_adjusted, like
an unknown shape class: the image prints, but not as drawn. See
Anomaly types.
The value sent to generation
In the variables of POST /api/v1/document_requests, the value of an
image variable is an https:// address, and nothing else: no base64, no
data: URI, no reference to an image stored by Doclift.
The address is refused with a 422 that names the variable when:
- it does not start with
https://, or is not a valid address; - it carries a user name or a password;
- it uses a port other than the standard
httpsport (443); - it points at Doclift itself;
- it points at an SVG;
- its host is not written in ASCII (use its punycode form) or it contains a backslash.
An address that passes these checks is not yet a usable image: what it contains is judged when the document is generated.
The download happens before rendering, never by the rendering engine itself. Three consequences:
- the address must be reachable from the internet during generation. A signed address must stay valid long enough for the request to be processed: a sandbox request goes through the low-priority queue and may wait;
- the accepted formats are PNG, JPEG and WebP. The format is recognized from
the content of the file, not from its extension or the
Content-Typeheader; - a supplied image that cannot be used makes the generation fail: the document is never delivered with an empty frame. See When an image is refused.
An image variable left empty prints nothing, and nothing is refused, unless
the variable is required and its key is absent from the payload, as
with any other variable.
The same image cited in several frames of the same document is downloaded
only once, and counts only once in limits.image_variables.max_images.
Test values are not integration values
To try a workflow, an author can cite an image they imported into the
organization (a relative address /workflows/images/<token>) as a test
value or seed_value. The production API never accepts that form: it
requires an https:// address. Do not copy a test value into an
integration.
Conditions on an image
Only present (there is an image) and blank (there is none) make sense on
an image variable, since its value is an address. Any other operator is the
blocking anomaly image_comparison. Conversely, an image token written for a
variable that is not an image is the blocking anomaly image_token_misuse:
the declared type decides what prints, and the token would print the text of
the variable instead of the image.
Images in a collection
Image column
A column of a collection can be an image: give it field_type: "image" in
fields. Each row then carries its own address. The possible types of a
column are variable.collection.fields.row_field_types.
Cite it from inside the repetition, with a token named collection.column,
in a section or a group repeated over the collection, or in a table row
<tr data-loop="collection">:
<variable class="editor-img-variable non-editable-content editor-parsed wf-shape-rounded" width="150" height="75">projets.icone</variable>
Same frame, same shape, same rules as an image variable. A row whose image
is empty or absent prints nothing at that spot, and the rest of its block
prints. Written outside its repetition, the token is the blocking anomaly
out_of_loop_reference.
Sub-collection
A column of type collection, with its own fields, opens a
sub-collection: per project, a list of rows. Its columns are of type
text or image (variable.collection.fields.nested.nested_field_types),
on a single level (variable.collection.fields.nested.max_depth, the
root collection counting as level 1). A third level is refused when the
variable is created.
A sub-collection prints as a repeated table row, in a node (section or group) that is itself repeated over the parent collection:
<table>
<tbody>
<tr data-loop="projets.lignes">
<td><variable class="editor-text-variable non-editable-content editor-parsed">projets.lignes.date</variable></td>
<td><variable class="editor-img-variable non-editable-content editor-parsed" width="60" height="60">projets.lignes.photo</variable></td>
</tr>
</tbody>
</table>
A cell can also cite projets.nom: that is the project currently printing.
There is no section or group repeated over a sub-collection, and no loop over
a sub-collection outside a node repeated over its parent. A project with no
rows keeps the header of the table and loses the template row; to hide the
whole table, place it in a section whose condition is projets.lignes
present (present and blank are the only operators allowed, otherwise
collection_comparison). A token that names a whole collection
({{projets}}, {{projets.lignes}}) prints nothing and is the blocking
anomaly collection_as_value: cite its fields.
The variable is declared like this (example):
{
"id": 200101,
"name": "projets",
"description": "One row per project",
"field_type": "collection",
"allowed_values": [],
"seed_value": null,
"required": false,
"fields": [
{ "name": "nom", "required": true, "description": "Project name" },
{ "name": "icone", "field_type": "image", "description": "Project picture" },
{
"name": "lignes",
"field_type": "collection",
"description": "Milestones",
"fields": [
{ "name": "date", "description": "Milestone date" },
{ "name": "photo", "field_type": "image", "description": "Milestone picture" }
]
}
]
}
The payload follows the declared type: a list under a column that is not a
collection is refused, like a scalar or an object under a column that is
one; null means no rows.
{
"logo": "https://example.com/logo.png",
"projets": [
{
"nom": "Rhone Sud",
"icone": "https://example.com/rhone-sud.png",
"lignes": [
{ "date": "2026-01-02", "photo": "https://example.com/chantier.png" }
]
}
]
}
The row limits are limits.collections.max_rows (per collection and per
sub-collection) and limits.collections.max_nested_rows (all the
sub-collections of a single variable together). A collection or a
sub-collection that exceeds them is refused with a 422 that names the
variable.
What Doclift keeps between two documents
So as not to download the same image again for every document, Doclift can keep the prepared image and serve it again to the following documents of your organization. It is never shared with another organization. What this changes for you:
- the image is only kept from the second time the same address is requested: a single-use address (a signed URL) is therefore never kept;
- the duration follows the cache headers of your server.
Cache-Control: no-storeorprivate: the image is never kept.max-age: honored.no-cachetogether with anETagor aLast-Modified: Doclift asks your server again, with a conditional request, before serving the image again. With no indication, the default retention is one hour; - whatever your server says, an image is kept for 24 hours at most after its first download.
An image that you modify under the same address can therefore keep being
served, in the old version, for up to 24 hours depending on your cache
headers. To be certain to print the new one, change the address (for example
?v=2), or have your server answer Cache-Control: no-store.
When an image is refused
An image that is supplied but unusable makes the generation fail, with a
message that names the variable: logo, or projets[2].icone for a column,
and projets[1].lignes[4].photo for a sub-collection. The messages are not
fixed to the character: do not compare them, read the case in the table
below.
An address refused by the format checks answers 422 before any
generation (see
Workflow templates). An
image that fails at download or at preparation makes the generation fail:
the result is read in generation_status and generation_error of the
generation (through GET /api/v1/document_requests/:id or in the webhook, see
Webhooks).
| Case | What it means | What to do |
|---|---|---|
| Address refused | A value that is not a usable https:// address (see above). | Fix the value sent. |
| Image not found or unreadable | The address does not answer, does not return a PNG, JPEG or WebP image, or returns a file that cannot be read as an image. | Fix the address or the file; if the host was briefly unavailable, replay. |
| Image too heavy | Too many pixels, or too heavy to decode (limits.image_variables). | Supply a smaller image. |
| Too many images, or document too heavy | The number of distinct images (max_images), the pixels or the bytes of a document, or the budget of a band, are exceeded. | Send fewer images, or lighter ones, or in smaller frames. |
| Download too long | Downloading the images of the document took too long (download_seconds). | Retry, or host the images on a faster server. |
| Too many downloads per minute | Your organization requested too many image downloads in the last minute (fetches_per_minute in sandbox). | Retry a little later. |
A third case to retry is not the caller's fault: the server is briefly saturated and has no room to prepare the images before the deadline. This case is not rendered like the others: the error may not name the variable. Retry a little later.
An asynchronous request hit by "too many downloads per minute" or by a saturated server is put back in the queue automatically, a limited number of times, before failing. A generation that fails delivers no document.
Examples
With the REST API
Read the payload contract of the published template (see Payload contract for the integrator endpoint), then send the request:
curl https://app.doclift.io/api/v1/document_requests \
--request POST \
--header "X-Api-Key: <your-api-key>" \
--header "Content-Type: application/json" \
--data '{
"document_request": {
"type": "asynchrone",
"tag": "Statement#42",
"document_generations": [
{
"template_id": 100050,
"variables": {
"logo": "https://example.com/logo.png",
"projets": [
{
"nom": "Rhone Sud",
"icone": "https://example.com/rhone-sud.png",
"lignes": [{ "date": "2026-01-02", "photo": "" }]
}
]
}
}
]
}
}'
With a refused address, the request is rejected before any generation. The
message follows Accept-Language (French by default); with
Accept-Language: en:
{
"error": "The following image variables do not carry an acceptable value: logo (the URL must start with https://), projets[0].icone (the URL must not carry a user name or a password)."
}
With a valid address that does not answer (here a 404), the generation
fails. In synchronous mode, the response is a 200 OK: the failure is
read in the generation (generation_status: "error", generation_error) and
in status and event, not in the HTTP code. The message follows
Accept-Language, French by default; here with Accept-Language: en:
{
"id": 100005,
"tag": "Statement#43",
"type": "synchrone",
"timestamp": "2026-11-26T18:10:12+01:00",
"documents_generations": [
{
"id": 100231,
"tag": "",
"generated_at": null,
"created_at": "2026-11-26T18:10:05+01:00",
"generation_status": "error",
"file": {},
"generation_error": "The image variable \"logo\" could not be used: The image could not be downloaded from this address."
}
],
"status": "error",
"error": null,
"event": "document_request.failed"
}
An address that answers but does not return an image (an HTML page, for
example) gives the same 200 and generation_status: "error", with the
message "The file at this address is not an accepted image.". In
asynchronous mode, the request answers status: "in_progress"; the
failure is then read in generation_error of
GET /api/v1/document_requests/:id (below) and in the
webhook:
{
"generation_status": "error",
"generation_error": "The image variable \"logo\" could not be used: The image could not be downloaded from this address."
}
With the MCP server
The MCP server carries the same rules. Read workflow_capabilities, then
declare the variable with variable_create (field_type: "image"), cite its
token with section_create, and check with workflow_validate and
workflow_selfcheck. For a test render, workflow_render really downloads
an https:// address; an unusable address answers an error that names the
variable (connector response, in English):
{
"document_request_id": 100231,
"status": "error",
"url": null,
"error": "The image variable \"logo\" could not be used: The image could not be downloaded from this address."
}
To import a fixed image and cite it, see the image tools of the MCP server.
Next
Variables and data
Create variables, including image columns, and import fixed images.
Sections and theme
The image tokens, the shapes, the row loops and the variable links.
Pitfalls
External images removed from the PDF and tokens that print nothing.