curl -X POST "https://api.magpipe.ai/functions/v1/stripe-add-credits" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": "50",
"success_url": "https://yourapp.com/billing?success=true",
"cancel_url": "https://yourapp.com/billing?canceled=true"
}'
{
"sessionId": "cs_live_a1b2c3d4e5f6g7h8i9j0",
"url": "https://checkout.stripe.com/c/pay/cs_live_a1b2c3..."
}
{
"error": "Invalid amount. Must be between 10 and 1000 or a preset value."
}
Billing
Purchase Credits
Create a Stripe checkout session to purchase credits
POST
/
stripe-add-credits
curl -X POST "https://api.magpipe.ai/functions/v1/stripe-add-credits" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": "50",
"success_url": "https://yourapp.com/billing?success=true",
"cancel_url": "https://yourapp.com/billing?canceled=true"
}'
{
"sessionId": "cs_live_a1b2c3d4e5f6g7h8i9j0",
"url": "https://checkout.stripe.com/c/pay/cs_live_a1b2c3..."
}
{
"error": "Invalid amount. Must be between 10 and 1000 or a preset value."
}
Create a checkout session to purchase credits. Returns a Stripe checkout URL where the user completes payment.
Request Body
string
required
Credit amount to purchase. Either a preset value (
small, medium, large) or a number between 10 and 1000.Preset values:small= $20medium= $50large= $100
string
required
URL to redirect to after successful payment
string
required
URL to redirect to if user cancels checkout
Response
string
Stripe checkout session ID
string
Stripe checkout URL - redirect user here to complete payment
curl -X POST "https://api.magpipe.ai/functions/v1/stripe-add-credits" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"amount": "50",
"success_url": "https://yourapp.com/billing?success=true",
"cancel_url": "https://yourapp.com/billing?canceled=true"
}'
{
"sessionId": "cs_live_a1b2c3d4e5f6g7h8i9j0",
"url": "https://checkout.stripe.com/c/pay/cs_live_a1b2c3..."
}
{
"error": "Invalid amount. Must be between 10 and 1000 or a preset value."
}
Notes
- Credits are added to the account immediately after successful payment
- The Stripe webhook handles the fulfillment automatically
- Use presets (
small,medium,large) for common amounts - Custom amounts must be between 10and1,000