Programmatically create coupon code in Stripe

I need to create over a 1000 coupon codes in my Stripe account so that customers can redeem the discount at my site. I don’t want to do this manually through the dashboard or else I’ll go crazy.

I have not been able to find instructions in STRIPE documentation to create coupon codes programmatically or through a REST client.

Does anyone know if this is possible using the Stripe api. Could you provide an example if you gotten this to work?

Thank you in advance.


It’s definitely possible using the Create Coupon API. You’d be able to use their Java library to create all those in a loop. Here’s a basic example taken from the documentation that creates a 25% off coupon for 3 months:

Stripe.apiKey = "sk_test_XXX";

Map<String, Object> couponParams = new HashMap<String, Object>();
couponParams.put("percent_off", 25);
couponParams.put("duration", "repeating");
couponParams.put("duration_in_months", 3);
couponParams.put("id", "25OFF");


Leave a Reply

Your email address will not be published. Required fields are marked *