🇧🇷 Issue NFS-e in Brazil
The NFS-e (Nota Fiscal de Serviços Eletrônica) is the electronic service invoice used in Brazil to report tax information to municipalities. Each municipality has its own rules, format, and API for issuing service notes.
Invopop’s “Notas Fiscais Eletrônicas” app provides a unified way to issue NFS-e documents across over 2000 municipalities using GOBL. You can find the full list of supported municipalities here.
This guide will walk you through the steps required first to register a supplier and then issue service notes in their name.
To issue service notes in Brazil, you will need:
There are four key processes to prepare:
These instructions apply to both the sandbox and live environments. Please note that the sandbox environment is simulated, and most responses are mocked. You’ll still need to register suppliers in the sandbox, but the company details, certificates or passwords don’t need to be valid or real.
All of the following steps must be carried out from the Invopop Console.
Create supplier post-registration workflow
Copy and paste into a new Empty Party workflow code view.
Before starting, review the workflows guide to understand the general setup process.
In Console, create a new workflow and choose Empty Party workflow as the base. Then name the workflow with a descriptive label such as “NFS-e Post-registration workflow”.
This worfkow is composed by a single step:
Registered
.Though you can customize it to suit your needs (adding a webhook, or an email notification after a supplier has been registered.)
Connect the Notas Fiscais Eletrônicas Brazil App
Enter the Configuration section, then tap Apps. Tap on the Connect button of the Notas Fiscais Eletrônicas Brazil app.
Tap the Configure button on the app, and choose the “Post-registration workflow” we created in the previous step, or leave it empty.
Tap the Save button.
Configure the supplier registration workflow
Copy and paste into a new Empty Party workflow code view.
Before starting, review the workflows guide to understand the general setup process.
In Console, create a new workflow and choose Empty Party workflow as the base. Then name the workflow with a descriptive label such as “NFS-e register supplier workflow”.
The new workflow will need to perform three steps:
processing
.Add any additional steps you may need, and save the new workflow.
Prepare Invoice Workflow
Copy and paste into a new Empty Invoice workflow code view.
Before starting, review the workflows guide to understand the general setup process.
In Console, create a new workflow and choose Empty Invoice workflow as the base. Then name the workflow with a descriptive label such as “Issue NFS-e invoice”.
The new workflow will need to perform these steps:
processing
.sent
.Finally, in the Error Handling area, add the Set State action and select Error
.
Add any additional steps you may need, and save the new workflow.
In this section, we’ll provide details on how to first persist and register a supplier, followed by issuing service notes on their behalf.
As usual, the recommended approach for running jobs is to perform two steps; first upload the document to the silo, second create a job.
Suppliers can be registered either manually via the Invopop Console or programmatically via the API. The process is essentially the same, so we’ll demonstrate the manual method for this guide.
Find the Contacts section of the sidebar and click Suppliers. Tap the + New Supplier button to be presented with a new editor. Copy and paste the following example that uses a fictitious example. This will only work in the sandbox environment; in production, you’ll need the details of an actual company:
Supplier for Sandbox
Tap Build, ensure there are no errors, and click Save.
We should now see the document. Find and click the Select Workflow button. Select the Register Supplier workflow created during setup, and click Run workflow.
The execution should be successful, and the silo entry will now be in the Processing
state. Tap the Meta tab to see the registration link:
You can access the registration link via the API by fetching the silo
entry and reading the meta
row where
the key
is set to registration-link
.
Tap the registration link, and a new browser window will open with a form to upload the supplier’s credentials. Note that this form can be shared directly with the supplier if necessary.
The details from this form are sent securely to Invopop’s local partner, PlugNotas, who will use them to authenticate in the corresponding municipality API.
The supplier must ensure that the certificate and password are valid and accepted by the municipality where they are registered.
Once the form is submitted, the supplier will be registered, and the post-registration workflow will be executed, changing the supplier’s state to registered
.
From this point on, you can send service notes on behalf of the supplier.
The following examples are of partial 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 “Issue NFS-e” workflow created during setup.
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 municipality and the actual PDF generated will be attached to the silo entry.
GOBL Invoices sent as NFS-e require the following properties to perform the correct normalization and validation steps. Invopop will try to assign these automatically, but we recommend defining them explicitly before uploading:
$region
to be set to BR
$addons
to include br-nfse-v1
B2B Service Note
In this example, we’re issuing a simple service note from a Brazilian supplier to another Brazilian customer.
Notice:
br-nfse-v1
addon; this ensures the document will be validated using the NFS-e rules built into the GOBL library,ext
) and identities have been used in multiple locations for fields whose values cannot be determined any other way,Please contact the [Invopop support team] (email:support@invopop.com) if you have any questions that are not listed here.
Do you support other types of “notas fiscais” such as NF-e or NFC-e?
At the moment, only NFS-e is supported. We are working on adding support for NF-e (for products) and NFC-e (for final consumers).
Where can I find the mapping of GOBL fields to NFS-e?
For further details on how GOBL prepares data for conversion, see the Brazil Tax Regime.