TF Fiscal

NF-e Invoices

POST/api/invoice/consultar_status

Get NF-e status

Consults the current status of an NF-e or NFC-e directly at the tax authority using the access key (44 digits), via the NfeConsultaProtocolo4 service. Works for both own invoices (issued by the token company) and third-party invoices (e.g. captured via DistDFe). The model (NF-e/NFC-e) is detected automatically from positions 20-21 of the key.

Required headers

tokenstringstringCompany token (whose certificate will be used in the consultation)
signstringstringMD5 signature: MD5(token + path + body + timestamp)
timestampstringstringUnix timestamp in seconds (5-minute window)

Body

chave*stringstringAccess key (44 numeric digits).
ambientestringstringWhich environment to query: 1=production, 2=homologation (also accepts producao/homologacao).

 * Required field.

Response fields

chavestringstringAccess key queried
statusstringstringNormalized status (see table below)
cstatintintRaw tax authority cStat code
motivostringstringRaw tax authority xMotivo message

Status mapping

autorizada100 , 150100 , 150NF-e authorized for use
cancelada101 , 151101 , 151Cancelled (also returned if there is a linked cancellation event, even with cStat=100)
denegada110 , 301 , 302110 , 301 , 302Use denied by the tax authority
inutilizada102102Number invalidated (numbering range)
nao_encontrada217217NF-e not present in the tax authority database
desconhecidoothersothersUnmapped cStat — check raw cstat and motivo

Error responses

MessageCause
chave inválida: deve ter 44 dígitosKey missing, with size other than 44, or containing non-numeric characters
empresa não possui certificado configuradoThe token company has no cert_file registered
SEFAZ retornou resposta vaziaThe tax authority returned no response (timeout, offline)
erro ao consultar SEFAZ: <detail>Exception while calling the service (invalid XML, timeout, expired certificate, etc.)

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/consultar_status" \
  -H "Content-Type: application/json" \
  -H "token: $TOKEN" \
  -H "timestamp: $TIMESTAMP" \
  -H "sign: $SIGN" \
  -d @body.json