Skip to main content

POST /credits/checkout

This endpoint creates a Stripe checkout session to allow a user to purchase a credit package. This is an authenticated endpoint.

Request Body

packageId
string
required
The ID of the credit package to purchase.
successUrl
string
required
The URL to redirect to after a successful purchase.
cancelUrl
string
required
The URL to redirect to if the purchase is canceled.

Response

sessionId
string
The ID of the Stripe checkout session. This can be used to redirect the user to the checkout page.
url
string
The URL of the Stripe checkout page.
curl -X POST https://api.llmgenerator.com/api/v1/credits/checkout \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "packageId": "pkg_xxxxxxxx",
        "successUrl": "https://example.com/success",
        "cancelUrl": "https://example.com/cancel"
      }'
{
  "sessionId": "cs_xxxxxxxxxxxxxxx",
  "url": "https://checkout.stripe.com/c/pay/cs_xxxxxxxxxxxxxxx"
}