TF Fiscal

Received Documents & DistDFe

POST/api/invoice/received/get_prod

Get products from received NF-e

Required headers

tokenstringstringCompany token
signstringstringMD5 signature: MD5(token + path + body + timestamp)
timestampstringstringUnix timestamp in seconds (5-minute window)

Fields

FieldTypeRequiredDescription
chavestringYes44-digit NF-e access key (model 55). The check digit is validated before calling the tax authority
ciencia_notaboolNoDefaults to false. "true", "1" and "sim" are also accepted. With true, if the tax authority has not released the full XML yet, the endpoint registers the Acknowledgement of Operation (event 210210) with the company certificate and queries once more; if an Acknowledgement was already registered through the platform, it is not sent again
ambienteintNo1 production (default) or 2 staging; any other value is treated as production

Response fields

chavestringstringAccess key that was queried
total_itensnumbernumberNumber of items in the invoice
itensarrayarrayOne object per invoice item (det)
emitobjectobjectIssuer's CNPJ, xNome, IE, UF and CRT
ideobjectobjectnNF, serie, dhEmi, tpNF, natOp and finNFe
totalobjectobjectICMSTot and, when present, IBSCBSTot
How the tax authority delivers the XML
  • The receiving company comes from the token; do not send a CNPJ in the body.
  • The query uses document distribution (DistDFe) at the National Environment, with the company’s own certificate.
  • Without a manifestation, the tax authority returns only the summary, with no items. Use ciencia_nota: true to release the full XML.
  • The Acknowledgement only states awareness of the invoice: it neither confirms receipt of the goods nor prevents the issuer from cancelling it.
  • A freshly authorized invoice may take a few minutes until the National Environment distributes it. Until then the response is invoice not found.
  • An invoice issued by the company itself is not distributed to it; query with the receiving company’s token.
  • The query stores nothing. Only the Acknowledgement, when triggered, registers an event at the tax authority.

Common errors

MessageCause
Chave inserida inválida / 发票密钥无效Key without 44 digits, with a non-numeric character, or with a wrong check digit
Apenas NF-e modelo 55 pode ser consultada pela chaveThe key belongs to an NFC-e (model 65), which the tax authority does not distribute
empresa não encontrada para este tokenThe token is not linked to any registered company
empresa não possui certificado configuradoThe company has no valid A1 certificate on file
nenhum documento localizado para esta chave e este CNPJ...The National Environment has not distributed the invoice yet, the environment is different, the company is not the recipient, or no Acknowledgement has been registered yet
esta nota foi emitida por este CNPJ e a SEFAZ não a distribui ao próprio emitenteQuerying an outgoing invoice with the issuer’s own token (rejection 641)
SEFAZ devolveu apenas o resumo da nota (sem itens)...Invoice still without Acknowledgement; call with ciencia_nota=true
consumo indevido: a SEFAZ bloqueou consultas repetidasThe tax authority per-CNPJ limit; wait before retrying
When the ciencia_nota flag triggers the event or finds one already registered, the error response carries data.ciencia with the event outcome. Every other error returns only success and message.

data.ciencia fields

enviadaboolboolWhether this request registered the Acknowledgement successfully
ja_registradaboolbooltrue means it had already been registered through the platform and was not sent again
tipo_eventointintAlways 210210
cStatintintStatus code returned by the tax authority for the event
nProtstringstringEvent protocol number
registrada_emstringstringReturned only when ja_registrada is true: time of the earlier registration
mensagemstringstringDescription of the event outcome

Examples

# sign = md5(token + path + body + timestamp)
# Template generated from the endpoint path; replace the placeholders
curl -X POST "https://api.tffiscal.com/api/invoice/received/get_prod" \
  -H "Content-Type: application/json" \
  -H "token: $TOKEN" \
  -H "timestamp: $TIMESTAMP" \
  -H "sign: $SIGN" \
  -d @body.json