Complete guide to Brazil NF-e and NFS-e electronic invoicing compliance including SEFAZ integration, DANFE document requirements, and XML validation.
Brazil pioneered electronic invoicing in Latin America with the launch of Nota Fiscal Eletronica in 2006. The NF-e system requires all businesses to generate XML-based electronic invoices for goods transactions and submit them to state tax authorities via SEFAZ portals for authorization before issuing to customers.
The NF-e model operates on a clearance basis where each invoice must receive authorization from the appropriate state SEFAZ system before being considered valid for tax purposes. The system generates a unique 44-digit access key and authorization protocol for each approved invoice which must appear on the accompanying DANFE auxiliary document.
In addition to NF-e for goods, Brazil uses NFS-e for services invoicing which varies by municipality. Both systems are mandatory for registered businesses and non-compliance results in significant penalties including fines and operational restrictions.
Used for physical goods transactions. Managed by state SEFAZ systems. Requires DANFE auxiliary document for transport. Standardized XML schema across all states. Access key format with 44 digits.
Used for services transactions. Managed by municipal systems. Over 5000 different municipal implementations. Each city has own format and validation rules. RPS batch submission model common.
The Documento Auxiliar da Nota Fiscal Eletronica is a printed or PDF representation of the XML invoice that accompanies goods during transport. The DANFE is not the invoice itself but serves as auxiliary documentation referencing the authorized XML.
Every DANFE must display the 44-digit access key and a barcode encoding this key for validation purposes. Tax authorities and transporters scan the barcode to verify the invoice authorization status in real-time via SEFAZ systems.
The DANFE must include essential invoice data including issuer and recipient details, product descriptions, tax calculations, and the authorization protocol number received from SEFAZ. Layout follows standardized format defined by federal regulations.
Each Brazilian state operates its own SEFAZ system for NF-e authorization. Businesses must integrate with the SEFAZ web services using digital certificates issued by authorized certification authorities. The process requires mutual TLS authentication with valid certificates.
Invoice XML must conform to the national schema version currently in use. The issuer submits the XML to their state SEFAZ which validates the structure, calculations, certificate, and issuer credentials. If approved, SEFAZ returns an authorization protocol and stores the invoice in its database.
Authorization typically completes within seconds but can take longer during peak periods or system maintenance. Rejected invoices must be corrected and resubmitted. Once authorized, the invoice cannot be modified and must be cancelled via specific cancellation procedures if needed.
The 44-digit access key uniquely identifies each NF-e and is generated by the issuer before submission. The key encodes the state code, issue date, issuer CNPJ, model, series, number, and a verification digit calculated via modulo 11 algorithm.
Recipients and tax authorities use the access key to query invoice status and retrieve the authorized XML from SEFAZ portals. This enables verification of invoice authenticity and authorization without requiring direct system integration.
The access key format ensures each invoice has a globally unique identifier within the NF-e system. Duplicate keys are rejected by SEFAZ during authorization. Proper key generation following the specification is critical for authorization success.
Digital certificates must be from authorized CAs and properly installed. Certificate expiry requires renewal and system updates. Password protection and secure storage are mandatory.
The XML must strictly follow the current schema version. Field formats, mandatory elements, and calculation rules are precisely defined. Schema validation before submission prevents authorization failures.
When SEFAZ systems are unavailable, contingency modes allow offline authorization. Invoices issued in contingency must be transmitted once systems recover. Proper contingency procedures are legally required.