Redispatch CT-e Download

Introduction

This API provides a way to download a CT-e document, of the redispatch type, generated by Mercado Livre on behalf of the carrier. The operation is performed through a GET method, using the specific transport identifiers such as route_id, shipment_id, and cte_key.

Important: OAuth will be used for security.

Request

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

Example Call (Request):

bash
1https://api.mercadolibre.com/MLB/routes/1234567/shipments/123456/cte/0000000000000000000000000000000000000000000?doctype=xml&access_token=123*******************************123

Response

The API response will be an XML document of the CT-e. Below is an example response with the main elements of the CT-e, including information about the issuer, recipient, amounts, and details of the transported cargo.

xml
1<cteProc xmlns="http://www.portalfiscal.inf.br/cte" versao="3.00"> 2 <CTe xmlns="http://www.portalfiscal.inf.br/cte"> 3 <infCte Id="CTe35111222333344445555666677" versao="3.00"> 4 <ide> 5 <cUF>35</cUF> 6 <cCT>123456</cCT> 7 <CFOP>5351</CFOP> 8 <natOp>Operação de transporte</natOp> 9 <mod>57</mod> 10 </ide> 11 <emit> 12 <CNPJ>12345678901234</CNPJ> 13 <xNome>Empresa Emitente Fictícia</xNome> 14 </emit> 15 <rem> 16 <CNPJ>98765432109876</CNPJ> 17 <xNome>Empresa Receptora Fictícia</xNome> 18 </rem> 19 </infCte> 20 <protCTe versao="3.00"> 21 <infProt> 22 <chCTe>35111222333344445555666677</chCTe> 23 <dhRecbto>2023-01-01T12:00:00-03:00</dhRecbto> 24 <nProt>123456789012345</nProt> 25 <xMotivo>Autorizado o uso do CT-e</xMotivo> 26 </infProt> 27 </protCTe> 28 </CTe> 29</cteProc>

In case of an error, the API will return an HTTP status other than 200 and the content-type will be 'application/json', with error details.

404 (NOT_FOUND)

json
1{ 2 "message": "download_document_not_found", 3 "error": "Document not found", 4 "status": 404, 5 "cause": [] 6}

Status Codes

The API uses standard HTTP status codes to indicate the success or failure of a request. Below are the most common status codes you may encounter.

HTTP Code
Content-Type
Response Body
Description
200application/xml (example above)When the CT-e is successfully generated.
404application/json{"message": "document_not_found"...}When the CT-e is not found.
404application/json{"message": "route_not_found"...}When the route is not found.