Query CTE from MWH

Introduction

The purpose of this API is to serve information in XML or PDF format to carriers that are part of the transport and that want to access the CT-e and NF-e from MELI. After the carrier queries the CT-e data, they must traverse all the fiscal data and download the XML using the URL contained in fiscal_data.tax.document.href with type=cte_document.

Important: OAuth will be used for security.

Request

bash
1GET https://api.mercadolibre.com/shipments/cte/{cte_key}?access_token={token}&doctype=xml

Response

The API returns the CT-e XML document. Below is an example of the full XML response:

xml
1<?xml version="1.0" encoding="UTF-8"?> 2<cteProc xmlns="http://www.portalfiscal.inf.br/cte" versao="3.00"> 3 <CTe xmlns="http://www.portalfiscal.inf.br/cte"> 4 <infCte Id="CTe35211020121850005467573310000009681865579207" versao="3.00"> 5 <ide> 6 <cUF>35</cUF> 7 <cCT>86557920</cCT> 8 <CFOP>6353</CFOP> 9 <natOp>PRESTAÇÕES DE SERVIÇOS DE TRANSPORTE</natOp> 10 <mod>57</mod> 11 <serie>331</serie> 12 <nCT>968</nCT> 13 <dhEmi>2021-10-25T13:46:46-03:00</dhEmi> 14 <tpImp>1</tpImp> 15 <tpEmis>1</tpEmis> 16 <cDV>7</cDV> 17 <tpAmb>2</tpAmb> 18 <tpCTe>0</tpCTe> 19 <procEmi>0</procEmi> 20 <verProc>1.0.0</verProc> 21 <cMunEnv>3509205</cMunEnv> 22 <xMunEnv>Cajamar</xMunEnv> 23 <UFEnv>SP</UFEnv> 24 <modal>01</modal> 25 <tpServ>0</tpServ> 26 <cMunIni>3509205</cMunIni> 27 <xMunIni>Cajamar</xMunIni> 28 <UFIni>SP</UFIni> 29 <cMunFim>2414001</cMunFim> 30 <xMunFim>Tangara</xMunFim> 31 <UFFim>RN</UFFim> 32 <retira>1</retira> 33 <indIEToma>1</indIEToma> 34 <toma3><toma>0</toma></toma3> 35 </ide> 36 <compl> 37 <Entrega> 38 <semData><tpPer>0</tpPer></semData> 39 <semHora><tpHor>0</tpHor></semHora> 40 </Entrega> 41 <xObs>Partilha nao calculada com base no PAR 3o Clausula II do Convenio ICMS CONFAZ 932015. Valor aproximado dos tributos R$ 1.87</xObs> 42 </compl> 43 <emit> 44 <CNPJ>20121850005467</CNPJ> 45 <IE>241141125113</IE> 46 <xNome>CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL</xNome> 47 <enderEmit> 48 <xLgr>Via de Acesso Norte</xLgr> 49 <nro>800</nro> 50 <xBairro>Empresarial Anhanguera</xBairro> 51 <cMun>3509205</cMun> 52 <xMun>Cajamar</xMun> 53 <CEP>07753580</CEP> 54 <UF>SP</UF> 55 </enderEmit> 56 </emit> 57 <rem> 58 <CNPJ>39802712000321</CNPJ> 59 <IE>130759432117</IE> 60 <xNome>CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL</xNome> 61 <enderReme> 62 <xLgr>Rua Campos Vergueiro</xLgr> 63 <nro>140</nro> 64 <xBairro>Vila Anastacio</xBairro> 65 <cMun>3550308</cMun> 66 <xMun>Sao Paulo</xMun> 67 <CEP>05095020</CEP> 68 <UF>SP</UF> 69 </enderReme> 70 </rem> 71 <dest> 72 <CPF>04762365416</CPF> 73 <xNome>CT-E EMITIDO EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL</xNome> 74 <enderDest> 75 <xLgr>Rua Santa Rita</xLgr> 76 <nro>8</nro> 77 <xBairro>centro</xBairro> 78 <cMun>2414001</cMun> 79 <xMun>Tangara</xMun> 80 <CEP>59240000</CEP> 81 <UF>RN</UF> 82 </enderDest> 83 </dest> 84 <vPrest> 85 <vTPrest>26.49</vTPrest> 86 <vRec>26.49</vRec> 87 </vPrest> 88 <imp> 89 <ICMS> 90 <ICMS00> 91 <CST>00</CST> 92 <vBC>26.49</vBC> 93 <pICMS>7.00</pICMS> 94 <vICMS>1.85</vICMS> 95 </ICMS00> 96 </ICMS> 97 <vTotTrib>1.85</vTotTrib> 98 </imp> 99 <infCTeNorm> 100 <infCarga> 101 <vCarga>11.72</vCarga> 102 <proPred>CAIXA</proPred> 103 <infQ> 104 <cUnid>01</cUnid> 105 <tpMed>PESO BRUTO</tpMed> 106 <qCarga>0.9600</qCarga> 107 </infQ> 108 </infCarga> 109 <infDoc> 110 <infNFe> 111 <chave>35200720121850000317551830000007891718491996</chave> 112 <dPrev>2021-09-03</dPrev> 113 </infNFe> 114 </infDoc> 115 </infCTeNorm> 116 </infCte> 117 </CTe> 118 <protCTe versao="3.00"> 119 <infProt> 120 <tpAmb>2</tpAmb> 121 <chCTe>35211020121850005467573310000009681865579207</chCTe> 122 <dhRecbto>2021-10-25T13:46:56-03:00</dhRecbto> 123 <nProt>135210014725214</nProt> 124 <cStat>100</cStat> 125 <xMotivo>Autorizado o uso do CT-e</xMotivo> 126 </infProt> 127 </protCTe> 128</cteProc>
Note: For reference of the response attributes, see the Sefaz website for more information: https://www.cte.fazenda.gov.br/portal/listaConteudo.aspx?tipoConteudo=YIi+H8VETH0= (Annex I)

Status Code Examples

If an error occurs, the API will return an HTTP status other than 200, an error message, the error, its cause, and the content-type will be application/json.

400 (NOT_OK)

json
1{ 2 "message": "description", 3 "error": "bad_request", 4 "status": 400, 5 "cause": [] 6}
HTTP Code
Content-Type
Response Body
Description
200application/xmlXML (example above)Returns the XML of the queried CT-e.
400application/json400 Response aboveThere is a problem with the submitted request. The message field contains a brief description. The client should not repeat this request without modifying it; repeated insistence may result in a temporary block.