Skip to main content
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..."
}
Create a checkout session to purchase credits. Returns a Stripe checkout URL where the user completes payment.

Request Body

amount
string
required
Credit amount to purchase. Either a preset value (small, medium, large) or a number between 10 and 1000.Preset values:
  • small = $20
  • medium = $50
  • large = $100
success_url
string
required
URL to redirect to after successful payment
cancel_url
string
required
URL to redirect to if user cancels checkout

Response

sessionId
string
Stripe checkout session ID
url
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..."
}

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 10and10 and 1,000