Create agreement - Account linking flow - Mercado Pago Developers

Create agreement

The first step to integrating Wallet Connect is the creation of an agreement, that is, an authorization link that the buyer accesses to authorize the merchant access to his Mercado Pago wallet when making a payment.

The agreement stores the payment methods selected by the payer and allows the modification of these settings without the intervention of the merchant, turning this step transparent during the payment flow.

Check out the diagram below that illustrates how the agreement creation flow works.

Create agreement

To create an agreement, send a POST with the necessary attributes to the /v2/wallet_connect/agreements endpoint and execute the request or, if you prefer, use the curl below and pay attention to the request response that will return two parameters mandatory to obtain the payer's approval: agreement_uri and return_uri.

          
curl -X POST \
      'https://api.mercadopago.com/v2/wallet_connect/agreements?client.id=<CLIENT.ID>' \
      -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
      -H 'Content-Type: application/json' \ 
      -H 'x-platform-id: YOUR_ACCESS_TOKEN' \
      -d '{
  "return_url": "https://www.mercadopago.com/",
  "external_flow_id": "EXTERNAL_FLOW_ID",
  "external_user": {
    "id": "usertest",
    "description": "Test account"
  },
  "agreement_data": {
    "validation_amount": 3.14,
    "description": "Test agreement"
  }
}'

        
Important
A user can only have one active agreement per integration. If you want to create a new agreement, you must cancel the previous one. To cancel an agreement, send a DELETE to the endpoint /v2/wallet_connect/agreements/{agreement_id} and execute the request.