Authorizations for Domestic Shipping

Content

The following information provides the API details to authorize a shipment with the carrier and get the tracking number and any additional information to generate the label that will be provided to the seller.

All the web services should be HTTP REST. It’s expected that the web service response uses the status codes specification depending if the request was successful or not.

Once a purchase has been performed on the site, Mercado Libre will make a POST request to the carrier as follows

POST /shipments/shipment_id/authorization
Note:
  • The shipment identifier (shipment_id) is unique at MELI´s side and must be used to validate if there was any previous autorization, taking into account that a retry mechanism is in place just in case an authorization fails.
  • The shipment identifier could eventually be associated to more than a tracking number but, it must only exist a unique "active" tracking number at the carrier side.
  • Idempotence: in case of receiving a request with a shipment already authorized, the service must retrieve a response with “HTTP Code” = 200, the same body and tracking number that was retrieved during the original authorization.
  • A cancelled shipment could be authorized in a future so this case should be taken into account.
  • Mercado Libre will send data with variable length in all fields which could also change over time so is responsability of the carrier to truncate data according to their storage requirements.
Important:
The Tracking Number of any shipment must only change on “n” authorizations if, and only if, a cancellation was prevously requested.

Depending on whether the authorization was succesfull or not, it is expected that the carrier retrieves a result according to the specified at "Status Code" section. In case of error, the communication will be retried according to the retry schema defined as part of the integration.

Important:
OAuth 2.0 will be used for secure authorizations.

Request Format

Inside the body of the request a JSON will be sent with the following attributes

NameData typeDescriptionField presence in every request
idLongUnique identifier of the shipment used by Mercado Libre, required to authorize. This ID will later be used to notify the events that occur in the operational flow of the shipment.Mandatory field presence in requests
transport_order_idStringUnique identifier for the transport legAlways present in the request
directionStringIndicates the direction of shipping. The allowed values are:
  • If the direction is from the seller to the buyer → "foward"
  • If the direction is from the buyer to the seller → "return"
Mandatory field presence in requests
carrier_informationNodeContains elements relevant to the carrier.Mandatory field presence in requests
carrier_information.contractStringIdentifies the contract / service defined by the carrier with which the shipment is to be authorized. For example, home delivery from the XD, shipment to DS agency, etc.Optional
carrier_information.agencyNodeContains information related to the destination agency. Mandatory only when it is a shipment to a carrier agency.Optional
carrier_information.agency.idStringId give Mercado Libre to the agency.Mandatory field presence in requests
shipment_informationNodeIt contains all the information that is considered relevant for shipping authorization. Sender, receiver, item, etc. Measurements are in centimeters and weights in grams.Mandatory field presence in requests
shipment_information.packageNodePackage related informationMandatory field presence in requests
shipment_information.package.itemsNodeInformation related to the itemsMandatory field presence in requests
shipment_information.package.items.item_idStringItem identification number on MercadolibreMandatory field presence in requests
shipment_information.package.items.descriptionStringItem description on MercadlibreMandatory field presence in requests
shipment_information.package.items.quantityNumericQuantity per item.Mandatory field presence in requests
shipment_information.package.amountNumericAmount paid for the package content.Mandatory field presence in requests
shipment_information.package.dimensionsNodePackage dimensions and weight.
shipment_information.package.dimensions.heightNumericHeight of the package in centimeters.Mandatory field presence in requests
shipment_information.package.dimensions.lengthNumericLength of the package in centimeters.Mandatory field presence in requests
shipment_information.package.dimensions.widthNumericWidth of the package in centimeters.Mandatory field presence in requests
shipment_information.package.dimensions.weightNumericWeight of the package in grams.Mandatory field presence in requests
shipment_information.receiverNodeInformation related to the receiverMandatory field presence in requests
shipment_information.receiver.full_nameStringFull name or company name of the recipientMandatory field presence in requests
shipment_information.receiver.first_nameStringFirst nameMandatory field presence in requests
shipment_information.receiver.last_nameStringLast name.Mandatory field presence in requests
shipment_information.receiver.phoneNodeInformation related to the receiver's phone data
shipment_information.receiver.phone.numberStringOnly numbersMandatory field presence in requests
shipment_information.receiver.addressNodeInformation related to the receiver's addressMandatory field presence in requests
shipment_information.receiver.address.street_nameStringStreet nameMandatory field presence in requests
shipment_information.receiver.address.street_numberStringStreet number.Optional
shipment_information.receiver.address.intersectionStringSecondary street.Mandatory field presence in requests in Ecuador
shipment_information.receiver.address.address_lineStringContains the street_name and street_number fields dataMandatory field presence in requests
shipment_information.receiver.address.commentStringCommentsOptional
shipment_information.receiver.address.zip_codeStringZip codeMandatory field presence in requests in Argentina, Brasil, México and Peru
shipment_information.receiver.address.cityNodeDestination cityMandatory field presence in requests
shipment_information.receiver.address.city.idStringUnique city identifier provided by Mercado Libre.Mandatory field presence in requests in Colombia, Uruguay, Chile and Ecuador
shipment_information.receiver.address.city.nameStringCity nameMandatory field presence in requests
shipment_information.receiver.address.stateNodeState, department or province of destination.Mandatory field presence in requests
shipment_information.receiver.address.state.idStringUnique state identifier provided by Mercado Libre. Format ISO 3166.Mandatory field presence in requests
shipment_information.receiver.address.state.nameStringState name.Mandatory field presence in requests
shipment_information.receiver.address.countryNodeDestination country.Mandatory field presence in requests
shipment_information.receiver.address.country.idStringUnique identifier that Mercado Libre gives the country in ISO 3166 Format.Mandatory field presence in requests
shipment_information.receiver.address.country.nameStringCountry name.Mandatory field presence in requests
shipment_information.receiver.address.neighborhoodNodeDestination neighborhood.Optional
shipment_information.receiver.address.neighborhood.idStringUnique neighborhood identifier.Optional
shipment_information.receiver.address.neighborhood.nameStringNeighborhood name.Optional
shipment_information.receiver.address.municipalityNodeMunicipality of destination.Optional
shipment_information.receiver.address.municipality.idStringUnique municipality identifier.Optional
shipment_information.receiver.address.municipality.nameStringMunicipality name.Optional
shipment_information.receiver.address.geolocationNodeAddress location.Optional
shipment_information.receiver.address.geolocation.geolocation_typeStringIt can be one of the following values:
  • APPROXIMATE: approximate geolocation.
  • GEOMETRIC_CENTER: locates the center of a region that is used as a reference.
  • RANGE_INTERPOLATED: restricts precision to the midpoint of 2 nearby reference points.
  • ROOFTOP: indicates that the location is exact.
  • UNKNOWN: indicates that the location was not validated.
