|
| 1 | +--- |
| 2 | +sidebar_position: 10 |
| 3 | +title: Cancellations (Cancelaciones) |
| 4 | +--- |
| 5 | + |
| 6 | +# CFDI cancellations |
| 7 | + |
| 8 | +This guide explains how invoice cancellations work in Facturapi, what each status means, and what to expect after requesting a cancellation. |
| 9 | + |
| 10 | +## Requirements and rules |
| 11 | + |
| 12 | +- You can only cancel invoices with `status: "valid"`. |
| 13 | +- If the invoice is `draft`, the cancel method deletes it. |
| 14 | +- If the invoice is already `canceled` or has a cancellation in progress (`cancellation_status: "pending"` or `"verifying"`), the method will return an error. |
| 15 | + |
| 16 | +## Cancellation motives (SAT) and substitution |
| 17 | + |
| 18 | +The SAT defines **cancellation motives**, and Facturapi exposes them via the `motive` parameter. Cancellations use the **SAT's new cancellation scheme (effective since 2022)**. |
| 19 | + |
| 20 | +- `01`: **Invoice issued with errors with relation**. Requires `substitution` with the UUID (or Facturapi ID) of the replacing invoice. |
| 21 | +- `02`: **Invoice issued with errors without relation**. |
| 22 | +- `03`: **Operation not carried out**. |
| 23 | +- `04`: **Nominative operation related to a global invoice**. |
| 24 | + |
| 25 | +The SAT expects the motive to match the use case; otherwise the cancellation may fail. |
| 26 | + |
| 27 | +Notes: |
| 28 | + |
| 29 | +- If you choose motive `01`, you must send `substitution`, and the replacement invoice must exist. |
| 30 | +- If the SAT considers your CFDI non-cancellable (by status or relationships), the request will be rejected even if the motive is valid. |
| 31 | + |
| 32 | +## Cancellation flow and statuses |
| 33 | + |
| 34 | +After calling `cancelInvoice`, you may get: |
| 35 | + |
| 36 | +- Success with `status: "canceled"` and `cancellation_status: "accepted"` (finalized). |
| 37 | +- Success with `status: "valid"` and `cancellation_status: "pending"` (requires receiver approval). |
| 38 | +- Success with `status: "valid"` and `cancellation_status: "verifying"` (SAT received the request and is validating it). |
| 39 | +- An error explaining why the cancellation could not be completed. |
| 40 | + |
| 41 | +Meaning of `cancellation_status`: |
| 42 | + |
| 43 | +| Status | Meaning | What to do | |
| 44 | +|:--|:--|:--| |
| 45 | +| `none` | No request registered by the SAT. | You can request cancellation if needed. | |
| 46 | +| `verifying` | SAT received the request and is validating it. | Wait for automatic updates or fetch the invoice. | |
| 47 | +| `pending` | Receiver approval is required. | Wait for acceptance/rejection or expiration. | |
| 48 | +| `accepted` | Cancellation was accepted. | Invoice moves to `status: "canceled"`. | |
| 49 | +| `rejected` | Cancellation was rejected. | Review the motive and retry if applicable. | |
| 50 | +| `expired` | Receiver did not respond in time. | You may retry cancellation if applicable. | |
| 51 | + |
| 52 | +## Automatic status updates |
| 53 | + |
| 54 | +Facturapi periodically checks the SAT and updates `cancellation_status`. You can: |
| 55 | + |
| 56 | +- Fetch the invoice using [Get Invoice](/api/#tag/invoice/operation/getInvoice). |
| 57 | +- Subscribe to the `invoice.cancellation_status_updated` webhook to receive changes when the status leaves `pending` or `verifying`. |
| 58 | + |
| 59 | +## Cancellation receipt and verification |
| 60 | + |
| 61 | +When the cancellation is accepted, you can download the cancellation receipt in XML or PDF from the [Cancellation receipt](/api/#tag/invoice/operation/downloadCancellationReceiptXml) endpoint. You can also validate the CFDI using `verification_url`. |
| 62 | + |
| 63 | +## Common errors |
| 64 | + |
| 65 | +- `409 Conflict`: the invoice is not `valid` or already has a cancellation in progress. |
| 66 | +- `400 Bad Request`: invalid motive or missing `substitution` when required by SAT rules. |
| 67 | +- `404 Not Found`: the folio or UUID does not exist in the SAT. |
0 commit comments