# Generate a document

> POST /v1/render. Choose the template, send the data, lists and images, receive the PDF.

```http
POST /v1/render
Authorization: Bearer mzp_…
Content-Type: application/json
Idempotency-Key: order-2041
```

```json
{
  "template": "vehicle-order-form",
  "format": "pdf",
  "data": {
    "values": {
      "customer.name": "John Smith",
      "vehicle.make": "BMW",
      "order.total": "€45,000.00",
      "lines": [
        { "description": "Floor mats", "quantity": "1", "total": "€120.00" }
      ]
    },
    "photos": ["data:image/jpeg;base64,…"],
    "logo": "data:image/png;base64,…"
  }
}
```

The response is the PDF (`application/pdf`), attachments included. Keep it: Mizanpage does not store it and cannot send it to you again.

## Choose the template

- **`template`**: the Mizanpage identifier of the template, or your `external_id`.
- **`kind`** alone: Mizanpage chooses according to the workspace's rules. The named template if it can be used, otherwise the first [Choose the template](https://mizanpage.com/en/docs/modeles/automatisations.md) rule whose conditions match your `data.values` (from Team), otherwise the type's default template, otherwise the partner's standard, otherwise the only published template. Otherwise, an explicit error (`409`).

The `X-Mizanpage-Template` response header tells you which template was used. To offer your users a choice, `GET /v1/templates/available?kind=…` lists the templates that can be used.

Only the **published version** prints. A template that was never published answers `409 not_published`.

## Parameters

| Parameter | Role |
| --- | --- |
| `format` | `pdf`. Write it on every call. Without it, the default value is reserved for the editor and your key receives `403 preview_only` |
| `data.values` | The values, by catalog key. Unknown keys are ignored |
| `data.photos` | Images as data URIs, 8 MB at most each |
| `data.logo` | The logo to print in a Logo block set to "Sent by the software" |
| `strict` | `true` refuses a document with an empty required field (`422 missing_fields`) |

Without `data`, the catalog's sample values are used.

## Images

Images travel in the request as data URIs. Mizanpage never fetches a web address. The rendering engine has no network access.

## Response headers

| Header | Content |
| --- | --- |
| `X-Mizanpage-Template` | The template used |
| `X-Mizanpage-Rule` | The "Choose the template" rule that chose it, when one did |
| `X-Mizanpage-Generation` | The identifier of the counted document |
| `X-Mizanpage-Test` | `1` for a test key |
| `X-Mizanpage-Facturx` | `EN 16931` when the PDF is a Factur-X invoice |
| `Cache-Control` | `no-store` |

## Factur-X

Add the `facturx` object for the PDF to become a Factur-X invoice: a PDF/A-3 holding `factur-x.xml` with the EN 16931 profile. A template set to **Include Factur-X data** does it too without this object, by reading `data.values` (see [Factur-X invoices](https://mizanpage.com/en/docs/generer/factur-x.md)).

```json
{
  "template": "invoice",
  "format": "pdf",
  "data": { "values": { "facture.numero": "F-2026-0042" } },
  "facturx": {
    "number": "F-2026-0042",
    "issue_date": "2026-10-21",
    "due_date": "2026-11-20",
    "seller": { "name": "Garage Ostrevel SRL", "vat_id": "BE0700000101", "address": { "line1": "Chaussée de Varnoble 12", "postcode": "5000", "city": "Namur", "country": "BE" } },
    "buyer": { "name": "Transports Galvérin SA", "vat_id": "FR40303265045", "address": { "country": "FR" } },
    "lines": [
      { "name": "Annual service", "quantity": 1, "unit_price": 300, "vat_rate": 21 },
      { "name": "Labour", "quantity": 2, "unit": "HUR", "unit_price": 75, "vat_rate": 21 }
    ],
    "payment": { "iban": "BE68 5390 0754 7099", "reference": "+++202/6004/81758+++" }
  }
}
```

The VAT by rate is worked out from the lines when `vat_breakdown` is missing. The totals sent in `totals` are checked. An invoice that does not add up gets `422 facturx_invalid` before rendering and is not counted. Each problem appears in `details.problems` with its field. The [API reference](https://mizanpage.com/en/docs/api/reference.md) describes the whole object.

Factur-X is used in France and Germany. In Belgium, it does not replace Peppol.

## What is counted

Each PDF requested by a key is a counted document. Its data makes no difference. Replaying a call with the same `Idempotency-Key` within 24 hours does not count a second time: see [Avoid duplicates](https://mizanpage.com/en/docs/api/idempotence.md).

## Several documents

There is no batch route: loop over `POST /v1/render` and respect the [rate limits](https://mizanpage.com/en/docs/api/erreurs-limites.md). A workspace can generate 120 PDFs per minute.

---

Documentation Mizanpage · Developers › API
https://mizanpage.com/en/docs/api/generer/
