---
title: "Create an invoice and its PDF"
description: "Learn how to turn canonical invoice JSON into validated invoice files and download them."
---

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

# Create an invoice and its PDF

You can turn one invoice or hundreds, written in Certinvo's canonical JSON, into invoice files ready to send.
Every file is validated before it is released. This guide shows the request, how to choose the files, and
how to download them.

If you have a customer export, such as a CSV file, see
[Convert a file through a mapping](/how-to/customer-files/send-a-file-through-a-mapping) instead.

A pro forma (type code 325) claims no payment and is made as a PDF only. Send it to `POST /v1/business-documents`,
which answers the PDF. A conversion refuses it with `not_an_invoice`.

A credit note, such as type code 381, claims no payment too. It is an invoice all the same, so it is converted as this guide
shows and filed as an e-invoice. Every total counts it minus, and it never gets a payment reminder.

## Send canonical invoices

```json
{
  "customer": "stadt-beispiel",
  "outputs": { "pdf": true },
  "input": {
"type": "canonical-invoices",
"items": [
  { "schemaVersion": "<version>", "invoiceNumber": "RE-1001", "...": "complete canonical invoice" }
]
  }
}
```

Each item must be a complete invoice that follows the canonical invoice schema. The object above is
shortened to show the envelope. It is not invoice data.

`customer` is optional. It names one of this company's customers (`/v1/customers`) as the invoices' buyer, so the
check reads that buyer's type, where it is established and its facts, and the report covers what its country's rules ask
of it, such as a public buyer in Germany's Leitweg-ID in the buyer reference. The API looks up and freezes the entry when it accepts the operation. Leave it
out when no saved customer applies.

`companyFacts` is optional. It holds the company facts for these invoices, in the shape `PUT /v1/company/facts`
takes: what the company is, where it is established, and in `facts` a country's facts named
as its rules name them, such as `"supply_vat_exemption": "USTG_19_1"`, why the supplies these invoices mark exempt
from VAT (category E) are exempt. `GET /v1/jurisdictions` lists each country's facts and their values. Each fact you give replaces the saved one for these invoices; a fact you leave out keeps
the saved one. Software that invoices for several companies can send them here, so nobody types them in Settings.
The API freezes them with every item.

`buyerType` is optional: `business`, `consumer` or `public`. It says who the buyer of these invoices is, and wins
over the named buyer's type. The company facts hold no buyer type: a `companyFacts` that sends one is refused. Without
either, a buyer the invoice addresses by a Leitweg-ID is
assumed to be a public body, unless its address is in another country than Germany, and a buyer whose VAT ID the invoice states a business. The rule files assume each company fact you did
not save. An invoice follows the
establishment its seller VAT ID names, and one from an establishment in another country is established there. Each invoice is then made as an e-invoice in its seller country's format: a German
seller's as your settings say, else by its buyer (Factur-X for a business or a consumer, XRechnung for a public
buyer), any other seller's as Factur-X. When a fact the rules read is missing and no
rule file assumes it, the invoice is still made and validated. Its files leave on the validator's verdict. The
report's `recommendations` name the formats picked, any field to add and where to read the rules behind them. They are
not part of the validation.

```bash
curl -s -X POST "https://api.certinvo.com/v1/conversions" \
  -H "Authorization: Bearer cvo_live_sk_..." \
  -H "Content-Type: application/json" \
  --data-binary @conversion.json
```

The answer is HTTP 202. One invoice and hundreds use the same route and the same envelope. A conversion
always uses the issued side of your [validation policy](/how-to/invoices/change-the-validation-policy).

## Choose the files

`outputs` is optional. It can name each file an invoice can be made in, for every item of the operation:

| Key | File |
|---|---|
| `ubl` | The XRechnung UBL file |
| `cii` | The XRechnung CII file |
| `pdf` | The ZUGFeRD PDF |
| `peppol` | The Peppol BIS 3.0 file |
| `en16931-ubl` | The plain EN 16931 UBL file |
| `en16931-cii` | The plain EN 16931 CII file |
| `factur-x` | The Factur-X PDF |
| `extended-cii` | The ZUGFeRD EXTENDED CII file |
| `zugferd-extended` | The ZUGFeRD EXTENDED PDF, which carries that CII file |

`true` asks for the file. `false` leaves it out, even when your settings would make it. A file `outputs` does not
name follows your settings: the `produce` part of your
[validation policy](/how-to/invoices/change-the-validation-policy). Leave `outputs` out and your settings decide
every file.

