POST
/api/nfse/cancelCancel NFS-e
Required headers
tokenstring | string | Company token |
signstring | string | MD5 signature |
timestampstring | string | Unix timestamp in seconds |
Fields
chave*string | string | Verification code of the NFS-e (codigoVerificacao from the issuance response, codigo_verificacao in the list); for NFS-e of the national system, the 50-digit access key (chave in the issuance response and the list) is also accepted |
motivo*string | string | Cancellation reason. National system: at least 15 characters after trimming; characters beyond 255 are truncated. São Paulo: required by the endpoint but not sent to the municipality |
c_string | string | National system only: cancellation justification code, "1" = Issuance error (default), "2" = Service not provided, "9" = Other; other values return an error.Ignored in São Paulo |
Only NFS-e with status autorizada can be cancelled. If the national system or the municipality replies that the NFS-e is already cancelled, the endpoint also returns success and updates the record status to cancelada.
Common errors
| Message | Cause |
|---|---|
| O campo chave (codigo de verificacao) e obrigatorio | chave not provided |
| O campo motivo e obrigatorio | motivo not provided |
| NFS-e nao encontrada para a chave informada | No NFS-e with this verification code or access key under the company of the token |
| Somente NFS-e autorizada pode ser cancelada | The NFS-e is already cancelled or not authorized |
| O motivo do cancelamento deve ter no minimo 15 caracteres | National system: motivo shorter than 15 characters |
| cMotivo invalido: use 1 (Erro na emissao), 2 (Servico nao prestado) ou 9 (Outros) | National system: c_motivo outside the allowed values |
| Chave de acesso da NFS-e invalida para cancelamento (esperados 50 digitos) | National system: the access key stored in the record does not have 50 digits |
Examples
# sign = md5(token + path + body + timestamp) # Template generated from the endpoint path; replace the placeholders curl -X POST "https://api.tffiscal.com/api/nfse/cancel" \ -H "Content-Type: application/json" \ -H "token: $TOKEN" \ -H "timestamp: $TIMESTAMP" \ -H "sign: $SIGN" \ -d @body.json
{
"chave": "Z685RI9C",
"motivo": "Cancelamento da NFS-e por erro na emissao",
"c_motivo": "1"
}
{
"success": true,
"message": "Nota de servico cancelada com sucesso"
}