Create unique discount codes with limited validity (duration)

Topic summary

A user needs to generate multiple discount codes sharing identical attributes (value, products, allocation method, limits) but with different validity periods—specifically 7 days from each code’s creation date.

Challenge identified:

  • Both the Price Rule API and Discount API lack straightforward methods to achieve this requirement
  • The user explored official Shopify API documentation but found no simple solution

Potential workaround considered:

  • Create a new price rule daily with the end_date set 7 days into the future
  • Use that day’s price rule for generating discount codes
  • However, this approach seems unnecessarily complex and inefficient

Current status:

  • The discussion remains open with no resolution
  • The user is seeking better ideas or alternative approaches from the community
Summarized with AI on November 11. AI used: claude-sonnet-4-5-20250929.

Hi! We would like to generate many discounts codes that have identical attributes (e.g. value, entitled products, allocation method, limits etc.) but different valid dates. The validity should be 7 days, starting with the date of the creation of the code.

I checked both the price rule APIs as well as the discount APIs, but could find no easy way to do this.
https://shopify.dev/docs/api/admin-rest/2024-01/resources/pricerule

https://shopify.dev/docs/api/admin-rest/2024-01/resources/discountcode

The only thing that I could imagine is use a new price rule every day - that is create a new price rule every day, set the “end_at” date 7 days in the future, and use the new price rule for creating discounts on that day. But that seems needlessly complex.

Does anyone have a better idea?

Thanks in advance
Best.