POST
/api/nfce/cancelCancel NFC-e
Cancels an authorized NFC-e. Unlike NFe, the cancellation reason here is provided by the client and forwarded to the tax authority. The tax authority cancellation window is short (usually 15-30 minutes after authorization).
Required headers
tokenstring | string | Issuing company token |
signstring | string | MD5 signature |
timestampstring | string | Unix timestamp in seconds |
Body
chave*string | string | 44-digit access key of the NFC-e (note: here it's chave, not uuid as in other endpoints) |
motivo*string | string | Cancellation justification (tax authority requirement). At least 15 characters after leading and trailing spaces are removed, otherwise an error is returned; characters beyond 255 are truncated |
* Required field.
Response fields (data)
motivostring | string | Official tax authority message for the cancellation event |
statusstring | string | Situation: "Canceled" |
nfceint | int | Canceled NFC-e number |
serieint | int | NFC-e series |
chavestring | string | 44-digit access key |
modelostring | string | Document model: "nfce" |
cStatint | int | Tax authority event code: 135 or 155 = cancellation approved.If the NFC-e was already canceled, the success response comes without cStat |
Response — error
When the tax authority rejects the event (e.g. cancellation deadline exceeded),
success is false and data comes with status: "Failed" and the rejection cStat. Validation errors (missing chave/motivo, motivo shorter than 15 characters, NFC-e not found, contingency not yet transmitted) return success: false with the message in message and no data object.
{
"success": false,
"data": {
"motivo": "Rejeição: Pedido de Cancelamento intempestivo",
"status": "Failed",
"nfce": 5,
"serie": 1,
"chave": "35210112345678901234650010000000051234567890",
"modelo": "nfce",
"cStat": 501
}
}Examples
# sign = md5(token + path + body + timestamp) # Template generated from the endpoint path; replace the placeholders curl -X POST "https://api.tffiscal.com/api/nfce/cancel" \ -H "Content-Type: application/json" \ -H "token: $TOKEN" \ -H "timestamp: $TIMESTAMP" \ -H "sign: $SIGN" \ -d @body.json
{
"chave": "35210112345678901234650010000000051234567890",
"motivo": "Cancelamento por erro de operacao do caixa"
}
{
"success": true,
"data": {
"motivo": "Evento registrado e vinculado a NF-e",
"status": "Canceled",
"nfce": 5,
"serie": 1,
"chave": "35210112345678901234650010000000051234567890",
"modelo": "nfce",
"cStat": 135
}
}