Documentation Mercado Libre
Check out all the necessary information about APIs Mercado Libre.
Documentation
Stock management in Full/Flex coexistence (MLA and MLC)
Now in Argentina and Chile, for items with Full and Flex coexistence, sellers can manage the stock in their warehouse (selling_address) and the stock in Full (meli_facility) separately to provide a better experience that helps them achieve more sales and fewer cancellations.
It is important to note that to use the stock update resource, in addition to having items in Full stock, you must have the Flex and Fulfillment shipping methods active. To verify this, check that the listing has the logistic_type fulfillment and the tag self_service_in, as these two fields indicate that the listing is in coexistence of both logistics.
Notifications
Soon, we will make available the stock_locations topic notifications for when the stock_locations of the user_product are modified, either by increment or decrement of the quantity field.
Get an item's stock
To check the item's stock, you must first obtain the user_product_id. To do this, query the field via the /items resource. If the item has variations, you must obtain the user_product_id within the variations array.
Request:
curl -X GET -h 'Authorization: Bearer $ACCESS_TOKEN' https://api.mercadolibre.com/user-products/$USER_PRODUCT_ID/stock
Example:
curl -X GET -h 'Authorization: Bearer $ACCESS_TOKEN' https://api.mercadolibre.com/user-products/MLAU12345678/stock
Response:
{
"locations":
[
{
"type": "meli_facility",
"quantity": 5
}
{
"type": "selling_address",
"quantity": 9
}
],
"id": "MLAU12345678",
"user_id": 1376088286
}
Response fields:
- Type: allows you to differentiate the item's locations.
- selling_address: stock available in the seller's warehouse (Flex).
- meli_facility: stock managed by Fulfillment.
When querying the endpoint, it will return a header called “x-version” which will have an integer value (of type long) representing the version of the entity.
This header must be sent when making modifications to entities; if it is not sent, a bad request status code 400 will be returned, and if the version sent is no longer the latest on the entity to be modified, a conflict status code 409 will be returned.
In the case of a response with status code 409, you must perform a GET again on the entity to be modified to obtain the updated x-version header.
Modify an item's stock
Request:
curl -X PUT -h 'Authorization: Bearer $ACCESS_TOKEN' -h 'x-version:$HEADER -h 'Content-Type: application/json'
https://api.mercadolibre.com/user-products/$USER_PRODUCT_ID/stock/type/selling_address -d
{
"quantity": XX
}
Example:
curl -X PUT -h 'Authorization: Bearer $ACCESS_TOKEN' -h 'x-version:$HEADER -h 'Content-Type: application/json'
https://api.mercadolibre.com/user-products/MLAU12345678/stock/type/selling_address -d
{
"quantity": 10
}
Response status codes:
| Code | Message | Description | Recommendation |
|---|---|---|---|
| 204 | OK | The stock will be updated asynchronously across all sales conditions of the user product. | |
| 400 | You cannot modify selling address stock if associated items are fulfillment only or no items are associated. | It is not possible to modify selling_address stock if the item is only active in Full. | Do not attempt to modify stock on items that do not have Full/Flex coexistence. |
| 400 | You cannot modify selling address stock in items without inventory id. | It is not possible to modify selling_address stock if there is no stock in Fulfillment. | The seller must first send stock to Meli's warehouse before modifying the selling_address stock. |
| 400 | You cannot modify selling address stock because you have to do a full inbound first before modifying. | ||
| 400 | Missing X-Version header | You must provide the “x-version” header. | |
| 409 | Version mismatch | The “x-version” header provided is incorrect. | Make a GET on /user-product to obtain the updated “x-version” header. |