# 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** `/v2/wallet_connect/agreements/{agreement_id}/payer_token` ## Request parameters ### Path - `agreement_id` (string, required) Unique identifier of the agreement, returned in the response from the endpoint [/v2/wallet_connect/agreements](/developers/en/reference/online-payments/wallet-connect/orders/create-agreement/post). - `code` (string, optional) Validation code generated during the [agreement linking flow](/developers/en/docs/wallet-connect/configure-agreements). It is a 32-character lowercase alphanumeric code obtained from the buyer's confirmation callback. ## Response parameters - `payer_token` (string, optional) `payer_token` that represents the buyer's authorization for the seller to process payments from their wallet. ## Errors | Status | Error | Description | | ------- | ------- | ----------- | | 400 | 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. | | 400 | AlreadyCreated | A `payer_token` for this agreement has already been generated. Use the `payer_token` obtained previously, as the same `code` cannot be reused. | | 400 | WindowExpired | The time window for generating a `payer_token` has expired. Create a new agreement and obtain a new approval from the buyer. | | 400 | AgreementNotConfirmedByUser | The agreement has not been confirmed by the buyer yet. Wait for the approval flow to be completed before requesting the `payer_token`. | | 400 | UserIdEqualsCollectorId | The buyer and seller cannot be the same Mercado Pago user. Use distinct accounts to perform the agreement. | | 400 | InvalidCodeFormat | The `code` format is invalid. It must be a 32-character lowercase alphanumeric string. | | 403 | 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. | | 404 | 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. | | 404 | 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. | | 500 | 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 example ### cURL ```bash curl -X POST \ 'https://api.mercadopago.com/v2/wallet_connect/agreements/{agreement_id}/payer_token' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer ' \ -d '{ "code": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4" }' ``` ## Response example ```json { "payer_token": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4" } ```