Consult Carta Porte Information by Shipment from Mexico

Introduction

The carta-porte shipment data query API is designed to provide fiscal data to carriers involved in transportation who want to generate the fiscal document for Mexico (cfdi+carta-porte). Given a shipment ID, this API returns the corresponding data (product list, origin and destination) for that shipment.

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

Request

bash
1GET https://api.mercadolibre.com/shipments/{shipment_id}/carta-porte-details/{step_type}?access_token={access_token}&logistic_center=MXAQR1&pipeline=SMD1_A
Parameter
Data Type
Description
Type
shipment_idStringShipment IDRequired
step_typeStringName of the desired section. Possible values: first_mile, middle_mile, last_mileRequired
access_tokenStringAccess tokenRequired
logistic_centerStringName of the logistic center from which the dispatch departs. Must not be used for first_mile or last_mile. Required for middle_mile.Conditionally Required
pipelineStringName of the HU pipeline present in the dispatch. Must not be used for first_mile or last_mile. Required for middle_mile.Conditionally Required

Response

json
1{ 2 "recipient": { 3 "rfc": "string", 4 "full_name": "string" 5 }, 6 "origin": { 7 "fiscal_information": { 8 "full_name": "string", 9 "rfc": "string", 10 "fiscal_residence": "string" 11 }, 12 "address": { 13 "address_line": "string", 14 "street_name": "string", 15 "street_number": "string", 16 "intersection": "string", 17 "zip_code": "string", 18 "city": { "id": "string", "name": "string" }, 19 "state": { "id": "string", "name": "string" }, 20 "country": { "id": "string", "name": "string" }, 21 "neighborhood": { "id": "string", "name": "string" }, 22 "municipality": { "id": "string", "name": "string" } 23 } 24 }, 25 "destination": { 26 "fiscal_information": { 27 "full_name": "string", 28 "rfc": "string", 29 "fiscal_residence": "string" 30 }, 31 "address": { 32 "address_line": "string", 33 "street_name": "string", 34 "street_number": "string", 35 "intersection": "string", 36 "zip_code": "string", 37 "city": { "id": "string", "name": "string" }, 38 "state": { "id": "string", "name": "string" }, 39 "country": { "id": "string", "name": "string" }, 40 "neighborhood": { "id": "string", "name": "string" }, 41 "municipality": { "id": "string", "name": "string" } 42 } 43 }, 44 "package": { 45 "items": [ 46 { 47 "category": int, 48 "description": "string", 49 "unit_code": "string", 50 "quantity": int, 51 "dangerous_material": "string", 52 "dangerous_material_key": "string", 53 "package_key": "string", 54 "package_description": "string", 55 "dimensions": { 56 "height": int, 57 "width": int, 58 "length": int, 59 "weight": int 60 } 61 } 62 ], 63 "total_items": int 64 }, 65 "return_reverse_logistics_collection": "" 66}

The response is an array by entity/type. If the fiscal data for a specific entity cannot be found, the error "Shipment id not found" is returned, as shown in the example above.