Mandatory field presence in requests
shipment_information.receiver.address.geolocation.latitudeNumericLatitude in number format with 8 decimal places.Mandatory field presence in requests
shipment_information.receiver.address.geolocation.longitudeNumericLongitude of the location in number format with 8 decimal places.Mandatory field presence in requests
shipment_information.receiver.identificationNodeReceiver IdentificationMandatory field presence in requests for Chile and Brazil
shipment_information.receiver.identification.typeStringReceiver Identification Type (it may vary depending on the country)Mandatory field presence in requests for Chile and Brazil
shipment_information.receiver.identification.numberNumericReceiver identification numberMandatory field presence in requests for Chile and Brazil
shipment_information.senderNodeSender informationMandatory field presence in requests
shipment_information.sender.full_nameStringSender full name or company nameMandatory field presence in requests
shipment_information.sender.first_nameStringSender nameMandatory field presence in requests
shipment_information.sender.last_nameStringSender last nameMandatory field presence in requests
shipment_information.sender.phoneNodeSender phone informationMandatory field presence in requests
shipment_information.sender.phone.numberStringOnly numbersMandatory field presence in requests
shipment_information.sender.addressNodeInformation related to the sender addressMandatory field presence in requests
shipment_information.sender.address.street_nameStringStreet name.Mandatory field presence in requests
shipment_information.sender.address.street_numberStringStreet number.Optional
shipment_information.sender.address.intersectionStringSecondary street.Mandatory field presence in requests in Ecuador
shipment_information.sender.address.address_lineStringContains the street_name and street_number fields dataMandatory field presence in requests
shipment_information.sender.address.commentStringOptional
shipment_information.sender.address.zip_codeStringZip code.Mandatory field presence in requests in Argentina, Brasil, México and Peru
shipment_information.sender.address.cityNodeOrigin city.Mandatory field presence in requests
shipment_information.sender.address.city.idStringUnique city identifier provided by Mercado Libre.Mandatory field presence in requests in Colombia, Uruguay, Chile and Ecuador
shipment_information.sender.address.city.nameStringCity name.Mandatory field presence in requests
shipment_information.sender.address.stateNodeState, department or province of origin.Mandatory field presence in requests
shipment_information.sender.address.state.idStringUnique state identifier provided by Mercado Libre. Format ISO 3166.Mandatory field presence in requests
shipment_information.sender.address.state.nameStringState name.Mandatory field presence in requests
shipment_information.sender.address.countryNodeOrigin country.Mandatory field presence in requests
shipment_information.sender.address.country.idStringUnique identifier that Mercado Libre gives the country in ISO 3166 Format.Mandatory field presence in requests
shipment_information.sender.address.country.nameStringCountry name.Mandatory field presence in requests
shipment_information.sender.address.neighborhoodNodeOrigin neighborhoodOptional
shipment_information.sender.address.neighborhood.idStringUnique neighborhood identifier.Optional
shipment_information.sender.address.neighborhood.nameStringNeighborhood name.Optional
shipment_information.sender.address.municipalityNodeMunicipality of origin.Optional
shipment_information.sender.address.municipality.idStringUnique municipality identifier.Optional
shipment_information.sender.address.municipality.nameStringMunicipality name.Optional
shipment_information.sender.address.geolocationNodeAddress location.Optional
shipment_information.sender.address.geolocation.geolocation_typeStringIt can be one of the following values:
  • APPROXIMATE: approximate geolocation.
  • GEOMETRIC_CENTER: locates the center of a region that is used as a reference.
  • RANGE_INTERPOLATED: restricts precision to the midpoint of 2 nearby reference points.
  • ROOFTOP: indicates that the location is exact.
  • UNKNOWN: indicates that the location was not validated.
