Documentation › NF-e issuance
NF-e issuance
Issue, validate, query, cancel and correct NF-e (modelo 55), with taxes coming from your ERP.
Every state. Issuance works in any state: Sudrel prepares your company's state in minutes, from the registration, with no action from you. Where the text mentions Bahia, it is the state of the examples and of the rules already detailed.
Issue NF-e (modelo 55) with the same conventions as NFS-e: Idempotency-Key,
referencia unique per company, Prefer: wait, errors as Problem Details,
ajustes, regras_versao, event cursor and signed webhooks. If you have
already integrated NFS-e, there is nothing new to learn.
Three modes, chosen in modo:
informado(default): taxes come ready from your ERP. In each item you send the ICMS, IPI, PIS, COFINS and IBS/CBS groups already calculated; Sudrel checks the totals against the sum of the items, validates against the official SEFAZ schema before signing, signs with the company's A1 certificate, transmits and tracks it.calcular: each item carries onlyproduto(the code registered in/v1/produtos), quantity and value; Sudrel's tax engine resolves CFOP and taxes and explains each value inajustes(rule, version and legal source). See Products and tax engine.conferir: you send the values, as in informado, plus each item'sproduto; Sudrel calculates alongside and returns the differences inajustes.
One invoice never becomes two. The access key is stored before sending. If
the SEFAZ response does not arrive (timeout, outage), the invoice stays
aguardando_confirmacao and Sudrel queries the key at SEFAZ: it only resends,
and the SAME XML, if SEFAZ says the invoice does not exist. A duplicate (204)
is not an error for you: the query resolves it.
What is required
| Field | informado mode |
calcular mode |
|---|---|---|
empresa_id |
Yes (not needed with a key restricted to one company) | Same |
referencia |
No, but send it: it is how you query and avoid duplicate invoices | Same |
natureza_operacao |
Yes | No: comes from the operations catalog |
presenca |
Yes | Yes |
destinatario.documento |
Yes | Yes |
destinatario.nome |
With CPF. With CNPJ, it comes from the Receita Federal | Same |
destinatario.endereco |
With CPF, only cep and numero. With CNPJ, it comes from the Receita Federal |
Same |
destinatario.inscricao_estadual |
Only with contribuinte: "contribuinte". Without contribuinte, Sudrel queries SEFAZ |
Same |
| Item | codigo, descricao, ncm, cfop, origem, unidade, quantidade, valor_unitario, icms, pis and cofins |
produto, quantidade and valor_unitario |
pagamentos |
At least one, with forma and valor (descricao for the outros form) |
At least one; if there is only one, valor may be omitted (it becomes the invoice value) |
totais |
No: summed from the items | No |
Depending on operacao (calcular and conferir modes; in informado, the
CFOP and finalidade you send already define the operation):
operacao |
Also requires | Taxes |
|---|---|---|
venda (default), venda_consumidor_final, bonificacao |
Nothing | Calculated |
remessa |
subtipo: conserto, demonstracao, industrializacao or outras |
In informado mode: the catalog resolves CFOP and nature, the engine does not calculate remessa (shipments) |
transferencia |
Nothing | In informado mode |
devolucao |
chave_referenciada (44 characters) and subtipo comercializacao (default) or industrializacao |
In informado mode: send the same chave_referenciada and finalidade: "devolucao", with the taxes of the original invoice. In conferir, the invoice goes out with your values, unchecked |
In informado mode, finalidade decides whether the original invoice is
required: devolucao and complementar require chave_referenciada (without
it, 422 chave_referenciada_obrigatoria); normal and ajuste accept it
without requiring it. Sudrel checks the length and check digit before sending
and puts the key where SEFAZ expects it: for a return, in each item
(det/DFeReferenciado, with item_referenciado when you provide it); for the
other purposes, on the invoice (NFref/refNFe). SEFAZ rejects both together
(rejection 1010).
Whatever is missing or wrong comes back together in a 422 validacao, each
error with the campo (JSON Pointer), the mensagem and the correcao.
Sandbox and production
sdr_test_key: issues for real in SEFAZ homologação (tpAmb 2), with the company's real certificate, no fiscal value and no charge, in any state. The recipient name goes out as SEFAZ requires in homologação.sdr_live_key: issues in SEFAZ production (tpAmb 1), with fiscal value. The request, response and webhooks are the same as in homologação.
Status
| Status | What it means |
|---|---|
transmitindo |
We are handling it: queued or sending. Do not resend. |
aguardando_confirmacao |
The invoice was sent and the SEFAZ response did not arrive. Sudrel is querying the key; no new invoice is created and you do not need to do anything. |
autorizada |
NF-e authorized. protocolo, chave_acesso, XML and DANFE available. |
rejeitada |
SEFAZ refused it. rejeicao carries the cStat, the SEFAZ message and, when known, the explanation in Portuguese. The number is still yours: fix it with POST /v1/nfe/{id}/correcao. |
denegada |
Use denied by SEFAZ (tax irregularity). The number was consumed and the invoice cannot be used. |
cancelada |
Cancelled after authorization. Protocol in cancelamento. |
descartada |
You gave up on the invoice (or Sudrel discarded a forgotten rejected one). The number is voided (inutilizado). |
contingencia_epec |
The state's SEFAZ was down and the invoice went into EPEC contingency: the event was registered in the Ambiente Nacional and the DANFE is already valid. The NF-e goes to the state when it is back (see NF-e contingency). |
Mapping to the internal status: PENDENTE and TRANSMITINDO are
transmitindo; AGUARDANDO_CONFIRMACAO, AUTORIZADA, DENEGADA, REJEITADA,
DESCARTADA and CANCELADA have the same name in lowercase; EPEC_REGISTRADO
is contingencia_epec. In NFS-e,
aguardando_confirmacao asks for your confirmation; in NF-e, it is Sudrel
confirming with SEFAZ.
What Sudrel fills in (ajustes)
regra |
What was done |
|---|---|
nfe_modo_informado |
No modo: taxes provided by you. |
nfe_serie_da_origem |
No serie: this company's API series (each channel has its own). |
nfe_destino_operacao |
Intrastate, interstate or foreign operation, from the states. |
nfe_totais_somados |
Totals you did not send, summed from the items. |
nfe_valor_total_item |
Item value: quantity times unit value. |
nfe_sem_gtin |
Product without a barcode: "SEM GTIN". |
nfe_transporte_sem_frete |
No transport: "sem frete" (no freight). |
nfe_tipo_operacao_saida |
No tipo_operacao: outbound. |
nfe_finalidade_normal |
No finalidade: normal NF-e. |
nfe_ibs_soma_uf_municipio |
Item IBS: sum of the state and municipal portions. |
nfe_totais_ibs_cbs_somados |
IBS and CBS totals you did not send, summed from the items. |
nfe_correcao_<cStat> |
Automatic correction made after a known rejection. |
nfe_destinatario_homologacao |
In the sandbox, the recipient name is the SEFAZ literal. |
nfe_autxml_escritorio |
In BA, the company's accounting firm in the autXML group (state requirement). |
nfe_autxml_sefaz_sem_escritorio |
In BA, with no linked accounting firm: the SEFAZ-BA CNPJ. |
nfe_autxml_sefaz_apos_487 |
SEFAZ refused the accounting firm (487); the invoice was rebuilt with the SEFAZ CNPJ. |
nfe_indintermed_padrao |
Intermediary indicator "no intermediary", when the presence type requires it. |
nfe_autxml_sefaz_escritorio_recusado |
SEFAZ had already refused this company's accounting firm (487): the invoice went straight out with the SEFAZ CNPJ, without a rejected attempt. |
nfe_operacao_venda |
Calcular and conferir modes, no operacao: sale. |
nfe_natureza_da_operacao |
Nature of operation from the operations catalog. |
nfe_pagamento_valor_da_nota |
Calcular mode, one payment without a value: the calculated invoice value. |
nfe_conferencia_divergencia |
Conferir mode: the value provided differs from the calculated one (acao: "divergente"). |
nfe_conferencia_fora_de_cobertura |
Conferir mode: the item was not checked because it is outside the engine's coverage. |
In calcular mode, each calculated value goes into ajustes with
acao: "calculado", the regra (for example icms_ba_ai_geral_2024,
ipi_aliquota_tipi, pis_cofins_base_sem_icms, ibs_cbs_calculadora_oficial),
the valor, the versao of the rule or table and the legal fonte.
Cancellation and correction letter
Cancellation up to 24 hours after authorization (national rule). After that
window, the response is 422 cancelamento_fora_do_prazo: the only option left
is late (extemporâneo) cancellation, requested by the taxpayer at SEFAZ. In
Bahia there is no late cancellation (RICMS/BA, art. 92): if the goods did not
move, the path is an inbound or outbound regularization NF-e within 60 days,
referencing the key of the incorrect invoice; the 422 response already says so.
The correction letter (carta de correção, up to 20 per invoice) does not
correct values, quantity, tax base, rate, data that changes the sender or
the recipient, or the issue or departure date. Sudrel does not read the text:
the response carries this warning, without blocking.
Numbering
Each channel (API, spreadsheet, dashboard) has its own series, and the number
is only reserved when the invoice is created (validation and preview never
reserve). A forgotten rejected invoice becomes descartada on its own before
the legal deadline for voiding (inutilização), with the
NFE_DESCARTE_PROXIMO webhook a few days before. Sudrel voids the numbers it
lost itself; GET /v1/nfe/inutilizacoes shows what was voided and why.
Endpoints in this section, with in-page testing
- GET/v1/nfe · Lists NF-e
- POST/v1/nfe · Issues an NF-e (modelo 55)
- POST/v1/nfe/previas · Validates and shows the XML without issuing
- GET/v1/nfe/prontidao/{empresa_id} · Is the company ready to issue NF-e?
- GET/v1/nfe/inutilizacoes · Numbers voided by Sudrel
- GET/v1/nfe/{id} · Gets an NF-e
- GET/v1/nfe/{id}/xml · Authorized XML (nfeProc)
- GET/v1/nfe/{id}/danfe · DANFE as PDF
- POST/v1/nfe/{id}/correcao · Fixes a rejected NF-e and resends it
- POST/v1/nfe/{id}/descarte · Gives up on a rejected NF-e
- POST/v1/nfe/{id}/cancelamento · Cancels an authorized NF-e
- POST/v1/nfe/{id}/cartas-correcao · Registers a correction letter (CC-e)