Parameter
Data Type
Description
Type
recipientObjectRecipient data
recipient.rfcStringRecipient's RFC (Tax ID)
recipient.full_nameStringRecipient's full name
originObjectShipment origin
origin.fiscal_informationObjectOrigin fiscal information
origin.fiscal_information.full_nameStringName of origin responsible party
origin.fiscal_information.fiscal_residenceStringConditional attribute to register the country code of fiscal residence for the federal freight transport operator, per the c_Pais catalog published on the SAT portal, based on ISO 3166-1.
origin.fiscal_information.rfcStringRFC of origin responsible party
origin.addressObjectOrigin location
origin.address.address_lineStringField composed of the street_name and street_number fields for the origin
origin.address.street_nameStringOrigin street name.
origin.address.street_numberStringOrigin street number.
origin.address.intersectionStringCross street.
origin.address.zip_codeStringOrigin zip code
origin.address.cityObjectOrigin city
origin.address.city.idStringUnique identifier assigned by Mercado Libre to the city
origin.address.city.nameStringCity name
origin.address.stateObjectOrigin state, department or province
origin.address.state.idStringUnique identifier assigned by Mercado Libre to the state in ISO 3166 format.
origin.address.state.nameStringState name
origin.address.countryObjectOrigin country
origin.address.country.idStringUnique identifier assigned by Mercado Libre to the country in ISO 3166 format
origin.address.country.nameStringCountry name
origin.address.neighborhoodObjectOrigin neighborhood
origin.address.neighborhood.idStringUnique neighborhood identifier
origin.address.neighborhood.nameStringNeighborhood name
origin.address.municipalityObjectOrigin municipality
origin.address.municipality.idStringUnique identifier assigned by Mercado Libre to the municipality
origin.address.municipality.nameStringMunicipality name
destinationObjectShipment destination
destination.fiscal_informationObjectDestination fiscal information
destination.fiscal_information.full_nameStringName of destination responsible party
destination.fiscal_information.rfcStringRFC of destination responsible party
destination.fiscal_information.fiscal_residenceStringConditional attribute to register the country code of fiscal residence for the federal freight transport operator, per the c_Pais catalog published on the SAT portal, based on ISO 3166-1.
destination.addressObjectDestination location
destination.address.address_lineStringField composed of the street_name and street_number fields for the destination
destination.address.street_nameStringDestination street name.
destination.address.street_numberStringDestination street number.
destination.address.intersectionStringCross street.
destination.address.zip_codeStringDestination zip code
destination.address.cityObjectDestination city
destination.address.city.idStringUnique identifier assigned by Mercado Libre to the city
destination.address.city.nameStringCity name
destination.address.stateObjectDestination state, department or province
destination.address.state.idStringUnique identifier assigned by Mercado Libre to the state in ISO 3166 format.
destination.address.state.nameStringState name
destination.address.countryObjectDestination country
destination.address.country.idStringUnique identifier assigned by Mercado Libre to the country in ISO 3166 format
destination.address.country.nameStringCountry name
destination.address.neighborhoodObjectDestination neighborhood
destination.address.neighborhood.idStringUnique neighborhood identifier
destination.address.neighborhood.nameStringNeighborhood name
destination.address.municipalityObjectDestination municipality
destination.address.municipality.idStringUnique identifier assigned by Mercado Libre to the municipality
destination.address.municipality.nameStringMunicipality name
packageObjectShipment packages
package.itemsListList of goods in the shipment
package.items.categoryIntAttribute corresponding in SAT to express the product key for goods or merchandise transported in various means of transport.
package.items.descriptionStringDescription of the merchandise
package.items.unit_codeStringAttribute to specify the standardized unit of measure key applicable to the quantity of goods or merchandise transported in various means of transport. The unit must correspond to the description of the registered goods or merchandise.
package.items.quantityIntMerchandise quantity
package.items.dangerous_materialStringIndicates if the product is hazardous material. Value "1" for hazardous material and "0" for non-hazardous.
package.items.dangerous_material_keyStringHazardous material code. Empty field when not hazardous.
package.items.package_keyStringPackage key.
package.items.package_descriptionStringPackage description.
package.items.dimensionsObjectInformation about merchandise dimensions
package.items.dimensions.heightIntHeight of the merchandise
package.items.dimensions.widthIntWidth of the merchandise
package.items.dimensions.lengthIntLength of the merchandise
package.items.dimensions.weightIntWeight of the merchandise in grams
package.total_itemsStringTotal quantity of goods in the shipment
return_reverse_logistics_collectionStringIndicates the use of reverse logistics, collection, or return services for transporting goods and/or merchandise. Values: Yes or "" (empty string)

HTTP Status Code Examples

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

400 (bad_request)

A 400 error occurs when the shipment is cancelled.

json
1{ 2 "message": "This shipment is cancelled", 3 "error": "bad_request", 4 "status": 400, 5 "cause": [] 6}

403 (NOT_OK)

A 403 error occurs due to lack of access to this API.

json
1{ 2 "message": "Access revoked, consult staff to check your permissions", 3 "error": "unexpected_error", 4 "status": 403, 5 "cause": ["error_getshipment"] 6}

404 (NOT_OK)

A 404 error occurs when an incorrect shipment ID is provided.

json
1{ 2 "message": "An error occurred while trying to get shipment details", 3 "error": "shipment_not_found", 4 "status": 404, 5 "cause": ["error_getshipment"] 6}

500 (INTERNAL_ERROR)

A 500 error occurs when an internal failure in this API occurs.

json
1{ 2 "message": "Error when trying to obtain shipment information", 3 "error": "internal_server_error", 4 "status": 500, 5 "cause": ["INTERNAL_ERROR"] 6}

HTTP Status Code Summary

HTTP Code
Content-Type
Response Body
Description
200application/jsonJSON (example above)When shipment data is successfully obtained.
400application/json{"message": "This shipment is cancelled"...}When the shipment is cancelled.
400application/json{"message": "Shipment not allowed"...}When the carrier has submitted a shipment for which it has no action in any process.
403application/json{"message": "Access revoked, consult staff to check your permissions"}When access to this API is missing.
404application/json{"message": "An error occurred while trying to get shipment details"...}When an incorrect shipment ID is provided.
500application/json{"message": "Error when trying to obtain shipment information"}When an internal failure in this API occurs.