ADocumentation Index
Fetch the complete documentation index at: https://mintlify.com/josemmo/Verifactu-PHP/llms.txt
Use this file to discover all available pages before exploring further.
CancellationRecord (registro de anulación) is used to annul a registration record that was previously submitted to the AEAT. It references the original invoice by its identifier and must be chained to the previous record in your SIF’s billing sequence, just like any other record.
Create the InvoiceIdentifier for the invoice to cancel
Provide the
InvoiceIdentifier that matches the original registration record exactly — the same issuer NIF, invoice number, and issue date.Create the CancellationRecord and assign the invoice ID
Instantiate a
CancellationRecord and assign the invoice identifier from the previous step.Chain to the previous record
Unlike
RegistrationRecord (where the very first record can have null predecessors), all CancellationRecord instances require a previousInvoiceId and previousHash. Both fields are mandatory — validation will fail if either is null.Calculate the hash
Record the generation timestamp and compute the SHA-256 hash. For cancellation records the hash payload uses the cancellation-specific field names (
IDEmisorFacturaAnulada, NumSerieFacturaAnulada, FechaExpedicionFacturaAnulada), but calculateHash() handles this automatically.Complete working example
The withoutPriorRecord flag
The boolean property $withoutPriorRecord (default: false) is used when you need to cancel a record that does not exist in the AEAT system or in the SIF itself — for example, when annulling a record that was generated locally but never reached AEAT, or that was removed from the SIF’s internal store.
true only when the AEAT (or your own SIF) has no knowledge of the original registration record. In the normal cancellation flow the flag should remain false.
The isPriorRejection flag
If a cancellation record was previously submitted and rejected by AEAT, you can resubmit it with the isPriorRejection flag set to true. This signals to AEAT that this is a re-submission of a record that was rejected in the immediately preceding batch.
RegistrationRecord, isPriorRejection on CancellationRecord is a plain bool (no null variant) and defaults to false.