---
title: "Download an invoice in another format"
description: "Learn how to download a stored invoice in any format, and why a download can be refused."
---

> 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.

# Download an invoice in another format

You can download any invoice Certinvo has stored: as the file that arrived, as XML in another syntax, as a
PDF, as a DATEV file, or as its reports. This guide lists the formats and explains when a download is
refused.

## Before you begin

You need the invoice's `invoiceId`. A completed validation or conversion item returns it when its operation
keeps its results, and `GET /v1/invoices` lists it. A temporary result is never stored as an invoice, so it
has no `invoiceId`. Its files come from the operation's own item routes until it expires.

## Download a file

```bash
curl -s -o invoice.xml \
  -H "Authorization: Bearer cvo_live_sk_..." \
  "https://<api-host>/v1/invoices/<id>/download?format=ubl"
```

The response has the file's own content type and is never cached.

## The formats

| `format` | What you get |
|---|---|
| `original` | The file exactly as it arrived or was sent to us. |
| `ubl`, `cii` | XRechnung in either syntax. If it was not stored, it is written from the model on the spot. |
| `zugferd-pdf` | The ZUGFeRD PDF, also written on the spot if needed. |
| `peppol` | The Peppol BIS 3.0 file, if one was made. |
| `en16931-ubl`, `en16931-cii`, `factur-x` | The plain EN 16931 files and the Factur-X PDF, if the company's policy made them. |
| `extended-cii`, `zugferd-extended` | The ZUGFeRD EXTENDED CII and the PDF that carries it, if they were made for the invoice. |
| `datev-extf`, `datev-ledger` | A DATEV booking file or package, written now from the company's DATEV settings and never stored. |
| `canonical` | The invoice in Certinvo's model. |
| `not-carried` | What the model could not hold. |
| `omissions` | What the files we made leave out, and the formats we refused, as JSON. Invoices filed before 2026-09-17 have none. |
| `trace` | Where each value of an invoice made through a mapping came from, as JSON: a column of the customer's record, the mapping itself, or a sum. An invoice nobody mapped has none, and neither has one filed before 2026-09-29. |
| `source-file` | The customer's own file the invoice was made from, exactly as it arrived. Its sha256 is the invoice's `sourceFile.sha256`, and `sourceFile.record` says which invoice of the file this is. Never held back. |
| `gate-report` | The validator's HTML report, sent as a file to save. Under a validation policy there is one per rulebook run, the Peppol run included. Name one with `label=`. |
| `peppol-report`, `peppol-gate-report` | Older invoices only: the report and HTML report of a separate Peppol check that ran without a policy. Every check now runs under a policy, so a newer invoice has neither. |

Every download of an invoice file adds an `api:downloaded` line to the invoice's history, with the format
and who downloaded it. Reports, the model and the left-out list add nothing, because they describe the
invoice. 

To show an invoice that arrived as a PDF without recording a download, read it from
`GET /v1/invoices/{id}/preview?format=original`. That answers the PDF itself, for display.

## When a download is refused

| Status | Code | Meaning |
|---|---|---|
| 409 | `invoice_rejected` | An outgoing invoice whose newest verdict is `rejected`, or a file written on the spot that the validator rejected. An invoice already sent is decided by the check it was sent with, while that check accepted it. |
| 409 | `invoice_on_hold` | A DATEV file of a received invoice your settings hold: one the gate rejected, or one whose bank account is new or not on its PDF. It is released with a reason at `POST /v1/invoices/<id>/release`. A dismissed invoice stays held. |
| 409 | `invoice_not_validated` | An outgoing invoice that was never checked, or a file written on the spot whose check gave no verdict. |
| 409 | `invoice_changed_since_check` | The file is not the file the newest check graded, or a file written on the spot would be written from invoice data the newest check did not record. |
| 409 | `conversion_would_be_incomplete` | The requested syntax cannot hold this invoice, so writing it would lose information. |
| 409 | `datev_export_refused` | The DATEV writer refused, for example because settings are missing. The message says why. |
| 404 | `unknown_invoice` | No such invoice for this company, or no such file. |
| 400 | `invalid_query` | An unknown format, or `label` used with something other than `gate-report`. |

The first three apply only to files that *are* the invoice. Reports and the model can always be downloaded.
The original file of a received invoice is never held back; only its DATEV files wait while it is on hold. A file Certinvo writes from a received invoice
is Certinvo's own file, so that exemption does not cover it. When one of the first three refuses an XML
file, its text stays readable at `/preview`.

