Add payment method to a profile

This endpoint allows to add a payment method to a payment profile associated with a customer. A payment profile can contain a maximum of two payment methods, and a new one cannot be added if its status is "CANCELLED". In case of success, the request will return a response with status 201.

POST

https://api.mercadopago.com/v1/customers/{customer_id}/payment-profiles/{payment_profile_id}/payment-methods
Request parameters
Header
Authorization
string

REQUIRED

Access Token obtained through the developer panel. Must be sent in all requests.
X-Idempotency-Key
string

REQUIRED

This feature allows you to safely retry requests without the risk of accidentally performing the same action more than once. This is useful for avoiding errors, such as creating two identical payments. To ensure that eac...Show more
Path
customer_id
string

REQUIRED

Unique customer identifier to which the payment profile that is being modified belongs. It can be obtained by sending a request to the "Search clients" endpoint.
payment_profile_id
string

REQUIRED

Unique payment profile identifier to modify, associated with the customer. It can be obtained by sending a request to the "Query a client's payment profi||le" endpoint.
Body
id
string

REQUIRED

Identifier of the payment method selected to add to the profile. If it's a card payment, it will be the brand.
visa: Visa credit card.
master: Master credit card.
amex: American Express credit card.
Show more
type
string

REQUIRED

Type of payment method selected to add to the profile.
credit_card: Credit card.
debit_card: Debit card.
prepaid_card: Prepaid card.
token
string

REQUIRED

It is a mandatory field for card payments, as it is the token that identifies the card and contains its data securely. It has a minimum length of 32 characters, and a maximum length of 33. If you don't know how to genera...Show more
card_id
long

REQUIRED

Unique identifier of the card declared as payment method, associated with the customer. Its value can be obtained in the query to the "Search cards of a client" endpoint.
Response parameters
payment_method_id
string
Unique identifier for the payment method, automatically generated. It helps to identify and differentiate each payment method.
id
string
Identifier of the payment method added to the profile. If it's a card payment, it will show the brand.
type
string
Type of payment method added to the profile.
card_id
integer
Unique identifier of the card added to the profile, associated with the customer.
Errors

400Error

payment_methods_cannot_be_null

The request failed because no payment method information was sent. More details can be found in "details". Verify that the data sent is correct and try again.

payment_methods_required

The request failed because no object with payment method information was sent. More details can be found in "details". Verify that the data sent is correct and try again.

html_insertion_not_allowed

Request failed because HTML tags were inserted in fields that do not allow them. More information can be found in "details". Verify that the data sent is correct and try again.

validation_error

The request failed due to a validation error for the senti fields. More details can be found in "details". Verify that the data sent is correct and try again.

payload_failed

The request failed, possibly due to formatting or invalid data errors. More details can be found in "details". Verify that the data sent is correct and try again.

more_than_two_payment_methods_not_allowed

The request failed because more than two objects containing payment method information were sent, which is the maximum allowed for the profile creation. Review the request and verify that you have sent that node correctly.

two_cards_with_token_not_allowed

Request failed because it is not allowed to create a payment profile with two cards containing "card_token" as payment methods. Review the request to send both objects correctly.

duplicate_payment_method_not_allowed

Request failed due to a duplicated payment method. It is not allowed to add a payment method that already exists in the payment profile.

invalid_site_id_for_fintoc

Request failed because the site_id associated with the user who is creating the payment profile is not valid for fintoc, a payment method that is only available for Chile. Verify that you are sending the correct credentials or create a profile using a valid payment method for your country.

profile_modification_not_allowed

Request failed because it's not allowed to change profile with canceled status. Verify that the payment profile status is correct before attempting changes.

payment_method_validation_failed

Request failed because the payment method validation could not be done. Try again later and, if the problem persists, contact Support with error details.

payment_method_id_cannot_be_blank

The request failed because no "payment_method_id" was sent. More details can be found in "details". Verify that the data sent is correct and try again.

customer_id_mismatch

Request failed because the "customer_id" sent does not match the payment profile. Verify if the correct value was sent and try again.

caller_id_mismatch

Request failed because the "caller_id" sent does not match the payment profile. Verify if the correct value was sent and try again.

site_id_mismatch

Request failed because the "site_id" does not match the payment profile. Verify if the correct value was sent and try again.

unknown_error_occurred

Unknown error. Contact Support for more information.

401Error

header_missing

Request failed because a required header is missing. Make sure that all necessary authentication headers are being sent.

Unauthorized Access Token

The value sent as Access Token is incorrect. Please check and try again with the correct value.

402Processing error

payment_method_not_approved

Request failed because the payment for the payment method verification was not approved. Verify that the payment information is valid and sufficient to complete the transaction or use a different payment method.

404Error

resource_not_found

Request failed because the payment profile was not found. Verify that the payment profile ID, customer ID and caller ID are correct.

429Error

Too Many Requests

Request failed because the request rate has been exceeded. Reduce the frequency or implement a retry system with exponential backoff.

500Error

internal_server_error

Request failed due to an internal server error. Please try again later and, if the problem persists, contact Support with error details.

Request
curl -X POST \
    'https://api.mercadopago.com/v1/customers/{customer_id}/payment-profiles/{payment_profile_id}/payment-methods'\
    -H 'Content-Type: application/json' \
       -H 'Authorization: Bearer APP_USR-4*********994754-12*********c73b4e1ac*********cef36b27c*********840' \
       -H 'X-Idempotency-Key: e25e9e95-ad95-4475-bdbd-aa2babb54548' \
    -d '{
  "id": "visa",
  "type": "credit_card",
  "token": "12345",
  "default_method": false
}'
Response
{
  "payment_method_id": "64abf0f5-3e15-48a5-9be0-a8ac56bbd87a",
  "id": "visa",
  "type": "credit_card",
  "card_id": 1234567890,
  "status": "READY",
  "default_method": true
}