Shopify API Discount Codes

I have an employee management system that is external and not connected to Shopify.

My clients have requested a new feature and I’m trying to figure out if it’s possible.

When adding a new member to their account on my site they would like to create a discount code for that member. When the code is entered on my site it should automatically create that code in their Shopify account.

is this possible?

Hello @GrJohn ,

Welcome to Shopify Community!

Yes, it is possible to automatically create a discount code in a Shopify store using the Shopify API. Here is an overview of how you can do this:

  1. First, you will need to create a private app in your Shopify store to access the API. To do this, go to “Apps” in the Shopify admin, and click on “Manage private apps”. Then, click on “Create a new private app” and follow the prompts to set up the app. Make sure to give the app the necessary permissions to create discount codes.

  2. Next, you will need to use the Shopify API to create a discount code in your store. You can do this by making a POST request to the /admin/api/2022-10/price_rules/507328175/discount_codes.json endpoint, passing in the necessary parameters in the request body. For example:

  3. In your employee management system, you can then create a function that makes the API request to create the discount code when a new member is added to the system.

Find more about API here : https://shopify.dev/api/admin-rest/2022-10/resources/discountcode#top

I hope this helps! Let me know if you have any questions.

1 Like

Thanks for the great response! Each of my clients will have their own stores so I am assuming we could associate the private app in each of their stores to their account with us using the api?