---
title: "Replace an invoice"
description: "Invoices API"
---

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

# Replace an invoice

{/* Generated by apps/docs/scripts/generate.ts from contracts/api/openapi.yaml. Do not edit. */}
<div class="cvo-op">
<div class="cvo-op-main">

<div class="cvo-op-header">
<div class="cvo-op-path-row">
<span class="cvo-method" data-method="post">POST</span>
<code class="cvo-op-path-code">/v1/invoices/&#123;id&#125;/replacements</code>
</div>
</div>

Files an edited version of an invoice you created, as a new version.

Send the edited canonical invoice. It is rendered, validated and filed as a new outbound invoice that points to `{id}`.

The invoice `{id}` is never changed. It stays readable, and lists show only the newest version. The query names the files of the new version as `outputs` does on a conversion (`pdf`, `peppol`, `ubl`, `cii`, `en16931-ubl`, `en16931-cii`, `factur-x`, `extended-cii`, `zugferd-extended`); a file it leaves out follows Settings.

The workspace's processing plan must include conversion and keep results durably, and the new version counts one document against its quota. A re-check of an invoice (`POST /v1/invoices/{id}/validations`) files no new document and counts nothing.

## Path parameters

## Query parameters

## Request body

`application/json`, required

## Response

A `200` answer carries these fields.

## Status codes

| Status | Meaning |
|---|---|
| `200` | The new version was filed. The body has the report, the id of the new version and the id of the version it replaces. |
| `202` | The new version was accepted and is validated in the background. `id` is the new version and `replaces` is the version it replaces. |
| `400` | The body is empty (`empty_document`) or is not a canonical invoice (`unreadable_document`). A canonical invoice whose `meta.mappingConfigVersion` names a mapping this organisation has not saved is `unknown_mapping_version`; an invoice written directly says `none`. A new version that is a business document claiming no payment, such as a pro forma (type code 325), is `not_an_invoice`. |
| `401` | No usable credential was sent (`invalid_credentials`). |
| `403` | The workspace's processing plan does not let this door file an invoice for good. No plan is in force (`workspace_plan_unavailable`), the workspace is closed (`workspace_closed`), conversion is not included (`operation_not_included`), or the plan keeps results only temporarily (`archive_not_included`). Nothing was filed. |
| `404` | No such invoice exists for this company (`unknown_invoice`). This API never returns 403 here. |
| `409` | The invoice was received, not created by you (`invoice_not_replaceable`), this version was already replaced (`invoice_already_replaced`), or it was sent (`invoice_sent`), so a change to it is a correction or a credit note that names it, made with `POST /v1/invoices/{id}/follow-ups`. The number of the new version is already on another invoice of this company (`invoice_number_used`). Nothing was filed. |
| `422` | The files the query asks for are files the validation policy does not allow (`formats_not_allowed`; the message is the policy's reason). Nothing was filed. |
| `429` | The current plan assignment has no remaining document quota (`document_quota_exceeded`). The new version counts one document, in the transaction that files it. Nothing was filed. |
| `502` | The validation engine could not run, so nothing was filed (`engine_unavailable`). |
| `503` | The new version could not be stored (`store_unavailable`), so nothing was saved. Send it again. |

</div>
<div class="cvo-op-aside">

</div>
</div>

Source: https://docs.certinvo.com/reference/api/invoices/replace-an-invoice/index.mdx
