Documentación Mercado Libre

Descubre toda la información que debes conocer sobre las APIs de Mercado Libre.
circulos azuis em degrade

Documentación

Última actualización 24/10/2023

Pixel management

Importante:
In order to make use of the resource, you must complete the following form, in order to access the certification process and meet the requirements.

With the /shops/custom-scripts/ext/integration resource you can associate your scripts to the seller's Shop, as well as deactivate it.

Considerations

  • The application must be registered at https://developers.mercadolibre.com, obtaining the application_id. (The application must be registered in Mshop).
  • To authorize requests, Oauth is used (more info).
  • Keep in mind that an application_id can only have one pixel_id. To acquire another, you must register another application. In turn, a Pixel_id can have multiple sellers associated with it.
  • To associate a script with a seller, the latter must have delegated a domain to MercadoShops. If this step was not performed, the API will return a status code 401 with the following message: Your shop is not authorized for this request, you must have a delegated domain. To identify if the seller has a delegated domain or not (more info.)
  • The format of the scripts must be a Handlebars template such that a JavaScript code can be obtained by replacing the user variable. The JavaScript code obtained from the script must be able to be executed within a condition. Additionally, it is preferable that the script be kept as small as possible, with a total size less than 2kB, and if additional logic is needed, the script should make a call to fetch and execute another JavaScript file stored on a CDN provided by the Integrator.
  • The name of the .Json file cannot have spaces or special characters, Custom-script does not allow them in the names of the Pixels.
  • The script must contain the variable that is defined in the .Json file. It is feasible to call the variable VARIABLE.

Example of correct scripts:


script.hbs

if (/*condition*/) { 
var 
src="https://test-pixel.com/api/script/mercadoshops/onLoad.js?=shop123"; var script = document.createElement("script"); 
script.setAttribute("src", src); 
document.getElementsByTagName("head")[0].appendChild(script); 
} 

This scripts will be displayed in the store as follows:

var src="https://test-pixel.com/api/script/mercadoshops/onLoad.js?={{VARIABLE}}"; var script = document.createElement("script"); 
script.setAttribute("src", src); 
document.getElementsByTagName("head")[0].appendChild(script); 

Example of incorrect scripts:

Glossary of fields and parameters

Field Field description Possible values for the field and its description
pixel_id Identification of the application script. String
sections Contains the arguments that indicate the section(s) of the store where the pixel will impact. Lower case must be respected and at least one section must be indicated. If none is indicated or the name is incorrect, a 400 error will be returned. The possible values are: home, search, cart, vip and contact.
external_client_id Seller ID, to which the pixel will be applied. String
integration_id Identifier of the integration previously created to the seller in the POST endpoint. It is the value of the response corresponding to the id. String

Identify the Store Domain

Prior to starting the pixel configuration flow, it is necessary to have access to the domain data of the Mercado Shops vendors in order to first identify whether or not they have a delegated domain, and also to have the domain information of the store to add customs scripts to integrators. For this we allow the information to be made available through the following resource.

Important:
Keep in mind that in the response to the /public-domains request you will have to validate that the status is ACTIVE to allow you to continue with the pixel configuration flow. In case of receiving any other value, we should give notice that the store does not have a delegated domain.

Request:

curl -X GET -H 'Authorization: Bearer $ACCESS_TOKEN'
https://api.mercadolibre.com/shops/public-domains

Response:

{
    "domain": "www.shop.domain.com",
    "shop_id": 123242154125,
    "status": "ACTIVE",
    "delegation_type": "PARTIAL",
    "site": "MCO"
}

Response Parameters

Fields Field Description Possible values for the field and its description
domain delegated domain String
shop_id shop id Long
status Delegation status REGISTERED, CHECK_FOR_TOTAL_DELEGATION, CHECK_FOR_PARTIAL_DELEGATION, DELEGATION_OK, DELEGATION_ERROR, CERTIFICATE_OK, CERTIFICATE_ERROR, NAVIGATION_OK, NAVIGATION_ERROR, ACTIVE, ERROR, DOMAIN_EXPIRED, CERTIFICATE_EXPIRED, INACTIVE, DELEGATION_CEASED, DELEGATION_ANALYZE, DELEGATION_RESTART, DELEGATION_PREVIOUS, DELEGATION_REREGISTER, CERTIFICATE_ANALYZE, NAVIGATION_ANALYZE, ANALYZE
delegation_type Delegation Type TOTAL, PARTIAL
site seller site id MLA, MBO, MLB, MLC, MCO, MCR, MRD, MCU, MEC, MGT, MHN, MLM, MNI, MPA, MPY, MPE, MPT, MSV, MLU, MLV

