Purchase credits
Create a Stripe Checkout session for a one-time credit top-up. Top-ups persist beyond the monthly reset.
curl -X POST https://api.chuger.com/v1/credits/purchase \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"credits": 1000}'
const res = await fetch('https://api.chuger.com/v1/credits/purchase', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHUGER_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ credits: 1000 }),
});
const { checkout_url } = await res.json();
window.location.href = checkout_url;
{
"checkout_url": "https://checkout.stripe.com/c/pay/cs_test_...",
"session_id": "cs_test_..."
}
{
"message": "The credits must be at least 100.",
"errors": {
"credits": ["The credits must be at least 100."]
}
}
Creates a Stripe Checkout session for a one-time credit top-up. The response includes a checkout_url that your user must visit to complete payment. Once paid, the purchased credits are added to your balance and persist beyond the monthly reset — they don't expire at month end.
POST https://api.chuger.com/v1/credits/purchase
All /v1/credits/* endpoints are free to call and not subject to per-minute rate limits. The credits aren't deducted from your balance until payment completes.
Authentication
Bearer token in the Authorization header. See Authentication.
Request body
Content-Type: application/json
Number of credits to purchase. Integer between 100 and 10,000 per call.
Example
Redirect your user to checkout_url. After the payment completes the purchased credits are added to the account balance — they sit on top of your monthly allowance and persist across monthly resets.
Response fields
Stripe-hosted checkout page. Redirect your user here.
Stripe Checkout session identifier. Useful for reconciliation in your own systems.
Errors
| Status | When |
|---|---|
401 | Missing or invalid token |
422 | credits missing, not an integer, or outside the 100–10,000 range |
See Errors for the full reference.