Mandatory field presence in requests
shipment_information.sender.address.geolocation.latitudeNumericLatitude in number format with 8 decimal places.Mandatory field presence in requests
shipment_information.sender.address.geolocation.longitudeNumericLongitude of the location in number format with 8 decimal places.Mandatory field presence in requests
shipment_information.sender.address.facility_idStringUnique facility identifierOptional
shipment_information.sender.identificationNodeInformation related to the sender’s identification.Always present in the request (Chile and Brazil)
shipment_information.sender.identification.typeStringSender’s identification type.Always present in the request (Chile and Brazil)
shipment_information.sender.identification.numberNumericSender’s identification number.Always present in the request (Chile and Brazil)
testBooleanIndicates that the request sent is for testingOptional
keywordStringThe HASH (SHA256) of a secret word. The value of this parameter can be empty. If a value is present, the Carrier must request the secret word from the receiver of the package.Optional
Note:
It should be noted that carrier account information must follow this order:
  • Contract: it is the number that uses the carrier to identify the contract (agreement) of rates established with Mercado Libre. It is being used to know how to define the shipment cost. This is the most used field by carriers.
  • Account: it is the identifier used by the carrier to differentiate areas of Mercado Libre. For instance Cross Border Trade has a different account id at the carrier side.
  • User: it is a user name assigned to Mercado Libre's clients.
  • Password: it is the password associated to the user.

OAuth Request Format

For the authentication mechanism through the generation of a token with OAuth, the following header must be added to the request:

--request  POST 'https://hostname/shipments/{shiment_id}/authorization'
--header 'Authorization: Bearer + TOKEN'
--body 'What is described in each integration is maintained'
Note:

Once the OAuth solution is implemented, the use of username and password in the integrations should be deprecated in favor of the use of the token. The fields to be deprecated are the following:

FieldTypeDescription
carrier_information.userStringIdentifies a mail system user assigned to the Mercado Libre customer.
carrier_information.passwordStringIdentifies the password associated with the system user.

Formato Response

Inside the body, the system will return all the data from the authorization, listed below:

NameData typeDescriptionType
idLongUnique identifier of the shipment used by Mercado Libre, required to authorize. This ID will later be used to notify the events that occur in the operational flow of the shipment.Mandatory
statusStringStatus of the authorization request
  • AUTHORIZED
  • FAILED
  • ERROR
Mandatory
status_messageStringAny relevant detail regarding the authorization status.Mandatory in case of failure (status = FAILED or status = ERROR).
tracking_numberStringTracking NumberMandatory in case the authorization was successfully processed. (status = AUTHORIZED).
authorization_informationNodeContains any information related to the date and time of the authorization. Also any extra information for the label generation.
authorization_information.dateDate (ISO 8601)Valid values. In UTC format: 2020-07-04T12:08:56.235Z or in local relative local time: 2020-07-04T12:08:56.235-07:00.Mandatory in case the authorization was successfully processed. (status = AUTHORIZED).
authorization_information.custom_dataNodeContains any relevant information for the label generation. There can be as many fields as needed in the key:value format.Optional
authorization_information.custom_data.keyString|Long“Key” refers to the name of the key in the key:value format. The value can be either text or number.Mandatory

