Introduction
Brazil has a variety of electronic tax documents that must be issued in different cases for various tax purposes. These include service invoices (NFS-e), product invoices (NF-e), and consumer invoices (NFC-e). Each document type is subject to variations from state to state and municipality to municipality, with each jurisdiction applying its own rules, formats, and APIs for issuing fiscal documents. Invopop’s Documentos Fiscais Eletrônicos app provides a unified way to issue fiscal documents across all Brazilian states and over 2000 municipalities using GOBL. You can find the full list of supported municipalities here. This guide will walk you through the steps required to issue electronic fiscal documents in a supplier’s name, and to cancel them if needed.Prerequisites
To issue electronic fiscal documents in Brazil, you will need:- A registered supplier: follow the DF-e supplier registration guide to connect the Documentos Fiscais Eletrônicos Brazil app and register the supplier’s certificate before issuing.
- Customer details (except for NFC-e where the customer is optional).
- Details of the goods or services provided:
- quantity,
- price,
- applicable tax rates (ISS, ICMS, PIS, COFINS, etc.), and,
- (only for services) service code (Código Item Lista Serviço) as defined by the municipality.
- To have chosen an invoice series
Setup
Prepare the invoicing workflows for the document types you want to issue and cancel.These instructions apply to both the sandbox and live environments. Please note that the sandbox environment is simulated, and most responses are mocked. The Documentos Fiscais Eletrônicos Brazil app must already be connected and configured — this is covered in the supplier registration guide.
1
Prepare NFS-e workflow
You can skip this step if you’re not interested in issuing NFS-e documents.
DF-e issue service invoice (NFS-e)
Add to my workspace →
- Workflow
- Code
2
Prepare NF-e Workflow
You can skip this step if you’re not interested in issuing NF-e documents.
DF-e issue product invoice (NF-e)
Add to my workspace →
- Workflow
- Code
3
Prepare NFC-e Workflow
You can skip this step if you’re not interested in issuing NFC-e documents.
DF-e issue consumer invoice (NFC-e)
Add to my workspace →
- Workflow
- Code
4
Prepare NFS-e Cancel Workflow
You can skip this step if you’re not interested in cancelling NFS-e documents.
DF-e cancel service invoice (NFS-e)
Add to my workspace →
- Workflow
- Code
5
Prepare NF-e Cancel Workflow
You can skip this step if you’re not interested in cancelling NF-e documents.
DF-e cancel product invoice (NF-e)
Add to my workspace →
- Workflow
- Code
6
Prepare NFC-e Cancel Workflow
You can skip this step if you’re not interested in cancelling NFC-e documents.
DF-e cancel consumer invoice (NFC-e)
Add to my workspace →
- Workflow
- Code
Running
In this section, we’ll provide details on how to issue invoices on behalf of a registered supplier, and how to cancel them. As usual, the recommended approach for running jobs is to perform two steps; first upload the document to the silo, second create a job. All operations described in the following sections can be performed manually via the Invopop Console, or programmatically via the API. The process is essentially the same in both cases, so we’ll demonstrate the manual method for this guide.Send invoices
The following examples are of example GOBL documents you can copy and paste directly into the Invopop Console or store via the API as silo entries. Then, you must run the appropriate issue workflow created during setup — “DF-e issue service invoice (NFS-e)”, “DF-e issue product invoice (NF-e)”, or “DF-e issue consumer invoice (NFC-e)” — over them.In the sandbox environment, you’ll notice that executing the workflow will always result in the same PDF and XML being attached to the silo entry. These are mock-up files returned by the sandbox environment for testing purposes.In production, the actual XML file sent to the tax authority and the actual PDF generated will be attached to the silo entry.
Example B2B service invoice (NFS-e)
Example B2B service invoice (NFS-e)
In this example, we’re issuing a simple service invoice (NFS-e) from a Brazilian supplier to another Brazilian business customer.Notice:
- we’ve added the
br-nfse-v1addon; this ensures the document will be validated using the NFS-e rules built into the GOBL library, - extensions (
ext) and identities have been used in multiple locations for fields whose values cannot be determined any other way, - ISS percentage is provided explicitly as it varies depending on the municipality and type of service,
- there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue service invoice (NFS-e)” workflow created during setup.
Example B2B service invoice with RTC (NFS-e)
Example B2B service invoice with RTC (NFS-e)
In this example, we’re issuing a simple service invoice (NFS-e) with the currently supported RTC (Tax Reform) fields.Notice the differences from the previous example:
- we’ve set the
br-nfse-operationextension, thebr-nfse-tax-statusextension and thebr-nfse-tax-classextension at item level which will be used to determine the IBS and CBS taxes as part of the tax reform.
Example B2B product invoice (NF-e)
Example B2B product invoice (NF-e)
In this example, we’re issuing an extended product invoice (NF-e) from a Brazilian supplier to another Brazilian business customer.Notice:
- we’ve added the
br-nfe-v4addon without thesimplifiedtag; this sets thebr-nfe-modelextension to55(NF-e), - the customer is required for NF-e and must include a full address; Brazilian customers must declare the
br-ibge-municipalityextension and a valid state, while foreign customers can be identified by a country-qualifiedidentity(e.g. a passport) instead of atax_id, - supplier and customer addresses must include a
country; it is auto-filled from the party’s tax ID (or first identity that declares a country) when omitted, - each line must include a
br-nfe-cfopextension to classify the fiscal operation, - item identities carry the NCM product classification code (
cProdin the NF-e XML) and the GTIN barcode (cEAN), item.refmaps to the supplier’s internal product code, anditem.unitis converted to a UNECE unit code,- line
discountsreduce the taxable base (vDesc); linechargeswith keydeliverymap to freight (vFrete) and keyinsuranceto insurance value (vSeg), line.orderprovides the line reference within the purchase order (nItemPed),- a line
notesentry with keygoodsmaps to per-item additional information (infAdProd), ordering.codesets the purchase order number (nPedincompra) andordering.contracts[0].codesets the contract number (nCont),delivery.receiversets a separate delivery address (entrega) when goods ship to a different location than the buyer’s fiscal address,- the payment instructions key is set to
credit-transfer, which causes thebr-nfe-payment-meansextension to be set automatically to18(transferência bancária), - a
generalnote maps to complementary information (infCpl) in the NF-e XML, - tax percentages are provided explicitly as they vary depending on the state and type of goods,
- there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue product invoice (NF-e)” workflow created during setup.
Example B2B product invoice for a Simples Nacional issuer (NF-e)
Example B2B product invoice for a Simples Nacional issuer (NF-e)
In this example, we’re issuing a product invoice (NF-e) from a supplier enrolled in the Simples Nacional tax regime.Notice the differences from the previous example:
- the supplier declares its regime with the
br-nfe-regimeextension set to1(Simples Nacional); use2for Simples Nacional, Excess or4for MEI — omitting it defaults to3(normal regime), - each ICMS line carries the
br-nfe-icms-csosnextension (here101, taxed with credit permission) instead of thebr-nfe-icms-cstcode that normal-regime issuers use, - PIS and COFINS are still required on every line but are not levied per item under Simples Nacional, so they use the
br-nfe-pis-cstandbr-nfe-cofins-cstextensions set to49(other operations) at a0%rate, - there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue product invoice (NF-e)” workflow created during setup.
Example NF-e for a full goods return
Example NF-e for a full goods return
In this example, we’re issuing a NF-e that fully returns the goods of a previously issued B2B product invoice — a devolução total under the pre-reform (pre-RTC) rules.Notice the differences from a standard product invoice:
- the document
typeiscredit-note; it keeps thebr-nfe-v4addon and is still issued as an NF-e, sobr-nfe-modelis derived as55, - a
precedingentry references the original NF-e and carries its SEFAZ access key (chave de acesso) as a stamp — you can copy it from thesefaz-keyentry in thestampsarray of the original invoice’s envelopehead, where it was added once the tax authority authorized the document, - because this is a full return, the
br-nfe-purposeextension is set to4(Goods Return) and thebr-nfe-operation-typeextension to0(Inbound / Entrada), since the returned goods re-enter the supplier; standard invoices set these automatically to1(normal) and1(outbound), but corrective documents must set both explicitly, - no
br-nfe-credit-note-typeextension is used: that field only applies to post-reform IBS/CBS credit notes (those setbr-nfe-purposeto5), - the line
br-nfe-cfopis a return code —2202(Devolução de venda de mercadoria adquirida ou recebida de terceiros) — mirroring the original6102sale but recorded as an inbound inter-state operation (CFOP starting with2), - the payment sets the
br-nfe-payment-meansextension to90(No payment), as a return does not involve a new payment, - there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue product invoice (NF-e)” workflow created during setup.
Example B2C consumer invoice (NFC-e)
Example B2C consumer invoice (NFC-e)
In this example, we’re issuing a simple consumer invoice (NFC-e) from a Brazilian supplier.Notice:
- we’ve added the
br-nfe-v4addon with thesimplifiedtag; this sets thebr-nfe-modelextension to65(NFC-e), - the customer is optional and in this example we’ve omitted it,
- extensions (
ext) and identities have been used in multiple locations for fields whose values cannot be determined any other way, - the payment instructions key is set to
card, which causes thebr-nfe-payment-meansextension to be set automatically to03(cartão de crédito), - tax percentages are provided explicitly as they vary depending on the state and type of goods,
- there are no totals or calculations; all these will be made automatically when uploading, and,
- make sure to process it with the “DF-e issue consumer invoice (NFC-e)” workflow created during setup.
Cancel an invoice
If you need to cancel a document that has already been sent to the tax authority, you can use the cancel workflows created during setup. Run the appropriate cancel workflow — NFS-e, NF-e, or NFC-e — over the silo entry you want to cancel. On success, the entry will be set toVoid.
NFS-e cancellations are subject to the rules of each municipality. Some require a specific cancellation code. NFC-e cancellations must be requested within the cancellation window set by the originating state.
Configuration
Both cancel actions accept optional parameters that control the cancellation request. They can be set as a default on the workflow step (via the step’s configuration page in the Console) or overridden per job by passing them as arguments when creating the job via the API.
Job arguments take precedence over the step configuration. To pass them when creating a job via the API:
FAQ
What type of Documentos Fiscais does Invopop support?
What type of Documentos Fiscais does Invopop support?
Invopop supports NF-e, NFS-e and NFC-e documents. Transport documents (MDF-e and CT-e) are not currently supported.
Where can I find the mapping of GOBL fields to DF-e documents?
Where can I find the mapping of GOBL fields to DF-e documents?
For further details on how GOBL prepares data for conversion, see:
🇧🇷 Invopop resources for Brazil
🇧🇷 Invopop resources for Brazil
Participate in our community
Ask and answer questions about invoicing in Brazil →