import { CommuneClient } from 'commune-ai';
const commune = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY });
const checkout = await commune.credits.purchase({
bundleId: 'growth',
success_url: 'https://your-app.com/billing?credits=success',
cancel_url: 'https://your-app.com/billing',
});
// Redirect your user to this URL
console.log(checkout.checkout_url);
console.log(`Purchasing ${checkout.credits} credits for $${checkout.price}`);
from commune import CommuneClient
client = CommuneClient()
checkout = client.credits.purchase(
bundle_id="growth",
success_url="https://your-app.com/billing?credits=success",
cancel_url="https://your-app.com/billing",
)
# Redirect your user to this URL
print(checkout.checkout_url)
print(f"Purchasing {checkout.credits} credits for ${checkout.price}")
purchase_credits(bundle_id="growth")
curl -X POST https://api.commune.email/v1/credits/checkout \
-H "Authorization: Bearer comm_..." \
-H "Content-Type: application/json" \
-d '{
"bundle": "growth",
"success_url": "https://your-app.com/billing?credits=success",
"cancel_url": "https://your-app.com/billing"
}'
commune credits purchase --bundle-id growth
{
"data": {
"checkout_url": "https://checkout.stripe.com/pay/cs_live_abc123...",
"bundle": "growth",
"credits": 5000,
"price": 55
}
}
{
"error": "Invalid request",
"details": {
"fieldErrors": {
"bundle": ["Invalid enum value. Expected 'starter' | 'growth' | 'scale'"]
}
}
}
{
"error": "credit_bundles_not_configured",
"message": "Credit purchase is not yet configured. Contact support."
}
Credits
Purchase Credits
Create a Stripe Checkout session to purchase a credit bundle. Returns a checkout URL — redirect your user to complete the payment.
POST
/
v1
/
credits
/
checkout
import { CommuneClient } from 'commune-ai';
const commune = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY });
const checkout = await commune.credits.purchase({
bundleId: 'growth',
success_url: 'https://your-app.com/billing?credits=success',
cancel_url: 'https://your-app.com/billing',
});
// Redirect your user to this URL
console.log(checkout.checkout_url);
console.log(`Purchasing ${checkout.credits} credits for $${checkout.price}`);
from commune import CommuneClient
client = CommuneClient()
checkout = client.credits.purchase(
bundle_id="growth",
success_url="https://your-app.com/billing?credits=success",
cancel_url="https://your-app.com/billing",
)
# Redirect your user to this URL
print(checkout.checkout_url)
print(f"Purchasing {checkout.credits} credits for ${checkout.price}")
purchase_credits(bundle_id="growth")
curl -X POST https://api.commune.email/v1/credits/checkout \
-H "Authorization: Bearer comm_..." \
-H "Content-Type: application/json" \
-d '{
"bundle": "growth",
"success_url": "https://your-app.com/billing?credits=success",
"cancel_url": "https://your-app.com/billing"
}'
commune credits purchase --bundle-id growth
{
"data": {
"checkout_url": "https://checkout.stripe.com/pay/cs_live_abc123...",
"bundle": "growth",
"credits": 5000,
"price": 55
}
}
{
"error": "Invalid request",
"details": {
"fieldErrors": {
"bundle": ["Invalid enum value. Expected 'starter' | 'growth' | 'scale'"]
}
}
}
{
"error": "credit_bundles_not_configured",
"message": "Credit purchase is not yet configured. Contact support."
}
import { CommuneClient } from 'commune-ai';
const commune = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY });
const checkout = await commune.credits.purchase({
bundleId: 'growth',
success_url: 'https://your-app.com/billing?credits=success',
cancel_url: 'https://your-app.com/billing',
});
// Redirect your user to this URL
console.log(checkout.checkout_url);
console.log(`Purchasing ${checkout.credits} credits for $${checkout.price}`);
from commune import CommuneClient
client = CommuneClient()
checkout = client.credits.purchase(
bundle_id="growth",
success_url="https://your-app.com/billing?credits=success",
cancel_url="https://your-app.com/billing",
)
# Redirect your user to this URL
print(checkout.checkout_url)
print(f"Purchasing {checkout.credits} credits for ${checkout.price}")
purchase_credits(bundle_id="growth")
curl -X POST https://api.commune.email/v1/credits/checkout \
-H "Authorization: Bearer comm_..." \
-H "Content-Type: application/json" \
-d '{
"bundle": "growth",
"success_url": "https://your-app.com/billing?credits=success",
"cancel_url": "https://your-app.com/billing"
}'
commune credits purchase --bundle-id growth
{
"data": {
"checkout_url": "https://checkout.stripe.com/pay/cs_live_abc123...",
"bundle": "growth",
"credits": 5000,
"price": 55
}
}
{
"error": "Invalid request",
"details": {
"fieldErrors": {
"bundle": ["Invalid enum value. Expected 'starter' | 'growth' | 'scale'"]
}
}
}
{
"error": "credit_bundles_not_configured",
"message": "Credit purchase is not yet configured. Contact support."
}
Body
string
required
The bundle ID to purchase. One of:
starter, growth, scale. Get bundle details and pricing from GET /v1/credits/bundles.string
URL to redirect the user to after a successful payment. Defaults to your Commune dashboard billing page.
string
URL to redirect the user to if they cancel the checkout. Defaults to your Commune dashboard billing page.
Response
object
Credits are added to your account automatically via Stripe webhook after payment is confirmed. There is typically a 1–3 second delay between payment completion and credits appearing in your balance.Purchased credits roll over indefinitely and do not expire. They are drawn from after your included plan credits are exhausted.
Last modified on March 19, 2026
Was this page helpful?

