RideKit
Docs/Reference/Brazil: NFS-e Nacional for the operator's own services

Brazil: NFS-e Nacional for the operator's own services

Built: 2026-11-03. Written for operators in Brazil, their accountants, and whoever maintains the code.

Since 2026, Brazilian service invoices follow one national standard (LC 214/2025). The issuer signs a DPS and sends it to the Sefin Nacional, which returns the NFS-e with its 50-digit access key.

A ride platform invoices two things of its own:

Document To For Default service code
Platform fee each driver (by CPF) the intermediation fee the platform took that month 10.05.01
Corporate billing each company on corporate billing (by CNPJ) its employees' rides that month 16.01.01

The ride itself is the driver's service, not the platform's. The per-ride nfse engine stays available for operators set up differently.

Setting it up

  1. Providers → NFS-e Nacional:
    • certPem and keyPem: the company's ICP-Brasil A1 certificate and its private key, as PEM. Convert a .pfx with: openssl pkcs12 -in cert.pfx -clcerts -nokeys -out cert.pem and openssl pkcs12 -in cert.pfx -nocerts -nodes -out key.pem.
    • apiBase: leave it empty for produção restrita (testing). Set the production base when you are ready to go live.
  2. Markets → Brazil → Tax:
    • The seller tax id is the operator's CNPJ.
    • In the NFS-e Nacional card, turn it on and fill in:
      • the município IBGE code (São Paulo 3550308);
      • the inscrição municipal;
      • the DPS series;
      • the tax regime;
      • the ISS rate (2% to 5%).
  3. Organizations → a company → Edit: enter its CNPJ (checked by its digits).
  4. Drivers: the CPF comes from the CNH, recorded when the licence is reviewed (see docs/city-registries.md).

Running it

  • On the 1st of each month (market time), the previous month is issued automatically.
  • Tax → NFS-e Nacional shows the month's documents, issues a month by hand, re-sends one that failed, and downloads the XML.

The values come from the books:

  • The platform fee is the commission actually credited in the ledger on the driver's completed rides that month.
  • Corporate billing is the company's completed rides that month.

A month can be issued again safely. Each driver or company has one document per month, and an issued document is never sent twice.

Each document has one of these states:

State Meaning
Issued The Sefin returned the NFS-e; its access key is shown and the XML can be downloaded
Kept local No certificate is set up. The DPS was built but not sent, and it is never claimed as issued.
Blocked Something is missing (the driver's CPF, the company's CNPJ, or the operator's CNPJ or município); the reason is shown
Failed The Sefin refused it; its error code and message are shown. Fix the cause and press Send again.

How it is built

  • The DPS follows the national layout (v1.00) and is numbered from one sequence.
  • It is signed with XMLDSig:
    • enveloped signature over infDPS;
    • inclusive C14N;
    • RSA-SHA256 and SHA-256;
    • the certificate goes in KeyInfo.
  • The DPS is sent gzipped and base64-encoded in JSON to POST {apiBase}/nfse, over mutual TLS with the company certificate.
  • No XML or certificate libraries are used. The XML is written already in canonical form, and our canonical bytes were checked to match libxml2's C14N.
What Where
DPS, signature, config, money backend/src/tax/nfse-nacional.ts
Monthly run, sending, admin API (/admin/nfse) backend/src/tax/nfse-nacional.service.ts
Storage migration 171: nfse_documents, nfse_dps_numero, organizations.tax_id
Admin components/tax/NfseNacionalReport.tsx, components/markets/NfseNacionalCard.tsx, Organizations edit (CNPJ)

Check before launch. This was tested against a local stand-in of the Sefin, not the Receita's environment. Issue a few documents in produção restrita first. Confirm with your accountant:

  • the service codes (10.05.01 and 16.01.01);
  • the ISS rate and regime;
  • whether your município needs the inscrição municipal;
  • whether ISS is retained for corporate clients.
source: docs/brazil-nfse-nacional.md (ships identically in the product zip)