The REST Admin API is a legacy API as of October 1, 2024. All apps and integrations should be built with the GraphQL Admin API. For details and migration steps, visit our migration guide.
price_rules
access scope.
Note
We recommend using the GraphQL Admin API to manage discounts. The Discount types
available in the GraphQL Admin API are intended to replace the GraphQL Admin PriceRule
object and REST Admin PriceRule
and DiscountCode
resources.
You can use the PriceRule resource to create discounts using conditions. You can then associate the conditions with a discount code by using the DiscountCode resource. Merchants can distribute the discount codes to their customers.
Using the PriceRule resource, you can create discounts that specify a discount as a percentage, a fixed amount, or free shipping. You use entitlements and prerequisites to dynamically build these discounts.
To learn about how to associate a price rule with a discount code, see the DiscountCode resource.
Create a price rule
You can create price rules with entitlements and prerequisites. Entitlements describe the designated resources that a discount applies to, such as specific products, variants, or collections. Prerequisites describe the requirements that must be met in order for the discount to apply to the entitled resources. For example, you might want a discount to apply only to a certain shipping price range, or a certain subtotal range.
You can use entitlements, prereqisites, and other conditions to create discounts, such as the following examples:
- $10 off the buyer's order if the total exceeds $40
- 15% off certain collections
- free shipping on orders over $100.00 for Canadian buyers, redeemable up to 20 times
For examples of how to create price rules, see the POST method.
The allocation method of the price rule. Valid values:
The date and time (ISO 8601 format) when the price rule was created.
The date and time (ISO 8601 format) when the price rule was updated.
The customer selection for the price rule. Valid values:
The date and time (ISO 8601 format) when the price rule ends. Must be after starts_at
.
A list of IDs of collections whose products will be eligible to the discount. It can be used only with
target_type
set to line_item
and target_selection
set to entitled
.
It can't be used in combination with entitled_product_ids
or entitled_variant_ids
.
A list of IDs of shipping countries that will be entitled to the discount. It can be used only with target_type
set to shipping_line
and target_selection
set to entitled
.
A list of IDs of products that will be entitled to the discount. It can be used only with target_type
set to line_item
and target_selection
set to entitled
.
If a product variant is included in entitled_variant_ids
, then entitled_product_ids
can't include the ID of the product associated with that variant.
A list of IDs of product variants that will be entitled to the discount. It can be used only with target_type
set to line_item
and target_selection
set to entitled
.
If a product is included in entitled_product_ids
, then entitled_variant_ids
can't include the ID of any variants associated with that product.
Whether the generated discount code will be valid only for a single use per customer. This is tracked using customer ID.
A list of customer IDs. For the price rule to be applicable, the customer must match one of the specified customers.
If prerequisite_customer_ids
is populated, then customer_segment_prerequisite_ids
must be empty.