Query Fiscal Data for Line Haul Routes

Introduction

This API serves fiscal data to carriers that are part of Mercado Libre's Middle Mile Line Haul transport.

Important: Make sure you have a valid application and token, and that you are authorized to use this endpoint. OAuth will be used for security.

Query by Route and Facility

Given a Route ID and a Facility ID, this API returns the Shipments for the route along with the URL to obtain the Shipment details.

bash
1GET https://api.mercadolibre.com/MLB/routes/{RouteID}/facilities/{FacilityID}/fiscal-info?offset=0&limit=3&access_token={token}

Example Request

bash
1GET https://api.mercadolibre.com/MLB/routes/1234567890/facilities/MELI123/fiscal-info?offset=0&limit=3&access_token=123*******************************123

Example Response

json
1{ 2 "limit": 3, 3 "offset": 0, 4 "total_items": 110, 5 "route_id": 12345678, 6 "status": "accepted", 7 "facility_id": "mx001", 8 "route_type": "middle_mile", 9 "items": [ 10 { 11 "id": "40000000000", 12 "href": "https://api.mercadolibre.com/MLB/routes/123/shipments/123/fiscal-info" 13 } 14 ] 15}

Response Fields

ParameterTypeDescription
limitIntDefines the number of items per page, with a maximum allowed value of 500
total_itemsIntTotal number of shipments in the route
route_idIntRoute ID
statusStringRoute status (accepted, canceled)
facility_idStringFacility ID
route_typeStringRoute type (middle_mile)
itemsArrayArray of routes
items.idStringShipment ID
items.hrefStringURL for shipment details

Shipment Detail Query API

Given a Shipment ID, this API returns simplified data such as the NF-e Key, CT-e Key, and the corresponding links to download each XML file for each Shipment in the route.

bash
1GET https://api.mercadolibre.com/MLB/routes/{RouteID}/shipments/{ShipmentID}/fiscal-info?access_token=accessToken

Example Request

bash
1GET https://api.mercadolibre.com/MLB/routes/1234567890/shipments/MELI123/fiscal-info?access_token=123*******************************123

Example Response

json
1{ 2 "entity_id": "40000000000", 3 "entity_type": "shipment", 4 "route_id": 123456, 5 "route_type": "middle_mile", 6 "origin": { 7 "facility_id": "BRSP05", 8 "cnpj": "123456789", 9 "ie": "123456789", 10 "name": "Facility 01", 11 "address": { 12 "street_name": "Rua a", 13 "number": "1", 14 "neighborhood": "Bairro", 15 "city": "Cidade", 16 "city_code": "11", 17 "zipcode": "111111111", 18 "state": "SS", 19 "country": "BR", 20 "country_code": "11245" 21 } 22 }, 23 "destination": { 24 "facility_id": "BRXSP9", 25 "cnpj": "123456789", 26 "ie": "123456789", 27 "name": "Facility 01", 28 "address": { 29 "street_name": "Rua a", 30 "number": "1", 31 "neighborhood": "Bairro", 32 "city": "Cidade", 33 "city_code": "11", 34 "zipcode": "111111111", 35 "state": "SS", 36 "country": "BR", 37 "country_code": "11245" 38 } 39 }, 40 "fiscal_data": [ 41 { 42 "invoice": { 43 "type": "nfe_document", 44 "amount": 104.37, 45 "key": "35210000000000000000000000000000000000000000", 46 "href": "https://api.mercadolibre.com/MLB/shipments/40000000000/nfe/35210000000000000000000000000000000000000000?doctype=xml" 47 }, 48 "tax": { 49 "type": "ICMS", 50 "key": "35211111111111111111111111111111111111111111", 51 "href": "https://api.mercadolibre.com/MLB/shipments/40000000000/cte/35211111111111111111111111111111111111111111?doctype=xml" 52 } 53 } 54 ] 55}

Response Fields

ParameterTypeDescription
idStringShipment ID
typeStringShipment type
route_idIntRoute ID
facility_idStringFacility ID
originObjectShipment origin
origin.facility_idStringOrigin facility ID
origin.cnpjStringOrigin facility CNPJ
origin.ieStringOrigin facility IE
origin.nameStringOrigin facility name
origin.address.street_nameStringOrigin facility street name
origin.address.numberStringOrigin facility number
origin.address.neighborhoodStringOrigin facility neighborhood
origin.address.cityStringOrigin facility city
origin.address.city_codeStringOrigin facility city code
origin.address.zipcodeStringOrigin facility zip code
origin.address.stateStringOrigin facility state
origin.address.countryStringOrigin facility country
origin.address.country_codeStringOrigin facility country code
destinationObjectShipment destination
destination.facility_idStringDestination facility ID
destination.cnpjStringDestination facility CNPJ
destination.ieStringDestination facility IE
destination.nameStringDestination facility name
destination.address.street_nameStringDestination facility street name
destination.address.numberStringDestination facility number
destination.address.neighborhoodStringDestination facility neighborhood
destination.address.cityStringDestination facility city
destination.address.city_codeStringDestination facility city code
destination.address.zipcodeStringDestination facility zip code
destination.address.stateStringDestination facility state
destination.address.countryStringDestination facility country
destination.address.country_codeStringDestination facility country code
fiscal_dataObjectShipment fiscal data
fiscal_data.invoice.keyStringInvoice (NF-e) key
fiscal_data.invoice.typeStringDocument type (nfe_document, dce_document)
fiscal_data.invoice.hrefStringURL to download the NF-e file
fiscal_data.tax.keyStringCT-e key
fiscal_data.tax.typeStringDocument type (ICMS or ISS)
fiscal_data.tax.hrefStringURL to download the CT-e file

Additional Notes

The fiscal_data attribute is a list of fiscal documents (i.e., NF-e and CT-e) per package. It always has two attributes for each package: invoice with NF-e related data; and tax with transport fiscal document data.

In tax, there is a type attribute that can take the following values:

  • ICMS: Indicates that Mercado Libre issued the umbrella CT-e for this package. It is the Carrier's responsibility to issue the redispatch CT-e, referencing the umbrella CT-e. The XML document can be obtained from the document.href attribute.
  • No_Tax: Indicates this is a 1P package. Mercado Libre did not issue any CT-e, and it is the Carrier's responsibility to issue the umbrella CT-e referencing the package NF-e.
  • ISS: Indicates transport within the same city, so no CT-e was issued by Mercado Libre, nor should it be issued by the Carrier. There is also another ISS scenario: ISS corresponds to transport within the same city or collection, forwarding or delivery of correspondence, documents, objects, goods or values, taxed by ISS according to LC 116/2003.

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 content-type will be application/json.

404 (NOT_FOUND)

json
1{ 2 "message": "An error occurred while trying to get route details", 3 "error": "unexpected_error", 4 "status": 404, 5 "cause": [ 6 "error_getroute" 7 ] 8}
HTTP CodeContent TypeResponse BodyDescription
200application/xmlXML (example above)When fiscal data is successfully retrieved.
404application/json{ "message": "An error occurred while trying to get route details" }When an incorrect Route ID or Facility ID is provided.