---
title: "Generate a PDF from many pages"
method: POST
path: "/batch"
tags: ["Images"]
---

# Generate a PDF from many pages

`POST /batch`

## Request

- Base URL: `https://api.dynapictures.com`
- URL: `https://api.dynapictures.com/batch`
- Auth: HTTP bearer

Renders any number of pages, from one template or from several, into one PDF returned in the response. Pages render one after another, and each uses one image credit.

## Request body

- BatchRequest
  - `templateId` string: The template for the pages. May be left out only if every page has its own.
  - `format` 'pdf': Only `pdf` is supported.
  - `metadata` string: Custom metadata stored for each page.
  - `pages` BatchPage[], required: The pages of the PDF, in order.
    - `templateId` string: The template for this page. Falls back to the top-level `templateId`.
    - `metadata` string: Custom metadata for this page.
    - `layers` LayerOverride[]: New values for the layers of this page.
      - `name` string, required: The name of the layer to customize, shown in the settings panel when the layer is selected. `canvas` is the background.
      - `text` string: The text to render in a text layer. Basic HTML is supported and sanitized.
      - `color` string: The text color. E.g. `#000000`, `rgb(0,0,0)` or `rgba(0,0,0,0.5)`.
      - `fontSize` string: Font size of a text layer, e.g. `48px`.
      - `backgroundColor` string: The background color of the layer. E.g. `#000000`, `rgb(0,0,0)` or `rgba(0,0,0,0.5)`.
      - `borderColor` string: The border color of the layer. Set `borderWidth` as well. E.g. `#000000`, `rgb(0,0,0)` or `rgba(0,0,0,0.5)`.
      - `borderWidth` string: The border width of the layer, e.g. `1px`.
      - `borderRadius` string: The border radius of the layer, e.g. `5px` or `50%`.
      - `opacity` number: Layer opacity from `0` (hidden) to `1` (as designed).
      - `imageUrl` string, uri: The image to render in an image layer.
      - `imagePosition` 'cro' | 'cov' | 'ai_face' | 'align': How the image fits its container. Empty centers it. `cro` crops to fill, `cov` scales to cover, `ai_face` detects faces and keeps them visible, and `align` uses `imageAlignH` and `imageAlignV`.
      - `imageAlignH` 'left' | 'center' | 'right' | 'full': Horizontal image alignment when `imagePosition` is `align`.
      - `imageAlignV` 'top' | 'center' | 'bottom' | 'full': Vertical image alignment when `imagePosition` is `align`.
      - `imageEffect` string: A CSS filter applied to the image, e.g. `grayscale(100%)` or `blur(4px)`.
      - `prompt` string: Prompt for an AI Image layer in "Per request" mode. Supports `[name]` tokens that refer to `referenceImages`.
      - `sourceImage` string, uri: URL of a photo for an AI Image layer to edit. Omit it for text-to-image.
      - `referenceImages` ReferenceImage[]: Named reference images for an AI Image layer.
        - `name` string, required: Short name used in the prompt as `[name]`, e.g. `logo`.
        - `url` string, uri, required: Public URL of the reference image.
      - `chartColor` string: The color of the chart. E.g. `#000000`, `rgb(0,0,0)` or `rgba(0,0,0,0.5)`.
      - `chartLabelColor` string: The color of the chart axis labels. E.g. `#000000`, `rgb(0,0,0)` or `rgba(0,0,0,0.5)`.
      - `chartDataLabels` string[]: Labels shown on the X axis.
      - `chartDataValues` number[]: The data series of the chart.
      - `value` number: Progress value for gauge and line progress bar layers, usually `0` to `100`.
      - `maxValue` number: Total number of ticks of a radial tick gauge, e.g. `24`, `60` or `100`.
      - `activeColor` string: Color of the filled ticks of a radial tick gauge.
      - `inactiveColor` string: Color of the empty ticks of a radial tick gauge.
      - `circleColor` string: Color of the background ring of a simple gauge.
      - `progressColor` string: Color of the progress arc or of the filled part of a line progress bar.
      - `textColor` string: Color of the value label inside a simple gauge.
      - `remainingColor` string: Color of the unfilled track of a line progress bar.
      - `label` string: Overrides the label text of a line progress bar.
      - `labelAlign` 'left' | 'center' | 'right': Horizontal alignment of the line progress bar label.

## Response `200`

The PDF file.

## Other responses

- `400`: The request is invalid. `message` says why.
- `401`: The API key is missing or wrong.
- `403`: The plan limit is reached, the trial has expired, or the key has no access to this resource.
- `404`: The resource does not exist, or the key has no access to it.
- `500`: The render failed. With `error: "render_incomplete"`, a layer could not be rendered: the credit is used, and retrying renders again.
- `504`: The render took longer than 120 seconds. The image may still have been generated, so check before retrying.

---

[API](https://skmtc.dev/dynapictures/apis/dynapictures-api.md) - [All operations](https://skmtc.dev/dynapictures/apis/dynapictures-api/llms.txt) - [OpenAPI document](https://skmtc.dev/dynapictures/apis/dynapictures-api/revisions/a9820777cfb3?raw)
