Skip to content

Voiding and correcting

The two irreversible actions: each needs the token of its own preview.

Both are irreversible, so both are done in two calls: a PREVIEW that says what would happen and returns a short-lived preview_token, and the action, which the server refuses without that token. Show the preview to a person before acting.

Voiding an accepted invoice

  1. POST /v1/invoices/{id}/void/preview (permission invoices:void): what would be sent to SUNAT, the last day it can still be voided, and the preview_token.

  2. POST /v1/invoices/{id}/void (permission invoices:void; Idempotency-Key required) with reason and that preview_token. It answers 202: the invoice stays accepted until SUNAT confirms, and only then becomes voided.

  3. GET /v1/invoices/{id}/void (permission invoices:read): the state of the void, with whether it is final. The events invoice.voided, invoice.void_rejected and invoice.void_failed say how it ended.

It can refuse with: invoice_not_voidable, void_not_available, already_voided, void_in_progress, invoice_externally_reversed, invoice_held, void_window_expired, test_scenario_not_allowed, test_scenario_unknown, preview_token_required, preview_token_invalid.

Past its window an invoice cannot be voided through SUNAT. If it was reversed directly at the provider, because the window passed or because someone did it by hand in the provider’s portal, POST /v1/invoices/{id}/mark_externally_reversed (permission invoices:void; Idempotency-Key required) records that (a note, not a fiscal state). Within the window, the normal path is to void it here with POST /v1/invoices/{id}/void.

Why a void did not happen Meaning What to do
fiscal_rejected SUNAT rejected the void. The invoice is still accepted and in force. Read sunat on the void for SUNAT’s code and text. A new void can be requested once the cause is fixed.
void_window_expired The window to void the invoice passed before the void could be sent (7 days from its issue date). If it was reversed by hand at the provider, record it with POST /v1/invoices/{id}/mark_externally_reversed.
test_scenario_expired A test void waited 24 hours for a manual resolution and was closed. The invoice is still accepted. Nothing: it was a test. Request another void and resolve it by hand.
held_closed_by_staff The provider kept giving an answer about the void that the service could not interpret, so the void was held, and a person of the staff of the service closed it as failed after asking the provider for it. The invoice is still accepted. The event invoice.void_failed carries, in close, the reason the staff wrote. If the invoice must still be voided, request a new void (preview it again) while its window lasts.

Correcting an invoice that ended failed or rejected

  1. GET /v1/invoices/{id}/correction (permission invoices:correct): what would be issued now, in the SAME invoice (its number or the next one, and why), and the preview_token.

  2. POST /v1/invoices/{id}/correction (permission invoices:correct; Idempotency-Key required) with the preview_token and what changes. The same invoice goes back to processing; its previous attempt stays in its history.

It can refuse with: invoice_not_correctable, void_in_progress, invoice_held, invoice_type_not_allowed_for_regime, test_scenario_not_allowed, test_scenario_unknown, preview_token_required, preview_token_invalid, correction_proposal_changed, issuer_not_configured.

A token that expired, belongs to another invoice or no longer matches what would be done is refused (preview_token_invalid): ask for the preview again.

Type to search…

↑↓ navigate↵ selectEsc close