---
title: "Check a received invoice"
description: "Learn how to validate received XML or PDF invoices and read the report for each one."
---

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

# Check a received invoice

You can send one received invoice or many in one request, and get a verdict and a report for each. This
guide covers UBL XML, CII XML, and hybrid PDFs (ZUGFeRD or Factur-X). It shows the request, how to follow
progress, and what each refusal means.

## Before you begin

- You need an API key.
- Each file must be a finished invoice. Canonical JSON (Certinvo's own JSON model of an invoice) and
  customer exports go to conversions instead. See [Create an invoice and its PDF](/how-to/invoices/create-an-invoice-and-its-pdf)
  and [Convert a file through a mapping](/how-to/customer-files/send-a-file-through-a-mapping).

## Send the invoices

Base64 encode each file. Send all of them in one envelope:

```json
{
  "context": "received",
  "documents": [
{ "name": "invoice-1001.xml", "data": "<base64>" },
{ "name": "invoice-1002.pdf", "data": "<base64>" }
  ]
}
```

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

`context: received` grades each file under the received side of your
[validation policy](/how-to/invoices/change-the-validation-policy). The answer is HTTP 202 with one
operation id and one item for each document you sent.

These are fixed when the operation is accepted:

- **The policy version.** Your current validation policy version is read once and applies to every item.
  `policyVersion` in the envelope may name only that version. To see what an older version says about an
  invoice already stored, re-check it with `POST /v1/invoices/<id>/validations?policyVersion=<n>`.
- **The company facts**, when you send `companyFacts`: your company's facts for these invoices, in the shape
  `PUT /v1/company/facts` takes. On a received invoice your company is the buyer, so what it is and where it is
  established count, and of its `facts` only those a country's rules ask per invoice, such as why the supplies these
  invoices mark exempt from VAT are exempt (`"supply_vat_exemption": "OTHER"`). Each fact you give replaces the saved one, and it is kept for every item.
- **The buyer's type**, when you send `buyerType`: on a received invoice the buyer is your company, so it says what
  your company is. When a fact the rules read is missing, the
  invoice is still validated and stored, on the validator's verdict.
- **The plan.** Your workspace's processing plan decides whether validation is included, how many documents
  and decoded bytes one operation may carry, and whether results are kept.

## Follow progress

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

- `pending` reaches zero when every item is settled.
- A `done` item carries its verdict: `clean`, `acceptable-with-findings` or `rejected`.
- A `failed` item has no verdict. It carries an operational error code instead.
- One failed item does not change the others.

You can follow the same facts as server-sent events:

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

## Read the reports

Read a finished item's complete report:

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

A received document's item has two more routes. `/canonical` returns the invoice as Certinvo's reader
understood it, in the canonical model. `/gate-reports` returns the validator's own HTML report pages, one
per run.

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

Both answer 409 `operation_not_ready` while the item is pending or when it failed. `/canonical` answers the
same when the reader could not build a model.

## What to expect

- Validation checks the bytes you sent, as they are. It never converts them to another syntax.
- The bytes decide which reader runs. A misleading file name or media type does not.
- `rejected` is a finished result, not an error. The request itself succeeds.
- When your settings turn the **New bank account** check on, a received invoice that pays to an account none of the
  same seller's earlier received invoices named carries a `seller-account-changed` finding. The check is off by
  default. A seller may change banks, so the finding never changes the verdict. Set to **Hold**, it also keeps the
  invoice out of DATEV and the forward until a person releases it
  ([Change the validation policy](/how-to/invoices/change-the-validation-policy)).
- With that check on, an invoice whose account could not be compared carries a `seller-account-not-compared`
  finding. This is the seller's first invoice, an invoice that states neither the seller's VAT ID nor its tax
  number, or one that states no account. This finding never holds the invoice.
- A file nothing can read becomes an item that fails with `unreadable_document`. The other files are still
  validated. The file is kept for 30 days and listed by `GET /v1/arrivals/not-accepted`, where it can be
  downloaded or dismissed.
- With `validateOnly: true` and exactly one document, the answer is HTTP 200 with that document's report. When the
  document was read, the report also carries `canonical`, the canonical invoice the reader made of it. Nothing is
  kept: no operation, no document and no quota. Bytes nothing can read are refused with 400 `unreadable_document`.
- With `validateOnly: true`, `context` may be left out. A file you made with Certinvo is then graded as issued under
  today's rules, and the report's `madeHere` says when it was made and its verdict then. Any other file is read as
  received, and graded again as issued when its seller's VAT ID is yours. The report's `checkedAs` names the side and
  why.
- With temporary retention, the reports and the canonical model are deleted after `retention.expiresAt`.
  From then on, the operation answers 404 `unknown_operation`.

## When the request is refused

Each of these refuses the whole operation. Nothing was accepted.

| Status | Code | Meaning |
|---|---|---|
| 400 | `invalid_operation` | The envelope or base64 is malformed, or it names a field the contract does not allow, such as a leftover `direction`. Canonical JSON or a customer export in `documents` is refused the same way. The message names the problem. |
| 400 | `operation_too_large` | The operation carries more documents, or more decoded bytes, than your plan allows. |
| 400 | `unknown_policy_version` | `policyVersion` names a version your company does not have. |
| 400 | `policy_version_superseded` | `policyVersion` names an older version. An operation may name only the current one. |
| 429 | `document_quota_exceeded` | Your plan's document quota has no room for every document. |

## See also

- [The check report](/reference/check-report): every field of the report.
- [Change the validation policy](/how-to/invoices/change-the-validation-policy): choose which rulebooks run.
- [API error codes](/reference/api-error-codes): every code the API answers.

Source: https://docs.certinvo.com/how-to/invoices/check-a-received-invoice/index.mdx