### How a file's verdict is found

A verdict belongs to one file, not to the invoice the file came from. Certinvo reads it from the report
already filed with the invoice. When that report graded no such file, the validator grades the file just
written, and its answer decides. That run adds a few seconds to the download.

- **A file written on the spot** is one nobody sent and nobody stored. It has its own verdict. One component
  writes it, reads that verdict and decides, so every route that hands out a file answers the same way.
  - For an invoice you created from the model, the validator graded both syntaxes when it was filed. Each
    leaves on its own answer, because the same rule can be fatal in one Schematron and a warning in the
    other. The XML written now must also hash to the bytes that were graded, or the download answers
    `invoice_changed_since_check`.
  - For an invoice that arrived as XML or a PDF, only the arrived file was graded. The other syntax and the
    PDF, written from its model, are graded when you ask for them, under your policy's rules for received
    invoices. A file the validator rejects answers `invoice_rejected`.
- **A stored file** must still hash to the sha256 its check recorded. If not, the download answers
  `invoice_changed_since_check`. Invoices filed before these hashes were recorded have none, and behave as
  they always did.
- **A PDF** is checked by the XML inside it. Two runs of the PDF writer never give the same bytes, because the
  clock and the file id change. A PDF leaves only while its XML is the XML the newest check graded. A PDF
  written on the spot is held to the XML written beside it.

A new check grades the stored files and records their hashes. So it clears `invoice_changed_since_check`
only when the stored file is still accepted. After a change to the writer, a new check grades what today's
writer makes. A corrected and rechecked invoice is released by its newest verdict. An invoice already sent keeps
the verdict it was sent with for your downloads: a later check under a newer policy is information only.

One case follows. A company that stores the PDF but not its CII gets the PDF refused after a writer change and
a new check. The new check grades a CII from today's writer, which is not the XML inside the stored PDF.
Filing the invoice again fixes it.

### What a file written on the spot leaves out

Every file Certinvo writes is read back and compared with the invoice. For a file written on the spot, the
`Certinvo-Left-Out` response header lists what it does not hold, as omission codes separated by commas.
`/preview` returns the sentences behind those codes, under `omissions`. A stored file has neither: its list
was written when the invoice was filed, and `format=omissions` returns it.

## See where each value came from

For an invoice made through a mapping, `GET /v1/invoices/{id}/trace` lists every value with its source:
read from the customer's file, set in the mapping, or worked out. A value read from a CSV or Excel file also
names the row and column the file shows (`place`). An invoice made through no mapping answers 404 `no_trace`.

## Download everything for an auditor

`GET /v1/invoices/{id}/evidence` returns one ZIP. It holds every stored file of the invoice, the customer's
file it was made from, and its history:

```bash
curl -o evidence.zip -H "Authorization: Bearer cvo_live_sk_..." \
  "https://<api-host>/v1/invoices/<id>/evidence"
```

- `manifest.json` names each file with its sha256, so an auditor can check every file without asking us.
- A file the download would refuse is not in the ZIP. The manifest lists it under `withheld`, with the
  same code and reason.
- The ZIP adds a download line to the history when it holds an invoice file.

## Read a rejected invoice's XML

To read XML that may not be downloaded, use the preview route. It returns the text inside JSON, with
whether the file is released:

```bash
curl -s -H "Authorization: Bearer cvo_live_sk_..." \
  "https://<api-host>/v1/invoices/<id>/preview?format=ubl"
```

Preview accepts `original`, `ubl`, `cii`, `peppol`, `en16931-ubl` and `en16931-cii`. It never returns a PDF.

`released` is about the file you are reading. For a file written on the spot, it is that file's own
answer, not the invoice's.

## In the console

Open the invoice and use the download buttons. The console fetches the file first. If the API refuses it,
the console says why in its own language, chosen by the refusal's code, and saves nothing. It saves the file under your
[file name pattern](/how-to/invoices/design-your-invoice#name-your-invoice-files), the invoice number when you set
none. The raw XML tabs use the preview route, so they work for
rejected invoices too.

## See also

- [Create an invoice and its PDF](/how-to/invoices/create-an-invoice-and-its-pdf): files from a conversion operation.
- [Send an invoice by email](/how-to/invoices/send-an-invoice-by-email): hand out a file by email, on the newest check.
- [API error codes](/reference/api-error-codes): every code the API answers.

Source: https://docs.certinvo.com/how-to/invoices/download-an-invoice-in-another-format/index.mdx
