Through the NF-e cancellation service, it’s possible to cancel a previously authorized invoice through the API.
Obs.: The cancellation of NF-e has rules and deadlines defined by Sefaz that must be considered and respected. For more information, click here and check the most updated version of the Sefaz Contributors’ Guidance Manual.
URL
Production: POST https://nfe.ns.eti.br/nfe/cancel
Input Data
Field | Description | Occurrence | Notes |
---|---|---|---|
X-AUTH-TOKEN | User access token | 1-1 | |
chNFe | NF-e access key | 1-1 | |
tpAmb | NF-e authorization environment type: 1 - Production 2 - Homologation | 1-1 | |
dhEvento | Date and time of the cancellation | 1-1 | Sefaz Standard: YYYY-MM-DDTHH:MM:SS+UTC E.g.: 2016-06-13T15:04:10-02:00 |
nProt | NF-e authorization protocol number | 1-1 | |
xJust | Literal description of the reason for cancelling the NF-e |
Request example
NF-e cancellation request
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"X-AUTH-TOKEN": "YOUR_TOKEN",
"chNFe": "43161107364617000135550000000099601000094832",
"tpAmb": "2",
"dhEvento": "2016-11-28T19:06:14-02:00",
"nProt": "143160001510168",
"xJust": "NF-e cancelada para teste de desenvolvimento de software de integração"
}'\
https://nfe.ns.eti.br/nfe/cancel
Returned data
Field | Description | Notes |
---|---|---|
status | Processing status code | |
motivo | Processing status literal description | |
retEvento | Object containing the cancellation processing data at Sefaz | Only when status = 200 |
retEvento.cStat | Processing situation code | |
retEvento.xMotivo | Literal description of the processing situation at Sefaz | |
retEvento.chNFe | NF-e access key | |
retEvento.dhRegEvento | Date and time of the event registration at Sefaz | Sefaz Standard: YYYY-MM-DDTHH:MM:SS+UTC. E.g.: 2016-06-13T15:04:10-02:00 |
retEvento.nProt | Sefaz authorization protocol number for the event | |
erro | Object containing error information in case the cancellation could not be carried out successfully | Only when status is different from 200 |
erro.cStat | Error status code | |
erro.xMotivo | Error literal description |
Return example
Successful return
{
"status": 200,
"motivo": "NF-e cancelada com sucesso",
"retEvento": {
"cStat": 135,
"xMotivo": "Evento registrado e vinculado a NF-e",
"chNFe": "43161107364617000135550000000099601000094832",
"dhRegEvento": "2016-11-28T19:09:04-02:00",
"nProt": "143160001510173"
}
}
Return codes
Code | Description |
---|---|
200 | NF-e cancelled successfully |
-2 | Invalid access key |
-3 | It was not possible to cancel the NF-e. Check the "erro" object for more information |
Download NF-e cancellation
You can download the complete cancellation distribution information in XML or JSON and also a graphical representation of the same in PDF format. For this, check the Event Download method in the NS NF-e API.