You can use the PriceRule DiscountCode resource to create discount codes that enable specific discounts to be redeemed. Merchants can distribute discount codes to their customers using a variety of means, such as an email or URL, and customers can apply these codes at checkout.
Each discount code belongs to a price rule, which holds the logic for the discount. For more information, see the PriceRule resource.
To create multiple discount codes that use the same price rule logic, use the batch endpoint. For example, you might allow merchants to create a batch of discount codes that belong to the same price rule but are each personalized for a different customer.
What you can do with DiscountCode
The Shopify API lets you do the following with the DiscountCode resource. More detailed versions of these general actions may be available: