> ## Documentation Index
> Fetch the complete documentation index at: https://creditor-documentation.debbiecollect.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate invoices

> Generate invoice PDFs in Debbie from case vouchers using HTML or Word templates

## Set up an invoice template

Create and publish a template of type `invoice` in Debbie, then send its
`templateId` together with `lineItems`. The template supports the same
mentions as a letter, HTML themes and Word (`.docx`) templates.

## Add the invoice data

The following example uses [Add case vouchers](https://creditor-documentation.debbiecollect.com/api-reference/endpoints/customers/add-case-vouchers.md):

```json theme={null}
{
  "caseVouchers": [
    {
      "voucherTypeId": "eb41e58e-fccf-419d-a771-cd5027fe6e87",
      "source": "CREDITOR",
      "currency": "DKK",
      "amount": -250000,
      "referenceId": "INV-2026-1001",
      "date": "2026-11-08T12:00:00Z",
      "dueDate": "2026-11-22T12:00:00Z",
      "templateId": "ca52ad58-6782-4c74-a652-efbbd63ff291",
      "lineItems": [
        {
          "id": "consulting",
          "name": "Consulting",
          "quantity": 2,
          "price": -100000,
          "taxRate": 25,
          "netAmount": -200000,
          "taxAmount": -50000
        }
      ]
    }
  ]
}
```

Use the existing `lineItems` format: each item has `id`, `name`, `quantity`,
`price`, `taxRate`, `netAmount` and `taxAmount`. Prices and amounts use minor
currency units. For example, `-100000` represents a DKK 1,000.00 charge.

Amounts follow the voucher's sign convention: charges are negative and discounts
are positive. Unit prices and net amounts exclude VAT; `taxRate: 25` means 25% VAT.
`quantity` and `taxAmount` may be fractional. `price` and `netAmount` are integers.

Supply the net and tax amounts from your bookkeeping system. Debbie uses these
values without recalculating them from quantity, price or tax rate. It sums VAT
before rounding it to a minor unit; half units round away from zero. Subtotal plus
rounded VAT must equal the voucher `amount`.

`referenceId` is the invoice number. A valid `date`, `dueDate`, and at least one
line are required when generating a PDF. The template must be published and
available to the tenant; creditor-specific templates must match the case's creditor.
Do not supply an uploaded `appendix` together with `templateId`.

Generation completes before a successful response. The PDF is saved as the created
voucher's `appendix` (`fileId`, `fileName`, `contentType`). This endpoint returns
case and voucher identifiers; retrieve the vouchers to access the PDF. No email
or letter is sent automatically. A rendering or validation error fails the request.

The invoice PDF is generated once when the voucher is created. Later changes to
the due date, line items, other voucher fields or custom properties do not change
or regenerate the saved PDF.

## Invoice mentions

All letter mentions are available, including the existing currency mention
`{{currency}}`. These additional fields refer to the invoice voucher:

| Mention | Value |
| - | - |
| `{{caseVoucher.referenceId}}` | Invoice number |
| `{{caseVoucher.date}}` | Invoice date in the recipient's language and tenant timezone |
| `{{caseVoucher.dueDate}}` | Due date |
| `{{{caseVoucher.lineItemsTable}}}` | Escaped, formatted invoice line table |
| `{{caseVoucher.subtotal}}` | Subtotal excluding VAT |
| `{{caseVoucher.vatAmount}}` | VAT calculated from the invoice lines |
| `{{caseVoucher.total}}` | Total including VAT |
| `{{caseVoucher.properties.myHandle}}` | A custom property on this invoice voucher; dates use `YYYY-MM-DD` and files use their names |

The HTML theme can loop over `caseVoucher.lineItems`. Each item has `id`, `name`,
`quantity`, `price`, `taxRate`, `netAmount`, `taxAmount` and `total`; monetary fields, quantities and VAT percentages
are formatted for display, with charges shown as positive amounts. In Word, use a row loop
`{#caseVoucher.lineItems}` … `{/caseVoucher.lineItems}` with `{name}`,
`{quantity}`, `{price}`, `{taxRate}`, `{netAmount}` and `{taxAmount}`. Ordinary Word
fields use single braces, for example `{caseVoucher.referenceId}`. You can also insert
the generated table with the HTML tag `{~~caseVoucher.lineItemsTable}`.

The template editor preview always uses demo invoice lines, dates and invoice number,
combined with the selected test case for ordinary letter mentions. Actual PDFs use
the specific case voucher's values.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.