> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chromiumly.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates (hosted API)

> Generate invoice PDFs from structured data with the hosted Templates API.

`Templates` is a hosted Chromiumly feature. It is not available on self-hosted Gotenberg endpoints.

To use templates, configure `apiKey` (or `CHROMIUMLY_API_KEY`). When only `apiKey` is set, Chromiumly uses `https://api.chromiumly.dev`.

## Supported template types

* `invoice_freelancer`
* `invoice_saas`
* `invoice_classic`
* `invoice_minimal`
* `invoice_modern`

## Basic usage

```typescript theme={null}
import { Chromiumly, Templates } from "chromiumly";

Chromiumly.configure({
  apiKey: process.env.CHROMIUMLY_API_KEY!,
});

const templates = new Templates();
const buffer = await templates.generate({
  type: "invoice_saas",
  data: {
    invoiceNumber: "INV-319",
    createdDate: "2026-03-19",
    dueDate: "2026-04-02",
    sender: {
      name: "Acme Cloud LLC",
      addressLine1: "450 Madison Ave",
      addressLine2: "New York, NY 10022",
    },
    receiver: {
      name: "Northwind Health Inc.",
      addressLine1: "221 Harbor Blvd",
      addressLine2: "San Diego, CA 92101",
    },
    items: [
      {
        description: "Platform Subscription",
        qty: 1,
        unitPrice: "1500.00",
        amount: "1500.00",
      },
    ],
    currency: "USD",
    subTotal: "1500.00",
    taxRate: 8.25,
    taxAmount: "123.75",
    total: "1623.75",
    footerNote: "Payment due in 14 days.",
  },
});
```

## Runtime validation

Pass `{ validate: true }` as the second argument to validate the payload shape before the request:

```typescript theme={null}
const buffer = await templates.generate(request, { validate: true });
```

If `apiKey` is missing, `Templates.generate()` throws.