Errors

Status_Code Error code Error message Description
401 unauthorized Seller has pending to ask their identity validation The seller did not validate your identity.
401 unauthorized Signature not found by user_id and checkpoint_id The seller did not sign the terms and conditions.
401 unauthorized Client.id not allowed to continue operation The client_id does not have permissions to access vendor information.
401 unauthorized invalid_token
403 forbidden ACCESS_TOKEN_NOT_GRANTED You do not have permissions to perform the query.
404 not_found shop_id not found in kvs The seller does not have domain delegation.
429 too_many_requests Over quota Too many requests were made in a short period of time.
500 internal_server_error It is caused by an unexpected error in any step of the flow.

Associate script to seller's shop

Request:

curl -X POST-H 'Authorization: Bearer $ACCESS_TOKEN' -H "Content-Type: application/json" -d
    {...}
https://api.mercadolibre.com/shops/custom-scripts/ext/integration

Example:

curl -X POST -H 'Authorization: Bearer $ACCESS_TOKEN' -H "Content-Type: application/json" -d
'{
  "pixel_id": "XXXXX",
  "sections": ["home", "search", "vip", "cart", "contact"],
  "external_client_id": "XXXXX",
}
'
https://api.mercadolibre.com/shops/custom-scripts/ext/integration

Response:

{
  "id": "XXXXX",
  "pixel": {
    "id": "XXXXX",
    "description": "XXXXX"
  },
  "created_at": "XXXXX",
  "sections": ["home", "search", "vip", "cart", "contact"]
}
Note:
Where the status code is sufficiently descriptive, the response body will be empty. In cases where the status code does not provide enough information, the error and message fields will be included in the response body to provide more context about the error.

Status Code Response body Notes
201 - Created Newly created integration data (id, creation date, sections, pixel details). It is important to save the id returned by this endpoint, since it must be used when disabling the integration.
400 - Unauthorized { "error": "Unauthorized Shop", "message": "Shop does not have a valid domain" } The shop to which the integration is to be performed does not have a delegated domain.
400 - Bad Request { "error": "Active integration already exists", "message": "Seller already has an active integration with this script" } The integration you are trying to perform is already active in the seller's domain.
400 - Bad Request { "error": "Script doesn't exist", "message": "Unable to find the script with the provided ID: " } The script to be integrated into the shop does not exist.
401 - Unauthorized { "error": "Unauthorized", "message": "You are unauthorized for this request" } The authorization token is not valid.
500 - Internal Server Error Internal error.

Disable pixel

Con el el siguiente recurso podrás desactivar el pixel en todas las secciones en que se activó previamente al usuario (vendedor).

Request:

curl -X DELETE -H 'Authorization: Bearer $ACCESS_TOKEN' https://api.mercadolibre.com/shops/custom-scripts/ext/integration?integration_id={INTEGRATION_ID}

Example:

curl -X DELETE -H 'Authorization: Bearer $ACCESS_TOKEN' https://api.mercadolibre.com/shops/custom-scripts/ext/integration?integration_id={INTEGRATION_ID}

Response:

{
  "updated_at": "XX/XX/XX",
  "status": "Disabled",
  "external_client_id": "XXXXX"
}

Status Code

Status Code Response body Notes
200 - OK
400 - Bad Request { "error": "Integration already disabled", "message": "It is not possible to process your request. The integration is already disabled" } The integration was previously disabled.
400 - Bad Request { "error": "Integration doesn't exist", "message": "The integration doesn't exist" } The integration to be disabled does not exist.
401 - Unauthorized { "error": "Unauthorized", "message": "You are unauthorized for this request" } The authorization token is not valid.
500 - Internal Server Error Internal error.