1. Inicio
  2. Documentos
  3. NS CTe (English)
  4. CTe Utility Functions
  5. Consult CT-e Situation

Consult CT-e Situation

Through the Consult CT-e Situation service, it’s possible to obtain information about the actual state of the CT-e in the Sefaz database.

This functionality is widely used in cases where it’s necessary to verify the existence and validity of a CT-e, as well as obtain information about the events that occurred with it (e.g.: alteration of values by Electronic Correction Letter).

URL

3.00 version

Production: POST https://cte.ns.eti.br/cte/stats/300

Input data
FieldDescriptionData TypeOccurrenceNotes
X-AUTH-TOKENUser access tokenString0-1
licencaCnpjCNPJ of the license interested in consulting the status of the CT-eInt0-1Used to identify the digital certificate to be used. If no sent, the CNPJ will be extracted from the key sent in the chCTe field.
chCTeCT-e access keyInt1-1
tpAmbCT-e authorization environment type:
1 - Production,
2 - Homologation
Int1-1
Request example

Consult situation

curl -X POST 
    \-H "Content-Type: application/json" 
    \-d '{ 
      "X-AUTH-TOKEN": "...", 
      "licencaCnpj": "99999999999999", 
      "chCTe": "43160734593613900019557000000010891022310638", 
      "tpAmb": "2"
     }' \
    https://cte.ns.eti.br/cte/stats/300
Returned data
FieldDescriptionNotes
statusProcessing status code
motivoProcessing status literal description
retConsSitCTeObject containing the authorization protocol data of the CT-e and all linked eventsOnly when status = 200
Return example

Successful return

{
    "status": 200,
    "motivo":   "Consulta realizada com sucesso",
    "retConsSitCTe": {
        "tpAmb":   "2",
        "verAplic":   "RS20191021102414",
        "cStat":   "100",
        "xMotivo":   "Autorizado o uso do CT-e",
        "cUF":   "43",
        "protCTe": {
            "infProt": {
                "Id":   "CTe143200000138854",
                "tpAmb":   "2",
                "verAplic":   "RS20200626095146",
                "chCTe":   "43200907364617000135570000000112041000000235",
                "dhRecbto":   "2020-09-03T16:26:30-03:00",
                "nProt":   "143200000138854",
                "digVal":   "8RGNcKssGvRQlm1kT3u6NvdWh6I=",
                "cStat":   "100",
                "xMotivo":   "Autorizado o uso do CT-e"
            },
            "versao":   "3.00"
        },
        "versao":   "3.00"
    }
}
Returned cStats

According to the main cStat code, which is returned in the protCTe object, it’s possible to define the status of the document.

Below is a table with the values that can be returned. There may be other returns as the needs by Sefaz.

CodeReturn
100Authorized document
101Cancelled document
110Denied document
Return codes
CodeDescription
200Consult carried out successfully
-400CT-e key or environment type not informed
-3Invalid access key
-6Error carrying out the consult. Verify the return to identify the reason

Como podemos ajudar?