Through the Event Download service, it’s possible to obtain the event data of a Cancellation or Electronic Correction Letter linked to a CT-e. The event data can be received in JSON or XML. In addition, it’s also possible to receive a graphical representation of the event in PDF format.
URL
3.00 version
Production: POST https://cte.ns.eti.br/cte/get/event/300
Input data
Field | Description | Notes |
---|---|---|
X-AUTH-TOKEN | User access token | |
chCTe | CT-e access key | |
tpDown | Download type: "X" – XML, "J" – JSON, "P" – PDF, "XP" – XML and PDF, "JP" – JSON and PDF | PDF only available for Cancellation and Correction Letter |
tpEvento | Event type: CCE, CANC, COMPENTREGA ou CANCCOMPENTREGA | CCE: Electronic Correction Letter CANC: CT-e cancellation COMPENTREGA: Delivery receipt CANCCOMPENTREGA: Delivery receipt cancellation |
tpAmb | Event environment type: 1 - Production, 2 - Homologation | Default value: 1 |
nSeqEvento | Event sequential number | For Cancellation it will be always 1 |
Request example
Event download request
curl -X POST
\-H "Content-Type: application/json"
\-d '{
"X-AUTH-TOKEN": "YOUR_TOKEN",
"chCTe": "43170112936129000195100000000013191000013027",
"tpDown": "xp",
"tpEvento": "cce",
"nSeqEvento": 1
}' \
https://cte.ns.eti.br/cte/get/event/300
Returned data
Field | Description | Notes |
---|---|---|
status | Processing status code | |
motivo | Processing status literal description | |
retEvento | Object containing the event processing data at Sefaz | Only when status = 200 |
retEvento.cStat | Event situation code at Sefaz | |
retEvento.xMotivo | Event situation literal description at Sefaz | |
retEvento.chCTe | CT-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 | Event authorization protocol number by Sefaz | |
xml | Event XML | Only when tpDown = "X" (or "XP") and status = 200 |
json | Event XML json | Only when tpDown = J (or "JP") and status = 200 |
Graphical representation of the event in PDF | PDF in Base64. Only when tpDown = "P" (or "XP" or "JP") and status = 200 | |
erro | Object containing error information in case the download was not successful | Only when status is different from 200 |
erro.cStat | Error code | |
erro.xMotivo | Error literal description |
Return example
Successful return
{
"status": 200,
"motivo": "Consulta realizada com sucesso",
"retEvento": {
"cStat": "135",
"xMotivo": "Evento registrado e vinculado ao CT-e",
"chCTe": "43161107364617000135550000000099341000094832",
"dhRegEvento": "2016-11-29T19:15:42-02:00",
"nProt": "143160001512983"},
"xml": "<?xml version=\"1.0\" encoding=\"utf-8\"?><procEventoCTe versao=\"1.00\" xmlns=\"http://www.portalfiscal.inf.br/Cte\">...</procEventoCTe>","pdf": "JVBERi0xLjQKJe..."
}
Return codes
Code | Description |
---|---|
200 | Download carried out successful |
-2 | Invalid access key |
-3 | Invalid event type |
-4 | Invalid download type |
-5 | Not possible to load the event. Verify the "erro" object for more information |