The problem with duplicates
When your system issues an invoice and the connection drops before receiving the response, should you retry? If you do so without precautions, you could generate two identical invoices registered with the SAT. Idempotency is the property that guarantees that sending the same request more than once produces the same result: a single invoice, not several.The technical foundation: original string and seal
Original String
The SAT defines a concatenation format (via an XSLT) that converts all CFDI fields into a single plain-text string. That string is the Original String. It includes, among other fields:- Version
- Date
- Seal
- PaymentForm
- CertificateNumber
- Certificate
- Subtotal
- Currency
- Total
- Receipt Type
- Export
- Payment Method
- PlaceOfIssue
- Issuer data
- Receiver data
- Line items and their details (description, quantity, unit value, amount, etc.)
- Taxes (transferred and withheld).
Issuer’s Digital Seal
The Original String is processed with SHA-256 and the result is signed with the issuer’s CSD private key using RSA:PAC validation
Before certifying the CFDI, the PAC verifies:- The XML structure is valid (SAT XSD schemas)
- The DigitalSeal corresponds to the issuer’s CSD
- The CFDI was not previously stamped (uniqueness)
The UUID as a unique identifier
The PAC generates a UUID (Folio Fiscal) when stamping. This UUID is unique nationwide and is registered with the SAT:How idempotency works in API Web
The Facturama API Web (a single issuer RFC) has three fields that, if not specified, are automatically generated on every call:
If you omit these fields and make two calls with the same JSON, Facturama generates two different CFDIs because
Date and Folio change. This breaks idempotency.
How to implement idempotency in API Web
Explicitly specify the three fields before sending:Folio, Date, and for Carta Porte IdCCP
Date and Folio fixed, the resulting XML is identical on every retry. The PAC will detect the duplicate and reject the second attempt, and the API will show the invoice that had already been stamped with the same data.
You can use the
Folio as an idempotency key in your database. If a CFDI with that folio already exists, do not send it again.The IdCCP field
For CFDIs with the Carta Porte complement, there is an additional fieldIdCCP that identifies the carta porte:
When to use idempotency
Apply the idempotency strategy when the error is recoverable by retrying:Recommended flow
type = issedLite