POST
/api/invoice/consultar_statusGet 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
tokenstring | string | Company token (whose certificate will be used in the consultation) |
signstring | string | MD5 signature: MD5(token + path + body + timestamp) |
timestampstring | string | Unix timestamp in seconds (5-minute window) |
Body
chave*string | string | Access key (44 numeric digits). Issuer UF is extracted from positions 0-1; model from positions 20-21 ( 55=NF-e, 65=NFC-e). |
ambientestring | string | Which environment to query: 1=production, 2=homologation (also accepts producao/homologacao).If omitted, the environment the note was issued in is used; production when the note is not found locally. The two are separate databases — querying production for a note issued in homologation always returns 217. |
* Required field.
Response fields
chavestring | string | Access key queried |
statusstring | string | Normalized status (see table below) |
cstatint | int | Raw tax authority cStat code |
motivostring | string | Raw tax authority xMotivo message |
Status mapping
autorizada100 , 150 | 100 , 150 | NF-e authorized for use |
cancelada101 , 151 | 101 , 151 | Cancelled (also returned if there is a linked cancellation event, even with cStat=100) |
denegada110 , 301 , 302 | 110 , 301 , 302 | Use denied by the tax authority |
inutilizada102 | 102 | Number invalidated (numbering range) |
nao_217 | 217 | NF-e not present in the tax authority database |
desconhecidoothers | others | Unmapped cStat — check raw cstat and motivo |
Error responses
| Message | Cause |
|---|---|
| chave inválida: deve ter 44 dígitos | Key missing, with size other than 44, or containing non-numeric characters |
| empresa não possui certificado configurado | The token company has no cert_file registered |
| SEFAZ retornou resposta vazia | The 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
{
"chave": "35260512345678000199550010000000011000000018"
}
{
"success": true,
"message": "Sucesso",
"data": {
"chave": "35260512345678000199550010000000011000000018",
"status": "autorizada",
"cstat": 100,
"motivo": "Autorizado o uso da NF-e"
}
}