XSD SAT (Servicio de Administración Tributaria) · 4.0

CFDI 4.0

Mexican e-invoice (Comprobante Fiscal Digital por Internet)

The Mexican electronic invoice, with the Timbre Fiscal Digital stamp and the Pagos 2.0 payment complement.

About

Every invoice in Mexico is a CFDI: an XML file signed by the issuer and stamped (timbrado) by an authorised certification provider (PAC) before it is valid. Version 4.0 has been the only accepted version since 2023.

The Complemento element only accepts elements whose schema is known, so a stamped CFDI fails against cfdv40.xsd alone. This entry loads cfdv40.xsd together with the SAT schemas of the Timbre Fiscal Digital 1.1 and the Complemento para recepción de Pagos 2.0 through a small wrapper schema by xmlvalid.com.

Good to know

  • The schema checks structure, data types and the SAT catalogues it includes (catCFDI is 6 MB of code lists). The signature, the certificate, the RFC registry and arithmetic between amounts are checked by the PAC and SAT, not by the schema.
  • Other complements (Carta Porte, Nómina, Comercio Exterior and so on) are not included; a document that carries one is reported invalid here.
  • The example is by xmlvalid.com and uses the SAT test RFC EKU9003173C9; its seal, certificate and stamp are placeholders.

Files

7 files · 5.6 MB

The validator loads all of these with their folder structure, so includes and imports resolve as published.

Example document

factura.xml · 1.9 KB · valid against this schema

In CI and from code

The same schema by its name, cfdi-4.0, through the API.

npx @xmlvalid/cli validate "**/*.xml" --schema cfdi-4.0
- uses: xmlvalid/validate-action@v1
  with:
    files: "**/*.xml"
    schema: cfdi-4.0
    api-key: ${{ secrets.XMLVALID_API_KEY }}
curl https://xmlvalid.com/api/v1/validations \
  -H "Authorization: Bearer $XMLVALID_API_KEY" \
  -F document={{ $schema->example ?? 'document.xml' }} -F schema=cfdi-4.0

Free accounts get 100 API validations a month. On Pro, a URL monitor can check a published document against this schema every hour and email you when it breaks. More CI setups