1. Inicio
  2. Documentos
  3. NS CTe (English)
  4. CTe Events
  5. CT-e Event Download

CT-e Event Download

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
FieldDescriptionNotes
X-AUTH-TOKENUser access token
chCTeCT-e access key
tpDownDownload type:
"X" – XML,
"J" – JSON,
"P" – PDF,
"XP" – XML and PDF,
"JP" – JSON and PDF
PDF only available for Cancellation and Correction Letter
tpEventoEvent type:
CCE, CANC, COMPENTREGA ou CANCCOMPENTREGA
CCE: Electronic Correction Letter
CANC: CT-e cancellation
COMPENTREGA: Delivery receipt
CANCCOMPENTREGA: Delivery receipt cancellation
tpAmbEvent environment type: 1 - Production, 2 - HomologationDefault value: 1
nSeqEventoEvent sequential numberFor 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
FieldDescriptionNotes
statusProcessing status code
motivoProcessing status literal description
retEventoObject containing the event processing data at SefazOnly when status = 200
retEvento.cStatEvent situation code at Sefaz
retEvento.xMotivoEvent situation literal description at Sefaz
retEvento.chCTeCT-e access key
retEvento.dhRegEventoDate and time of the event registration at SefazSefaz Standard: YYYY-MM-DDTHH:MM:SS+UTC
E.g.: 2016-06-13T15:04:10-02:00
retEvento.nProtEvent authorization protocol number by Sefaz
xmlEvent XMLOnly when tpDown = "X" (or "XP") and status = 200
jsonEvent XML jsonOnly when tpDown = J (or "JP") and status = 200
pdfGraphical representation of the event in PDFPDF in Base64. Only when tpDown = "P" (or "XP" or "JP") and status = 200
erroObject containing error information in case the download was not successfulOnly when status is different from 200
erro.cStatError code
erro.xMotivoError 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
CodeDescription
200Download carried out successful
-2Invalid access key
-3Invalid event type
-4Invalid download type
-5Not possible to load the event. Verify the "erro" object for more information

Como podemos ajudar?