Performance

Important:
It’s expected that the average request response time is under one second.

Status Codes

StatusHTTP codeDescriptionAction
AUTHORIZED200The authorization was successfully processed.The shipment was already authorized and won't retry.
FAILED400The authorization was not able to be processed due to an error on the request. It’s expected to return status=FAILED with the status_message specifying the error cause.Depending on the nature of the error, the data will try to be fixed before retrying. Periodic retries could happen.
ERROR500Any server side error. In this case status and status_message are optional.There will be retry attempts to perform the authorization until the authorization is performed successfully.

Example

Request:

POST https://hostName/shipments/26379079680/authorization
{
    "id":10101033319242,
    "transport_order_id": "5c81e696e6d9183ea9190a58c13d4de71816b743",
    "direction":"forward",
    "carrier_information":{
        "contract":"",
    },
    "shipment_information":{
        "sender":{
            "first_name":"PY",
            "last_name":"S.A.",
            "phone":{
                "number":"522175123929",
            },
            "address":{
                "address_line":"Calle 12",
                "street_name":"Calle 12",
                "street_number":"S/N",
                "intersection":"Calle 21",
                "comment":"",
                "zip_code":"1870",
                "city":{
                    "id":"TUxBQ0xBTWF0YW56",
                    "name":"La Matanza"
                    },
                "state":{
                    "id":"AR-B",
                    "name":"Buenos Aires"
                    },
                "country":{
                    "id":"AR",
                    "name":"Argentina"
                    },
                "neighborhood":{
                    "id":null,
                    "name":"Villa Celina"
                    },
                "municipality":{
                    "id":null,
                    "name":"Villa Celina"
                    },
                "geolocation":{
                    "geolocation_type":"ROOFTOP",
                    "latitude":-14.10100206,
                    "longitude":-52.10104811
                    },
                "facility_id":"101010"
            },
            "full_name":"GOLANDS",
        },
        "receiver":{
            "first_name":"MEL",
            "last_name":"PY",
            "phone":{
                "number":"10108508106",
            },
            "address":{
                "address_line":"Calle 23",
                "street_name":"Calle 23",
                "street_number":"S/N",
                "intersection":"Calle 32",
                "comment":"",
                "zip_code":"1625",
                "city":{
                    "id":"TUxBQ0VTQzQ3YTc0",
                    "name":"Escobar"
                    },
                "state":{
                    "id":"AR-B",
                    "name":"Buenos Aires"
                    },
                "country":{
                    "id":"AR",
                    "name":"Argentina"
                    },
                "neighborhood":{
                    "id":null,
                    "name":null
                    },
                "municipality":{
                    "id":null,
                    "name":null
                    },
                "geolocation":{
                    "geolocation_type":"RANGE_INTERPOLATED",
                    "latitude":-32.101012822,
                    "longitude":-52.10102059
                    },
                "delivery_preference":"business"
            },
            "full_name":"Mel py",
            "id":10010389392
        },
        "package":{
            "items":[
                {
                "item_id":"MLA101010618394",
                "description":"Lampara 100w",
                "quantity":1
                }
            ],
            "dimensions":{
                "height":15,
                "width":25,
                "length":70,
                "weight":1900
            },
            "amount":2420,
        },
    "test":false,
    "keyword": "3bc405c30cadb4e6eefdf0cff899abcf8234d761c9a3ea1b2f510601ae5fc504"
}

Response:

Authorized (HTTP Status Code 200)

{
    "id": "10101033319242",
    "status":"AUTHORIZED",
    "status_message":"OK",
    "tracking_number": "ASDfgh123asd",
    "authorization_information": {
        "date": "2001-07-04T12:08:56.235-07:00",
        "custom_data":{
            "ruta_1":"RUTA"
        }
    }
}

FAIL (HTTP Status Code 400)

{
    "error_code": "invalid_user_information.buyer",
    "status_message":"Missing receiver information",
    "status": "FAILED"
}

FAIL (HTTP Status Code 500)

{
    "status_message":"Internal server error",
    "status": "ERROR"
}