Duplicate existing DiscountCode with Shopify Admin REST API

Hi everyone!

I’m working on a Private App that would allow the merchants to create Discount Codes automatically using the Admin REST API.

We are migrating from a different ecommerce platform which had the possibility to duplicate existing discount codes and this allowed the merchants to fine-tune a single discount and then the app would just duplicate whatever setup was made to it.

The REST API specs does not mention any duplicate operation but I saw this link containing a reference for duplicating discount codes on the Mobile App.

https://help.shopify.com/en/manual/discounts/create-discount-codes#duplicate-a-discount-on-a-mobile-device

Is there any way to achieve this programmatically ?

So far, the strategy that I’m thinking of is creating this “Reference Discount” and grab its parameters manually and create new PriceRules+DiscountCode based on these values. Of course, this would take at least 3 operations, 1 read and 2 writes.

Can you think of a better way to achieve this? is there a duplicate discount API service?

Thanks in advance for taking your time to read this message. :slightly_smiling_face: