Crear suscripción - Suscripciones - Mercado Pago Developers
Crear suscripción

POST

/preapproval
Una suscripción es la unión entre un plan y un cliente. La principal característica de este contrato es que tiene configurada una forma de pago y es la base para la creación de las facturas. También puedes crear una suscripción sin un plan.
Parámetros para la solicitud
auto_recurring
object
Localización: bodyDatos de configuración para recurrencia. Solo se requiere para suscripciones sin plan asociado.
back_url

REQUERIDO

string
Localización: bodyURL de retorno exitosa. Usa esta configuración para redirigir a tus clientes a tu sitio después de nuestro checkout. Solo se requiere para suscripciones sin plan asociado.
card_token_id
string
Localización: bodyIdentificador único de card token
external_reference
string
Localización: bodyReferencia para sincronizar con tu sistema. Este es un campo de texto libre para ayudarte con tu integración, para vincular las entidades. Solo se requiere para suscripciones sin plan asociado.
Parámetros de respuesta
id
string
Localización: bodyIdentificador único de suscripción.
version
number
Localización: bodyCantidad de veces que esta suscripción fue modificada.
application_id
number
Localización: bodyID único que identifica tu aplicación/integración. Una de las claves del par que componen las credenciales que identifican una aplicación/integración en tu cuenta.
collector_id
number
Localización: bodyID único que identifica a tu usuario como vendedor. Este ID coincide con tu User ID en nuestro ecosistema.
Solicitud
curl
curl -X POST \
    'https://api.mercadopago.com/preapproval' \
    -H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
    -H 'Content-Type: application/json' \
    -d '{
  "preapproval_plan_id": "2c938084726fca480172750000000000",
  "reason": "Yoga classes",
  "external_reference": "YG-1234",
  "payer_email": "test_user@testuser.com",
  "card_token_id": "e3ed6f098462036dd2cbabe314b9de2a",
  "auto_recurring": {
    "frequency": 1,
    "frequency_type": "months",
    "start_date": "2020-06-02T13:07:14.260Z",
    "end_date": "2022-07-20T15:59:52.581Z",
    "transaction_amount": 10,
    "currency_id": "ARS"
  },
  "back_url": "https://www.mercadopago.com.ar",
  "status": "authorized"
}'
Respuesta
json
{
  "id": "2c938084726fca480172750000000000",
  "version": 0,
  "application_id": 1234567812345678,
  "collector_id": 100200300,
  "preapproval_plan_id": "2c938084726fca480172750000000000",
  "reason": "Yoga classes.",
  "external_reference": 23546246234,
  "back_url": "https://www.mercadopago.com.ar",
  "init_point": "https://www.mercadopago.com.ar/subscriptions/checkout?preapproval_id=2c938084726fca480172750000000000",
  "auto_recurring": {
    "frequency": 1,
    "frequency_type": "months",
    "start_date": "2020-06-02T13:07:14.260Z",
    "end_date": "2022-07-20T15:59:52.581Z",
    "currency_id": "ARS",
    "transaction_amount": 10,
    "free_trial": {
      "frequency": 1,
      "frequency_type": "months"
    }
  },
  "payer_id": 123123123,
  "card_id": 123123123,
  "payment_method_id": 123123123,
  "next_payment_date": "2022-01-01T11:12:25.892-04:00",
  "date_created": "2022-01-01T11:12:25.892-04:00",
  "last_modified": "2022-01-01T11:12:25.892-04:00",
  "status": "pending"
}
Errores
400bad_request
400400--Bad-Request--Subscriptions are not available for this country yet
400400--Bad-Request--The payment method account money is not available in your country
400400--Bad-Request--Collector and Application cannot be from different countries
400400--Bad-Request--Field card_token_id is required
400400--Bad-Request--Field payer_email is required
400400--Bad-Request--Invalid value for payer_email, must be a valid email address
400400--Bad-Request--Invalid value for transaction amount, must be a positive number
400400--Bad-Request--Invalid value for transaction amount, only two decimals are allowed
400400--Bad-Request--Invalid value for auto_recurring.currency_id
400400--Bad-Request--Invalid value for auto_recurring.end_date, the date must be after today
400400--Bad-Request--Invalid value for auto_recurring.frequency, must be a positive integer
400400--Bad-Request--Invalid value for auto_recurring.frequency_type, valid ones are days, months
400400--Bad-Request--Invalid value for auto_recurring.start_date, the date must be after today
400400--Bad-Request--Invalid format in auto_recurring.start_date or auto_recurring.end_date
400400--Bad-Request--Invalid value for back_url, must be a valid URL
400400--Bad-Request--Field reason has more than 255 characters
400400--Bad-Request--Field reason has unsupported characters
400400--Bad-Request--Field auto_recurring.frequency is required
400400--Bad-Request--Field auto_recurring.frequency_type is required
400400--Bad-Request--Field auto_recurring.transaction_amount is required
400400--Bad-Request--Field auto_recurring.currency_id is required
400400--Bad-Request--Field auto_recurring.end_date must be after auto_recurring.start_date
400400--Bad-Request--Field external_reference has more than 255 characters
400400--Bad-Request--Field external_reference has unsupported characters
400400--Bad-Request--Already exists a preapproval for user <payer_email> and application <application_id>
400400--Bad-Request--Payer and collector cannot be the same user
400400--Bad-Request--Both payer and collector must be real or test users
400400--Bad-Request--This preapproval cannot be created. The seller does not accept account_money
400400--Bad-Request--This preapproval cannot be created only with payment method account_money
400400--Bad-Request--Cannot operate between different countries
400400--Bad-Request--Cannot create preapproval pending, the feature with account money is disabled for your country.
400400--Bad-Request--Cannot pay an amount lower than min
400400--Bad-Request--Cannot pay an amount greater than max
400400--Bad-Request--You cannot create a preapproval with payment_method in status pending
400400--Bad-Request--You cannot create a new preapproval from a cancelled or inactive template
400400--Bad-Request--The transaction_amount must be the same as preapproval_plan
400400--Bad-Request--Card token was used, please generate new
400400--Bad-Request--Card token was generated without cvv validation
400400--Bad-Request--Invalid request data
401bad_request
401401--Unauthorized--CC_VAL_433 Credit card validation has failed
401401--Unauthorized--Verification of collectors personal data is in process, come back later
401401--Unauthorized--Unauthorized access to resource
401401--Unauthorized--This app cannot create subscriptions without a plan
403bad_request
403403--Forbidden--The collector does not meet the personal data verification requirements
403403--Forbidden--The caller is not authorized to access this resource
403403--Forbidden--Unauthorized seller for this feature AM_VAL_01
500bad_request
500500--Error--Internal server error