What is the best way to generate big batch of discount codes every day?

What is the best way to generate big batch of discount codes every day?

1 0 0

I want to generate discount codes in our shop every day, on average 24,000 codes every day. 


I see there's a discount code creation job endpoint https://shopify.dev/docs/api/admin-rest/2024-01/resources/discountcode#post-price-rules-price-rule-i... but it only allows for 100 codes per job and only allows for 1 job simultaneously. I was thinking to generate the codes in these 100 code batches, but the job requires polling to check that the codes are successfully created. I'm afraid this will eat in to our API limits. 


What's the best way to generate 24k codes every day in an efficient manner without crossing the API rate limiting thresholds?




Reply 1 (1)

Shopify Staff
2862 312 813

Hi Tamang4,


Are the discounts all for the same value/ have the same rules? If so, it would likely be easier/ more efficient to use the `discountRedeemCodeBulkAdd` mutation instead? This allows you to asynchronously add multiple discount redeem codes in bulk that are associated with a single discount ID. Would recommend seeing if this suits your use case. 



Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog