Skip to main content

POST /api/subscription/create-checkout

Creates a Stripe Checkout session to upgrade or subscribe to a paid plan (BASIC or PRO). Returns a session ID and URL to redirect the user to complete payment.

Authentication

This endpoint requires authentication. Include your access token in the request cookies.

Request Body

string
required
Plan to subscribe to. Options: BASIC, PRO
string
Promotional code for discounts (3-50 characters). Will be converted to uppercase
string
default:"monthly"
Billing period. Options: monthly, annual

Response

string
required
Stripe Checkout session ID
string
required
URL to redirect the user to complete the checkout process
string
required
Success message

Example Request

Example Response

Usage Flow

  1. Call this endpoint to create a checkout session
  2. Redirect the user to the returned url
  3. User completes payment on Stripe’s hosted checkout page
  4. User is redirected back to your success URL
  5. Stripe webhook updates the subscription status

Error Responses

error
Authentication required or token expired
error
Invalid request parameters
error
User already has an active subscription to the requested plan
error
Server or Stripe error occurred
The checkout session expires after 24 hours. Users must complete payment within this timeframe.
For annual billing, consider displaying the discount percentage to encourage upgrades.