FinchContext
Run with

Generate NF-e (Nota Fiscal Eletrônica, modelo 55) XML

Skill: Convert sale data into the SEFAZ NF-e modelo 55 XML and obtain authorization

Region: Brazil (Brasil) Category: E-Invoicing — Documento Fiscal Eletrônico (NF-e) Does: Takes ordinary goods-sale data and produces the NF-e (modelo 55) XML per the SEFAZ leiaute 4.00 (enviNFe), builds the 44-digit chave de acesso, and applies the authorization response (protNFe) returned by the SEFAZ autorizadora web service. Standard: NF-e leiaute 4.00 (Nota Técnica vigente) — Manual de Orientação ao Contribuinte (MOC)

The NF-e is signed (XML digital signature, certificado ICP-Brasil A1/A3) and transmitted to the SEFAZ autorizadora of the issuer's UF (or SVC/SVAN contingency). Only after a cStat 100 (Autorizado o uso) with the protNFe does the document become valid; the buyer-facing DANFE is printed from the authorized XML. Confirm the active NT/leiaute and the CSC for the QR Code before use.


When this applies


Input data required

Group Fields
Identificação (ide) UF code, natOp, mod=55, serie, nNF, dhEmi, tpNF (0 entrada / 1 saída), idDest, cMunFG, tpAmb (1 produção / 2 homologação), tpEmis, cNF, cDV
Emitente (emit) CNPJ, xNome, IE, CRT (regime tributário), endereço (enderEmit)
Destinatário (dest) CNPJ/CPF, xNome, IE / indIEDest, endereço, email
Produto (det/prod) cProd, cEAN, xProd, NCM, CFOP, uCom, qCom, vUnCom, vProd
Impostos (imposto) ICMS (CST/CSOSN, vBC, pICMS, vICMS), IPI, PIS, COFINS
Totais (total/ICMSTot) vBC, vICMS, vProd, vIPI, vPIS, vCOFINS, vNF
Transporte / Pagamento modFrete, detPag (tPag, vPag)

Chave de acesso (44 digits)

Concatenate, in order, then append cDV:

cUF(2) + AAMM(4) + CNPJemit(14) + mod(2) + serie(3) + nNF(9) + tpEmis(1) + cNF(8) = 43 digits
cDV(1)  = módulo 11 check digit over the 43 digits

The chave is carried in infNFe Id="NFe<44 digits>" and echoed in protNFe/infProt/chNFe.


Document structure (leiaute 4.00)

enviNFe (versao="4.00")
└── NFe
    ├── infNFe Id="NFe44..." versao="4.00"
    │   ├── ide      (mod 55, serie, nNF, dhEmi, tpNF, tpAmb, cNF, cDV)
    │   ├── emit     (CNPJ, xNome, IE, CRT, enderEmit)
    │   ├── dest     (CNPJ/CPF, xNome, indIEDest, enderDest)
    │   ├── det nItem="1"
    │   │   ├── prod    (cProd, NCM, CFOP, uCom, qCom, vUnCom, vProd)
    │   │   └── imposto (ICMS, IPI, PIS, COFINS)
    │   ├── total/ICMSTot
    │   ├── transp
    │   └── pag/detPag
    └── Signature   (ds:Signature, ICP-Brasil)

Authorization response wraps it as nfeProc = NFe + protNFe.


Calculation rules


Worked example (one line, authorized)