When `outputs` names a key other than `pdf` and `peppol`, the files that result must follow the
[rules a policy must follow](/how-to/invoices/change-the-validation-policy#rules-a-policy-must-follow). For example,
at least one file must be made, and `extended-cii` or `zugferd-extended` needs the `ZUGFeRD EXTENDED` rulebook
`REQUIRED` in your policy. A choice that breaks a rule is refused with 422 `formats_not_allowed`, and nothing
is accepted. The message gives the reason.

A file the named `customer` needs cannot be turned off: `false` for it is refused with 422 `customer_needs_file`,
and nothing is accepted.

A named `customer` can add files of its own. Every invoice for it gets them, whatever your settings say, and keeps
the customer's plan for sending it. `delivery` chooses another way for these invoices, or `null` for none. See [Give a customer its files and delivery](/how-to/invoices/give-a-customer-its-files-and-delivery).

An invoice can move a file up a level. When it has sub-lines, names a party only ZUGFeRD EXTENDED carries, such as
an invoicee or a payer other than the buyer, or holds another field only it carries, the Factur-X PDF is made as the
ZUGFeRD EXTENDED PDF instead, and the EN 16931 CII as the EXTENDED CII. It stays one file. This is not done when
`outputs` sets `zugferd-extended` to `false`. XRechnung files never move: they name the party or field they leave out.
When the CII cannot hold the invoice, as with sub-lines, the UBL file of the same level is made in its place. The
invoice page says which file was made and why.

Any other key, or a value that is not `true` or `false`, is refused with 400 `invalid_operation`. So is any
field of the envelope or of `input` that the contract does not allow. The message names it.

The policy version and `outputs` are frozen when the operation is accepted. A setting you save while the
items wait changes nothing for them.

In the console, the create form's **Files and delivery** panel has one tick per file. Each tick starts as your
settings say, else as the buyer's default, and a line under the ticks says why. A file the chosen customer needs is ticked and locked. When your policy does not allow the files you
ticked, the form shows the reason and files nothing.

The same panel shows the language the invoice's page prints in, with the reason under it: chosen for this invoice,
the language saved for the buyer, the language of the buyer's country, or your language in Settings. Beside it is a
second language for every label, or none. Change either for this one invoice; the preview follows. Over the API,
send `print` with `language` and `secondLanguage` (`null` for none); leave it out and each invoice's buyer decides.
The invoice keeps its language, so a later download or email prints the same page. See
[Design your invoice](/how-to/invoices/design-your-invoice#the-language-of-each-invoice).

## Validate without filing

To see what the validator says before you file, send the same request with `validateOnly: true` and exactly
one canonical invoice:

```json
{
  "validateOnly": true,
  "outputs": { "pdf": true },
  "input": { "type": "canonical-invoices", "items": [{ "...": "complete canonical invoice" }] }
}
```

The answer is HTTP 200 with the invoice's report, the same report a filed conversion gets. The invoice is
rendered and the exact bytes are validated, then nothing is kept: no operation, no invoice, no files and no
idempotency claim, and nothing counts against your plan's allowance. The plan must still include
conversions, and its size limit still holds.

`customer`, `outputs`, `policyVersion`, `companyFacts` and `buyerType` work as above. A mapped file,
or more than one invoice, is refused with 400 `invalid_operation`. A body that is not a canonical invoice is
refused with 400 `invalid_invoice` before anything is validated, and `error.detail` names each field at fault.

## Wait for the result

```bash
curl -s -H "Authorization: Bearer cvo_live_sk_..." \
  "https://api.certinvo.com/v1/conversions/<operation-id>"
```

Every file is validated as the exact bytes Certinvo produced. A file that is rejected, or that nothing
validated, is withheld. Its report stays readable:

```bash
curl -s -H "Authorization: Bearer cvo_live_sk_..." \
  "https://api.certinvo.com/v1/conversions/<operation-id>/items/0/report"
```

A `done` item lists its released files under `files`, each with its `format`, `mediaType` and size. A
withheld file is not listed. The validator's own HTML report pages, one for each file it graded, are at
`/items/0/gate-reports`. They are there for a rejected invoice too.

Certinvo also compares each PDF's page with the XML inside it. What it finds is in the report's
`documentFindings`, for example a `pdf-xml-not-compared` finding about `BT-115` when the page labels no amount as
due. Such a finding never withholds the PDF and never changes the verdict.

## Download the files

Download one released file:

```bash
curl -f -H "Authorization: Bearer cvo_live_sk_..." \
  "https://api.certinvo.com/v1/conversions/<operation-id>/items/0/download?format=zugferd-pdf" \
  -o invoice.pdf
```

Use `format=ubl`, `format=cii`, or any other format the operation lists. To download all released files
as one ZIP:

```bash
curl -f -H "Authorization: Bearer cvo_live_sk_..." \
  "https://api.certinvo.com/v1/conversions/<operation-id>/download" \
  -o invoices.zip
```

The ZIP holds released files only. Its entry names are built from the operation id, the item index and
the format. A file name you sent never becomes a path in the ZIP.

## If an item is rejected or fails

- **Rejected.** The validator refused the invoice. This is a finished result. Read the item's report,
  correct the invoice, and send a new conversion.
- **Failed with `invalid_invoice`.** The JSON is not a valid canonical invoice, so nothing reached the
  validator. `error.detail` names each field at fault by its JSON Pointer, such as `/seller/legalName`. It
  holds no value from the invoice. The item has no report and no file.
- **Failed for another reason.** The engine was down, or the input could not be read. This says nothing
  about whether the invoice complies.

## See also

- [Download an invoice in another format](/how-to/invoices/download-an-invoice-in-another-format): fetch a stored invoice's files later.
- [Start from a template](/how-to/invoices/start-from-a-template): a ready canonical JSON batch to begin with.
- [The check report](/reference/check-report): every field of the report.

Source: https://docs.certinvo.com/how-to/invoices/create-an-invoice-and-its-pdf/index.mdx
