Certinvo never changes a filed invoice. To correct one before it is sent, you file a new version that points at the old one. After it is sent, the change is a correction or a credit note of its own. This guide shows how to do that over the API and in the console, and what happens to the old version.
The old version stays exactly as it was, with its verdict. Lists and DATEV exports use the newest version.
Before you begin
- The invoice must be one Certinvo made: its direction is
out. A received invoice is what somebody else sent, so it cannot be replaced. - You need the id of the newest version. A version that was already replaced cannot be replaced again.
- The invoice must not have left yet. Once it was emailed, forwarded, put in the SFTP folder, had a file
downloaded, was reported sent, or the buyer answered it, it is locked:
lockedistrueon its record. A change to a sent invoice is a correction (384) or a credit note (381) that names it, made withPOST /v1/invoices/{id}/follow-ups. A DATEV export does not lock an invoice. - Your workspace’s processing plan must be in force, include conversion, and keep results for good. A new version is filed for good, and it counts as one document against the plan’s allowance.
Over the API
Send the complete corrected invoice, in Certinvo’s canonical model, to the replacements route of the version you are correcting:
curl -s -X POST "https://<api-host>/v1/invoices/<id>/replacements?pdf=true" \
-H "Authorization: Bearer cvo_live_sk_..." \
-H "Content-Type: application/json" \
--data-binary @corrected-invoice.json- The body is the canonical invoice itself, not an operation envelope.
- The route answers in the same request.
- The new version is checked under your current validation policy. Its
producepart selects which files are made. ubl,cii,pdf,peppol,en16931-ubl,en16931-cii,factur-x,extended-ciiandzugferd-extended, eachtrueorfalse, override that choice for one file each. They work likeoutputson a conversion:pdfis the ZUGFeRD PDF.
The answer is the new version’s validation report. It has its own id, its validationId, and
replaces, which names the old version.
| Status | Code | Meaning |
|---|---|---|
| 200 | Filed and checked. Read verdict and released. |
|
| 409 | invoice_not_replaceable |
The invoice arrived from someone else. |
| 409 | invoice_already_replaced |
This version already has a successor. Replace the newest one. |
| 409 | invoice_sent |
The invoice left, so no new version replaces it. Make a correction or a credit note with POST /v1/invoices/{id}/follow-ups. The database refuses it too, for a send that lands meanwhile. |
| 409 | invoice_number_used |
The new version’s number is already on another outgoing invoice of this company. A version of the same invoice keeps its number. Nothing was filed. |
| 400 | empty_document, unreadable_document |
The body is empty or not canonical JSON. |
| 400 | invalid_invoice |
The JSON is not a valid canonical invoice, or it writes one key twice in an object. The detail names each field at fault, or the doubled key, by its JSON Pointer. |
| 422 | formats_not_allowed |
The files the query asks for are not allowed by your validation policy. The message says why. Nothing was filed. |
| 400 | not_an_invoice |
The new version has the type code of a business document that claims no payment, such as a pro forma (325). It is made as a PDF only. Nothing was filed. |
| 400 | unknown_mapping_version |
meta.mappingConfigVersion names a mapping this company has not frozen. An invoice written directly says none. |
| 403 | workspace_plan_unavailable |
The workspace has no processing plan in force. Nothing was filed. |
| 403 | workspace_closed |
An owner closed the workspace. Nothing was filed. |
| 403 | operation_not_included |
The plan does not include conversion. Nothing was filed. |
| 403 | archive_not_included |
The plan keeps results only for a while, and a new version is filed for good. Nothing was filed. |
| 429 | document_quota_exceeded |
The plan’s document allowance is used up. The new version is counted in the transaction that files it, so nothing was filed. |
| 404 | unknown_invoice |
No such invoice for this company. |
| 502 | engine_unavailable |
The engine could not run, so nothing was filed. This says nothing about the invoice. |
| 503 | store_unavailable |
The new version could not be stored. Nothing was saved. Send it again. |
The database allows only one successor per version. If two corrections race, one wins and the other is not
filed. The losing answer has no id.
In the console
- Open the outgoing invoice in Ausgang, or open its page.
- Choose Edit. The invoice’s page stays and switches to edit mode, at
/invoices/<id>?edit=1: the values in its Data tab become fields you can type in. - Change what needs correcting, and choose Save new version. The file ticks under Files and delivery start as the invoice has its files. The new version is made in the files ticked there. The paper beside the form prints in the language the invoice was filed in, unless you choose another, so it shows what the new PDF will.
The new version’s page then opens. What the form has no field for, such as sub-lines, stays as it was. When a change would need one of those details to be recomputed or would lose one, the form says so and files nothing. A received invoice has no Edit button. A sent invoice has no Edit button either. Opened at its edit address, the page says it was sent and points at Create a follow-up on the invoice page.
What happens to the old version
- It keeps its original bytes, its check results and its history.
GET /v1/invoices/<old id>shows it withreplacedBy. The new version showsreplaces.GET /v1/invoiceslists only the newest version.- In the console, a picker above the invoice’s preview chooses which version the preview shows, newest first. The newest is marked in use. It is the one the lists show and the only one you can edit. When the preview shows another version, a line above it says so. The Versions tab lists every version newest first, as v3.0, v2.0 and so on, with when it was saved, its gross amount, its verdict and the fields it changed from the version before it, each by its official name and BT code. Choose a version there to show it in the preview; the version shown lists each change with its value before and after; a line you removed is named as removed, by its number in the earlier version. Open page opens that version’s own page. An old version’s page also says it was replaced and links the newest. An invoice nobody edited has neither the picker nor the tab.
- A DATEV period export takes the newest version. If an earlier version was already exported, the invoice counts as exported, unless you ask to include exported invoices again.
See also
- Create an invoice and its PDF: file a new invoice.
- Export a period to DATEV: how exports pick the newest version.
- API error codes: every code the API answers.