curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/checkout \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"planId": "professional",
"successUrl": "https://yourapp.com/subscription/success",
"cancelUrl": "https://yourapp.com/pricing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/checkout', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
planId: 'professional',
successUrl: 'https://yourapp.com/subscription/success',
cancelUrl: 'https://yourapp.com/pricing'
})
});
const data = await response.json();
// Redirect user to Stripe checkout
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/checkout',
headers={
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
json={
'planId': 'professional',
'successUrl': 'https://yourapp.com/subscription/success',
'cancelUrl': 'https://yourapp.com/pricing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
{
"sessionId": "cs_test_a1b2c3d4e5f6g7h8i9j0",
"url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3d4...",
"plan": {
"id": "professional",
"name": "Professional",
"monthlyCredits": 3000,
"priceCents": 1299
}
}
Subscriptions
Create Subscription Checkout
Create a Stripe checkout session for subscribing to a plan.
POST
/
subscriptions
/
checkout
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/checkout \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"planId": "professional",
"successUrl": "https://yourapp.com/subscription/success",
"cancelUrl": "https://yourapp.com/pricing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/checkout', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
planId: 'professional',
successUrl: 'https://yourapp.com/subscription/success',
cancelUrl: 'https://yourapp.com/pricing'
})
});
const data = await response.json();
// Redirect user to Stripe checkout
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/checkout',
headers={
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
json={
'planId': 'professional',
'successUrl': 'https://yourapp.com/subscription/success',
'cancelUrl': 'https://yourapp.com/pricing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
{
"sessionId": "cs_test_a1b2c3d4e5f6g7h8i9j0",
"url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3d4...",
"plan": {
"id": "professional",
"name": "Professional",
"monthlyCredits": 3000,
"priceCents": 1299
}
}
Overview
Creates a Stripe checkout session for subscribing to a plan. Returns a URL where you should redirect the user to complete the payment. Requires session-based authentication (JWT access token).For third-party integrations: Use
POST /subscriptions/checkout/api with API Key authentication instead.Authentication
string
required
Your JWT access token. Format:
Bearer YOUR_ACCESS_TOKENRequest Body
string
required
The plan identifier to subscribe to. Must be one of:
starter, professional, business, or agency.string
default:"monthly"
Billing frequency. Options:
monthly or yearly.string
URL to redirect to after successful payment. Defaults to application dashboard.
string
URL to redirect to if user cancels payment. Defaults to pricing page.
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/checkout \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"planId": "professional",
"successUrl": "https://yourapp.com/subscription/success",
"cancelUrl": "https://yourapp.com/pricing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/checkout', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
planId: 'professional',
successUrl: 'https://yourapp.com/subscription/success',
cancelUrl: 'https://yourapp.com/pricing'
})
});
const data = await response.json();
// Redirect user to Stripe checkout
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/checkout',
headers={
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json'
},
json={
'planId': 'professional',
'successUrl': 'https://yourapp.com/subscription/success',
'cancelUrl': 'https://yourapp.com/pricing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
{
"sessionId": "cs_test_a1b2c3d4e5f6g7h8i9j0",
"url": "https://checkout.stripe.com/c/pay/cs_test_a1b2c3d4...",
"plan": {
"id": "professional",
"name": "Professional",
"monthlyCredits": 3000,
"priceCents": 1299
}
}
Response Fields
string
Stripe checkout session ID. Can be used to verify the session later.
string
URL to redirect the user to for payment. This is a Stripe-hosted checkout page.
object
Details of the selected plan.
Checkout Flow
- Create session: Call this endpoint with the desired plan
- Redirect user: Send user to the returned
url - Payment processing: User completes payment on Stripe
- Webhook: Stripe notifies your webhook endpoint
- Success redirect: User is redirected to
successUrl - Verify (optional): Check subscription status via
/subscriptions/current
Error Responses
Bad Request - Invalid plan ID or user already has an active subscription.
Unauthorized - Invalid or missing token.
If the user already has an active subscription, they should use the billing portal (
/subscriptions/portal) to change plans instead.POST /subscriptions/checkout/api
Creates a Stripe checkout session using API Key authentication. Ideal for third-party integrations.Authentication
Requires API Key authentication. Include your API key in theAuthorization header:
Authorization: Bearer llmgen_your_api_key_here
Request Body
Same as/subscriptions/checkout above.
Response
Same as/subscriptions/checkout above.
curl -X POST https://api.llmgenerator.com/api/v1/subscriptions/checkout/api \
-H "Authorization: Bearer llmgen_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"planId": "professional",
"successUrl": "https://yourapp.com/subscription/success",
"cancelUrl": "https://yourapp.com/pricing"
}'
const response = await fetch('https://api.llmgenerator.com/api/v1/subscriptions/checkout/api', {
method: 'POST',
headers: {
'Authorization': 'Bearer llmgen_your_api_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
planId: 'professional',
successUrl: 'https://yourapp.com/subscription/success',
cancelUrl: 'https://yourapp.com/pricing'
})
});
const data = await response.json();
// Redirect user to Stripe checkout
window.location.href = data.url;
import requests
response = requests.post(
'https://api.llmgenerator.com/api/v1/subscriptions/checkout/api',
headers={
'Authorization': 'Bearer llmgen_your_api_key_here',
'Content-Type': 'application/json'
},
json={
'planId': 'professional',
'successUrl': 'https://yourapp.com/subscription/success',
'cancelUrl': 'https://yourapp.com/pricing'
}
)
data = response.json()
print(f"Redirect to: {data['url']}")
Was this page helpful?
⌘I