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
| Field | Description | Data Type | Occurrence | Notes |
|---|---|---|---|---|
| X-AUTH-TOKEN | User access token | String | 0-1 | |
| licencaCnpj | CNPJ of the license interested in consulting the status of the CT-e | Int | 0-1 | Used to identify the digital certificate to be used. If no sent, the CNPJ will be extracted from the key sent in the chCTe field. |
| chCTe | CT-e access key | Int | 1-1 | |
| tpAmb | CT-e authorization environment type: 1 - Production, 2 - Homologation | Int | 1-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
| Field | Description | Notes |
|---|---|---|
| status | Processing status code | |
| motivo | Processing status literal description | |
| retConsSitCTe | Object containing the authorization protocol data of the CT-e and all linked events | Only 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.
| Code | Return |
|---|---|
| 100 | Authorized document |
| 101 | Cancelled document |
| 110 | Denied document |
Return codes
| Code | Description |
|---|---|
| 200 | Consult carried out successfully |
| -400 | CT-e key or environment type not informed |
| -3 | Invalid access key |
| -6 | Error carrying out the consult. Verify the return to identify the reason |