AI resources
Generate payer token

This endpoint allows generating a payer_token, a unique identifier that represents the buyer's authorization for the seller to process payments from their wallet. In case of success, the request will return a response with status 201.

POST

https://api.mercadopago.com/v2/wallet_connect/agreements/{agreement_id}/payer_token
Request parameters
Header
Authorization
string

REQUIRED

Access Token obtained through the developer panel. Must be sent in all requests.
Path
agreement_id
string

REQUIRED

Unique identifier of the agreement, returned in the response from the endpoint /v2/wallet_connect/agreements.
Body
code
string

REQUIRED

Validation code generated during the agreement linking flow. It is a 32-character lowercase alphanumeric code obtained from the buyer's confirmation callback.
Response parameters
payer_token
string
payer_token that represents the buyer's authorization for the seller to process payments from their wallet.
Errors

400Request error.

CodeMismatch

The provided code does not match the validation code for this agreement. Use the code returned in the return_uri or in the confirmation webhook of the corresponding agreement.

AlreadyCreated

A payer_token for this agreement has already been generated. Use the payer_token obtained previously, as the same code cannot be reused.

WindowExpired

The time window for generating a payer_token has expired. Create a new agreement and obtain a new approval from the buyer.

AgreementNotConfirmedByUser

The agreement has not been confirmed by the buyer yet. Wait for the approval flow to be completed before requesting the payer_token.

UserIdEqualsCollectorId

The buyer and seller cannot be the same Mercado Pago user. Use distinct accounts to perform the agreement.

InvalidCodeFormat

The code format is invalid. It must be a 32-character lowercase alphanumeric string.

403Forbidden.

forbidden

You don't have permission to access the requested resource. Check whether the Access Token used has the permissions and scopes required for this operation.

404Resource not found.

AgreementNotFound

No agreement was found with the provided ID. This same response is returned when the agreement belongs to another application (ClientNotOwner), in order to avoid exposing the existence of other customers' agreements.

ClientNotOwner

The agreement exists but was not created by the current application. The same AgreementNotFound response will be returned to avoid exposing the existence of other customers' agreements.

500Generic error.

internal_error

An internal server error occurred. Please try again later. If the problem persists, contact support and provide the x-request-id and details about the operation performed.

Request
curl -X POST \
    'https://api.mercadopago.com/v2/wallet_connect/agreements/{agreement_id}/payer_token'\
    -H 'Content-Type: application/json' \
       -H 'Authorization: Bearer APP_USR-4*********994754-12*********c73b4e1ac*********cef36b27c*********840' \
    -d '{
  "code": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"
}'
Response
{
  "payer_token": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"
}