<?xml version="1.0" encoding="UTF-8"?>
<nfeProc xmlns="http://www.portalfiscal.inf.br/nfe" versao="4.00">
  <NFe>
    <infNFe Id="NFe35250612345678000195550010000001231000001236" versao="4.00">
      <ide>
        <cUF>35</cUF><cNF>00000123</cNF><natOp>Venda de mercadoria</natOp>
        <mod>55</mod><serie>1</serie><nNF>123</nNF>
        <dhEmi>2026-06-04T10:15:00-03:00</dhEmi><tpNF>1</tpNF><idDest>1</idDest>
        <cMunFG>3550308</cMunFG><tpImp>1</tpImp><tpEmis>1</tpEmis>
        <cDV>6</cDV><tpAmb>1</tpAmb><finNFe>1</finNFe><indFinal>0</indFinal><indPres>0</indPres>
      </ide>
      <emit>
        <CNPJ>12345678000195</CNPJ><xNome>Comercio Exemplo LTDA</xNome>
        <enderEmit><xLgr>Av Paulista</xLgr><nro>1000</nro><xMun>Sao Paulo</xMun><UF>SP</UF><CEP>01310100</CEP><cMun>3550308</cMun></enderEmit>
        <IE>111111111111</IE><CRT>3</CRT>
      </emit>
      <dest>
        <CNPJ>98765432000110</CNPJ><xNome>Cliente Atacado SA</xNome>
        <enderDest><xLgr>Rua Comercio</xLgr><nro>50</nro><xMun>Campinas</xMun><UF>SP</UF><CEP>13010000</CEP><cMun>3509502</cMun></enderDest>
        <indIEDest>1</indIEDest><IE>222222222222</IE>
      </dest>
      <det nItem="1">
        <prod>
          <cProd>SKU-001</cProd><cEAN>SEM GTIN</cEAN><xProd>Cadeira de escritorio</xProd>
          <NCM>94013000</NCM><CFOP>5102</CFOP><uCom>UN</uCom><qCom>10.0000</qCom>
          <vUnCom>200.0000000000</vUnCom><vProd>2000.00</vProd><cEANTrib>SEM GTIN</cEANTrib>
          <uTrib>UN</uTrib><qTrib>10.0000</qTrib><vUnTrib>200.0000000000</vUnTrib><indTot>1</indTot>
        </prod>
        <imposto>
          <ICMS><ICMS00><orig>0</orig><CST>00</CST><modBC>3</modBC><vBC>2000.00</vBC><pICMS>18.00</pICMS><vICMS>360.00</vICMS></ICMS00></ICMS>
          <IPI><cEnq>999</cEnq><IPINT><CST>53</CST></IPINT></IPI>
          <PIS><PISAliq><CST>01</CST><vBC>2000.00</vBC><pPIS>1.65</pPIS><vPIS>33.00</vPIS></PISAliq></PIS>
          <COFINS><COFINSAliq><CST>01</CST><vBC>2000.00</vBC><pCOFINS>7.60</pCOFINS><vCOFINS>152.00</vCOFINS></COFINSAliq></COFINS>
        </imposto>
      </det>
      <total><ICMSTot>
        <vBC>2000.00</vBC><vICMS>360.00</vICMS><vProd>2000.00</vProd>
        <vIPI>0.00</vIPI><vPIS>33.00</vPIS><vCOFINS>152.00</vCOFINS>
        <vDesc>0.00</vDesc><vNF>2000.00</vNF>
      </ICMSTot></total>
      <transp><modFrete>0</modFrete></transp>
      <pag><detPag><tPag>15</tPag><vPag>2000.00</vPag></detPag></pag>
    </infNFe>
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><!-- assinatura ICP-Brasil --></Signature>
  </NFe>
  <protNFe versao="4.00">
    <infProt>
      <tpAmb>1</tpAmb><verAplic>SP_NFE_PL_009</verAplic>
      <chNFe>35250612345678000195550010000001231000001236</chNFe>
      <dhRecbto>2026-06-04T10:15:07-03:00</dhRecbto>
      <nProt>135260000000123</nProt><digVal>...</digVal>
      <cStat>100</cStat><xMotivo>Autorizado o uso da NF-e</xMotivo>
    </infProt>
  </protNFe>
</nfeProc>

Validation checklist


Last updated: 2026-06-04 — confirm the active layout version, field codes, and SEFAZ/Receita Federal requirements against the current specifications before use.