Create a subscription (Checkout)
Creates a new subscription linked to a plan.
Payment Method Options:
- Use
cardTokenIdto reference an existing, active card - Use
paymentMethodto register a new card with this subscription
Card Validation Flow (when using paymentMethod):
- If
validateCard: true(default): A small test charge (e.g., R$ 1.50) is made to the card. The customer must check their card statement and callPOST /v1/cards/{cardTokenId}/activatewith the exact value. After activation, pending subscriptions using that card will have their first charge processed automatically. - If
validateCard: false: The card is used immediately and the first charge is processed.
Using an existing card (cardTokenId):
- The card must be active (not pending activation)
- The first charge is processed immediately
Authorizations
HTTP Basic authentication. Use your secret key as the username and an empty string as password. The API key should be base64 encoded in the format 'username:' when sending the Authorization header.
Body
Subscription plan ID
"2RhQg9M7ZCg3X3nMb9W1kX8Q"
Billing day of the month (1-28)
1 <= x <= 2815
Existing customer ID. Use this OR customer object, not both.
"2RhQg9M7ZCg3X3nMb9W1kX8Q"
Customer data. Use this OR customerId, not both. If provided, will search by email or create a new customer.
Existing card token ID. Use this to create a subscription with a previously registered card. The card must be active (not pending activation). Use this OR paymentMethod, not both.
"2RhQg9M7ZCg3X3nMb9W1kX8Q"
Card data for new card registration. Use this OR cardTokenId, not both.
Whether to validate the card before activating the subscription.
When true (default):
- A small test transaction (up to R$ 2.00) is made on the card
- The subscription is created with status
pending_card_activation - The customer must verify the transaction amount on their card statement
- Use
/cards/{cardTokenId}/activateendpoint to activate the card - After successful activation, the test amount is refunded and the first subscription charge is processed
When false:
- Card is not validated, increasing risk of declined transactions
- First charge is processed immediately
- Subscription becomes
activeif charge succeeds
true
When true, skips the trial period (if the plan has one) and
starts billing immediately. Default is false.
false
Additional metadata
{ "referralCode": "PROMO2024" }Response
Subscription successfully created
Unique subscription identifier
"2RhQg9M7ZCg3X3nMb9W1kX8Q"
Subscription status:
active: Subscription is active and billing normallypending_activation: First charge failed, awaiting retrypending_card_activation: Card requires validation (when validateCard=true)
active, pending_activation, pending_card_activation "active"
Token ID of the registered card (used for card activation)
"2RhQg9M7ZCg3X3nMb9W1kX8Q"
Current billing period start
"2024-01-15T10:30:00.000Z"
Current billing period end
"2024-02-15T10:30:00.000Z"
Billing day of the month
15
Card activation info (only present when validateCard=true)
First charge result (only present when validateCard=false)