Skip to main content

Overview

A valid CFDI 4.0 is composed of several sections with clear responsibilities. Here is the structure from top to bottom.

1. Receipt header

Contains the global attributes of the CFDI:

2. Issuer

The issuer is the taxpayer that issues the receipt. Its data comes from the CSD configured in Facturama — the API inserts it automatically; you don’t need to specify it if you use API Web.

3. Receiver

In addition to Rfc, Name, and FiscalRegime, two additional required fields must be provided for the receiver: CfdiUse and TaxZipCode.

4. Line items (Items)

The list of goods or services being billed:

5. Taxes

Taxes are declared per line item and added to the receipt total:

6. Original String and Digital Seal

Before sending it to the PAC, the XML goes through a cryptographic process:
  1. Original String: ordered concatenation of the CFDI fields in plain-text format (defined by the SAT in its XSLT)
  2. SHA-256 hash: cryptographic digest of the original string
  3. Digital Seal: the hash signed with the private key of the issuer’s CSD (RSA)
This guarantees that no one can alter the CFDI content without invalidating the seal.

7. Fiscal Digital Stamp

Once the PAC validates the XML, it adds the Fiscal Digital Stamp as a complement:
The UUID is the most important value for invoice tracking. Always store it alongside the invoice. With it you can verify the CFDI on the SAT portal or initiate a cancellation.

Printed representation (PDF)

The PDF is the visual representation of the XML, not the fiscal document itself. It must include the QR code with the CFDI data so the receiver can verify it. Facturama generates the PDF automatically when you create a CFDI. You can download it with:
format: Format of the file to retrieve (pdf|html|xml). type: CFDI type. For API Web, use issued for income, expense, and complement invoices, and payroll for payroll receipts. id: Identifier of the document to cancel. You’ll find it in the “Id” field in the invoice issuance response, or when querying issued invoices.