--- title: PriceRule description: >- Create the logic for a discount, and then use the DiscountCode API to associate a code with the discount so it can be applied at checkout. api_version: 2024-10 api_name: admin_rest api_type: rest source_url: html: 'https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule' md: 'https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt' --- ![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg) The REST Admin API is a legacy API as of October 1, 2024. Starting April 1, 2025, all new public apps must be built exclusively with the [GraphQL Admin API](https://shopify.dev/docs/api/admin-graphql). For details and migration steps, visit our [migration guide](https://shopify.dev/docs/apps/build/graphql/migrate). # Price​Rule Requires `price_rules` access scope. Note We recommend using the GraphQL Admin API to manage discounts. The [Discount types](https://shopify.dev/api/examples/discounts) 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](https://shopify.dev/docs/admin-api/rest/reference/discounts/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](https://shopify.dev/docs/admin-api/rest/reference/discounts/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](https://shopify.dev/docs/admin-api/rest/reference/discounts/pricerule/#create-{{%20current_version%20}}). \# ## Endpoints * [post](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#post-price-rules) [/admin/api/2024-10/price\_​rules.​json](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#post-price-rules) Creates a price rule [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBasicCreate) [discountCodeBasicCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBasicCreate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBasicCreate) [discountAutomaticBasicCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBasicCreate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBxgyCreate) [discountCodeBxgyCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBxgyCreate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBxgyCreate) [discountAutomaticBxgyCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBxgyCreate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeFreeShippingCreate) [discountCodeFreeShippingCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeFreeShippingCreate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticFreeShippingCreate) [discountAutomaticFreeShippingCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticFreeShippingCreate) * [get](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#get-price-rules) [/admin/api/2024-10/price\_​rules.​json](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#get-price-rules) Retrieves a list of price rules [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNodes) [discountNodes](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNodes) * [get](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#get-price-rules-price-rule-id) [/admin/api/2024-10/price\_​rules/{price\_​rule\_​id}.​json](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#get-price-rules-price-rule-id) Retrieves a single price rule [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNode) [discountNode](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNode) * [get](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#get-price-rules-count) [/admin/api/2024-10/price\_​rules/count.​json](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#get-price-rules-count) Retrieves a count of all price rules [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNodesCount?example=retrieves-a-count-of-all-price-rules) [discountNodesCount](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNodesCount?example=retrieves-a-count-of-all-price-rules) * [put](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#put-price-rules-price-rule-id) [/admin/api/2024-10/price\_​rules/{price\_​rule\_​id}.​json](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#put-price-rules-price-rule-id) Updates an existing a price rule [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBasicUpdate) [discountCodeBasicUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBasicUpdate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBasicUpdate) [discountAutomaticBasicUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBasicUpdate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBxgyUpdate) [discountCodeBxgyUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBxgyUpdate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBxgyUpdate) [discountAutomaticBxgyUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBxgyUpdate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeFreeShippingUpdate) [discountCodeFreeShippingUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeFreeShippingUpdate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticFreeShippingUpdate) [discountAutomaticFreeShippingUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticFreeShippingUpdate) * [del](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#delete-price-rules-price-rule-id) [/admin/api/2024-10/price\_​rules/{price\_​rule\_​id}.​json](https://shopify.dev/docs/api/admin-rest/2024-10/resources/pricerule.txt#delete-price-rules-price-rule-id) Remove an existing PriceRule [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeDelete) [discountCodeDelete](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeDelete) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticDelete?example=remove-an-existing-pricerule) [discountAutomaticDelete](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticDelete?example=remove-an-existing-pricerule) *** ## The PriceRule resource ### Properties *** allocation\_method deprecated The allocation method of the price rule. Valid values: Show allocation\_method properties * **each**: The discount is applied to each of the entitled items. For example, for a price rule that takes $15 off, each entitled line item in a checkout will be discounted by $15. * **across**: The calculated discount amount will be applied across the entitled items. For example, for a price rule that takes $15 off, the discount will be applied across all the entitled items. When the value of `target_type` is `shipping_line`, then this value must be `each`. *** created\_at read-only deprecated The date and time ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) when the price rule was created. *** updated\_at read-only deprecated The date and time ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) when the price rule was updated. *** customer\_selection deprecated The customer selection for the price rule. Valid values: Show customer\_selection properties * **all**: The price rule is valid for all customers. * **prerequisite**: The customer must either belong to one of the customer segments specified by `customer_segment_prerequisite_ids`, or be one of the customers specified by `prerequisite_customer_ids`. *** ends\_at deprecated The date and time ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) when the price rule ends. Must be after `starts_at`. *** entitled\_collection\_ids deprecated 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`. *** entitled\_country\_ids deprecated 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`. *** entitled\_product\_ids deprecated 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`. Caution 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. *** entitled\_variant\_ids deprecated 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`. Caution 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. *** id read-only deprecated The ID for the price rule. *** once\_per\_customer deprecated Whether the generated discount code will be valid only for a single use per customer. This is tracked using customer ID. *** prerequisite\_customer\_ids deprecated A list of customer IDs. For the price rule to be applicable, the customer must match one of the specified [customers](https://shopify.dev/docs/admin-api/rest/reference/customers/customer). If `prerequisite_customer_ids` is populated, then `customer_segment_prerequisite_ids` must be empty. *** {} ## The PriceRule resource ```json { "allocation_method": "each", "created_at": "2017-03-13T16:09:54-04:00", "updated_at": "2017-03-14T16:09:54-04:00", "customer_selection": "prerequisite", "ends_at": "2017-04-19T17:59:10Z", "entitled_collection_ids": [ 4564654869, 8979761006 ], "entitled_country_ids": { " entitled_country_ids": [ 7897987023, 3569053679 ] }, "entitled_product_ids": [ 7897397755, 42382368242 ], "entitled_variant_ids": [ 6798798798, 5675765905 ], "id": 9808080986, "once_per_customer": true, "prerequisite_customer_ids": [ 384028349005, 3492039843 ], "prerequisite_quantity_range": { "greater_than_or_equal_to": 2 }, "customer_segment_prerequisite_ids": [ 1122345432, 43535360314 ], "prerequisite_shipping_price_range": { "less_than_or_equal_to": "10.0" }, "prerequisite_subtotal_range": { "greater_than_or_equal_to": "40.0" }, "prerequisite_to_entitlement_purchase": { "prerequisite_amount": "80.00" }, "starts_at": "2017-01-19T17:59:10Z", "target_selection": "entitled", "target_type": "line_item", "title": "SUMMERSALE10OFF", "usage_limit": 10, "prerequisite_product_ids": [ 7897397755, 42382368242 ], "prerequisite_variant_ids": [ 6798798798, 5675765905 ], "prerequisite_collection_ids": [ 4564654869, 8979761006 ], "value": -35, "value_type": "fixed_amount", "prerequisite_to_entitlement_quantity_ratio": { "prerequisite_quantity": 2, "entitled_quantity": 1 }, "allocation_limit": 3 } ``` *** ## postCreates a price rule [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBasicCreate) [discountCodeBasicCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBasicCreate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBasicCreate) [discountAutomaticBasicCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBasicCreate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBxgyCreate) [discountCodeBxgyCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBxgyCreate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBxgyCreate) [discountAutomaticBxgyCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBxgyCreate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeFreeShippingCreate) [discountCodeFreeShippingCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeFreeShippingCreate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticFreeShippingCreate) [discountAutomaticFreeShippingCreate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticFreeShippingCreate) Creates a price rule ### Parameters *** api\_version string required *** ### Examples Create a Buy X Get Y price rule that gives one free ipod touch if customer buys 2 ipods Request body price\_​rule​ Price\_rule resource Show price\_rule properties price\_​rule.title:​"Buy2iPodsGetiPodTouchForFree" deprecated The title of the price rule. This is used by the Shopify admin search to retrieve discounts. It is also displayed on the **Discounts** page of the Shopify admin for bulk discounts. For non-bulk discounts, the discount code is displayed on the admin. Caution For a consistent search experience, use the same value for `title` as the `code` property of the associated discount code. price\_​rule.value\_​type:​"percentage" deprecated The value type of the price rule. Valid values: Show value\_type properties * **fixed\_amount**: Applies a discount of `value` as a unit of the store's currency. For example, if `value` is -30 and the store's currency is USD, then $30 USD is deducted when the discount is applied. * **percentage**: Applies a percentage discount of `value`. For example, if `value` is -30, then 30% will be deducted when the discount is applied. If `target_type` is `shipping_line`, then only `percentage` is accepted. price\_​rule.value:​"-100.0" deprecated The value of the price rule. If if the value of `target_type` is `shipping_line`, then only `-100` is accepted. The value must be negative. price\_​rule.customer\_​selection:​"all" deprecated The customer selection for the price rule. Valid values: Show customer\_selection properties * **all**: The price rule is valid for all customers. * **prerequisite**: The customer must either belong to one of the customer segments specified by `customer_segment_prerequisite_ids`, or be one of the customers specified by `prerequisite_customer_ids`. price\_​rule.target\_​type:​"line\_item" deprecated The target type that the price rule applies to. Valid values: Show target\_type properties * **line\_item**: The price rule applies to the cart's line items. * **shipping\_line**: The price rule applies to the cart's shipping lines. price\_​rule.target\_​selection:​"entitled" deprecated The target selection method of the price rule. Valid values: Show target\_selection properties * **all**: The price rule applies the discount to all line items in the checkout. * **entitled**: The price rule applies the discount to selected entitlements only. price\_​rule.allocation\_​method:​"each" deprecated The allocation method of the price rule. Valid values: Show allocation\_method properties * **each**: The discount is applied to each of the entitled items. For example, for a price rule that takes $15 off, each entitled line item in a checkout will be discounted by $15. * **across**: The calculated discount amount will be applied across the entitled items. For example, for a price rule that takes $15 off, the discount will be applied across all the entitled items. When the value of `target_type` is `shipping_line`, then this value must be `each`. price\_​rule.starts\_​at:​"2018-03-22T00:00:00-00:00" deprecated The date and time ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) when the price rule starts. price\_​rule.prerequisite\_​collection\_​ids:​\[841564295] deprecated List of collection ids that will be a prerequisites for a Buy X Get Y discount. The `entitled_collection_ids` can be used only with: Show prerequisite\_collection\_ids properties * `target_type` set to `line_item`, * `target_selection` set to `entitled`, * `allocation_method` set to `each` and * `prerequisite_to_entitlement_quantity_ratio` defined. Cannot be used in combination with `prerequisite_product_ids` or `prerequisite_variant_ids`. price\_​rule.entitled\_​product\_​ids:​\[921728736] deprecated 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`. Caution 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. price\_​rule.prerequisite\_​to\_​entitlement\_​quantity\_​ratio:​{"prerequisite\_quantity":2,​"entitled\_quantity":1} deprecated Buy/Get ratio for a Buy X Get Y discount. `prerequisite_quantity` defines the necessary 'buy' quantity and `entitled_quantity` the offered 'get' quantity. The `prerequisite_to_entitlement_quantity_ratio` can be used only with: Show prerequisite\_to\_entitlement\_quantity\_ratio properties * `value_type` set to `percentage`, * `target_type` set to `line_item`, * `target_selection` set to `entitled`, * `allocation_method` set to `each`, * `prerequisite_product_ids` or `prerequisite_variant_ids` or `prerequisite_collection_ids` defined and * `entitled_product_ids` or `entitled_variant_ids` or `entitled_collection_ids` defined. Caution Cannot be used in combination with `prerequisite_subtotal_range`, `prerequisite_quantity_range` or `prerequisite_shipping_price_range`. price\_​rule.allocation\_​limit:​3 deprecated The number of times the discount can be allocated on the cart - if eligible. For example a Buy 1 hat Get 1 hat for free discount can be applied 3 times on a cart having more than 6 hats, where maximum of 3 hats get discounted - if the `allocation_limit` is 3. Empty (`null`) `allocation_limit` means unlimited number of allocations. Caution `allocation_limit` is only working with Buy X Get Y discount. The default value on creation will be `null` (unlimited). Create a price rule that gives a select group of customers $5 off their order Request body price\_​rule​ Price\_rule resource Show price\_rule properties price\_​rule.title:​"5OFFCUSTOMERGROUP" deprecated The title of the price rule. This is used by the Shopify admin search to retrieve discounts. It is also displayed on the **Discounts** page of the Shopify admin for bulk discounts. For non-bulk discounts, the discount code is displayed on the admin. Caution For a consistent search experience, use the same value for `title` as the `code` property of the associated discount code. price\_​rule.target\_​type:​"line\_item" deprecated The target type that the price rule applies to. Valid values: Show target\_type properties * **line\_item**: The price rule applies to the cart's line items. * **shipping\_line**: The price rule applies to the cart's shipping lines. price\_​rule.target\_​selection:​"all" deprecated The target selection method of the price rule. Valid values: Show target\_selection properties * **all**: The price rule applies the discount to all line items in the checkout. * **entitled**: The price rule applies the discount to selected entitlements only. price\_​rule.allocation\_​method:​"across" deprecated The allocation method of the price rule. Valid values: Show allocation\_method properties * **each**: The discount is applied to each of the entitled items. For example, for a price rule that takes $15 off, each entitled line item in a checkout will be discounted by $15. * **across**: The calculated discount amount will be applied across the entitled items. For example, for a price rule that takes $15 off, the discount will be applied across all the entitled items. When the value of `target_type` is `shipping_line`, then this value must be `each`. price\_​rule.value\_​type:​"fixed\_amount" deprecated The value type of the price rule. Valid values: Show value\_type properties * **fixed\_amount**: Applies a discount of `value` as a unit of the store's currency. For example, if `value` is -30 and the store's currency is USD, then $30 USD is deducted when the discount is applied. * **percentage**: Applies a percentage discount of `value`. For example, if `value` is -30, then 30% will be deducted when the discount is applied. If `target_type` is `shipping_line`, then only `percentage` is accepted. price\_​rule.value:​"-5.0" deprecated The value of the price rule. If if the value of `target_type` is `shipping_line`, then only `-100` is accepted. The value must be negative. price\_​rule.customer\_​selection:​"prerequisite" deprecated The customer selection for the price rule. Valid values: Show customer\_selection properties * **all**: The price rule is valid for all customers. * **prerequisite**: The customer must either belong to one of the customer segments specified by `customer_segment_prerequisite_ids`, or be one of the customers specified by `prerequisite_customer_ids`. price\_​rule.customer\_​segment\_​prerequisite\_​ids:​\[210588551] deprecated A list of customer segment IDs. For the price rule to be applicable, the customer must be in the group of customers matching a customer segment. If `customer_segment_prerequisite_ids` is populated, then `prerequisite_customer_ids` must be empty. price\_​rule.starts\_​at:​"2017-01-19T17:59:10Z" deprecated The date and time ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) when the price rule starts. Create a price rule that gives the buyer $10.00 off an order Request body price\_​rule​ Price\_rule resource Show price\_rule properties price\_​rule.title:​"SUMMERSALE10OFF" deprecated The title of the price rule. This is used by the Shopify admin search to retrieve discounts. It is also displayed on the **Discounts** page of the Shopify admin for bulk discounts. For non-bulk discounts, the discount code is displayed on the admin. Caution For a consistent search experience, use the same value for `title` as the `code` property of the associated discount code. price\_​rule.target\_​type:​"line\_item" deprecated The target type that the price rule applies to. Valid values: Show target\_type properties * **line\_item**: The price rule applies to the cart's line items. * **shipping\_line**: The price rule applies to the cart's shipping lines. price\_​rule.target\_​selection:​"all" deprecated The target selection method of the price rule. Valid values: Show target\_selection properties * **all**: The price rule applies the discount to all line items in the checkout. * **entitled**: The price rule applies the discount to selected entitlements only. price\_​rule.allocation\_​method:​"across" deprecated The allocation method of the price rule. Valid values: Show allocation\_method properties * **each**: The discount is applied to each of the entitled items. For example, for a price rule that takes $15 off, each entitled line item in a checkout will be discounted by $15. * **across**: The calculated discount amount will be applied across the entitled items. For example, for a price rule that takes $15 off, the discount will be applied across all the entitled items. When the value of `target_type` is `shipping_line`, then this value must be `each`. price\_​rule.value\_​type:​"fixed\_amount" deprecated The value type of the price rule. Valid values: Show value\_type properties * **fixed\_amount**: Applies a discount of `value` as a unit of the store's currency. For example, if `value` is -30 and the store's currency is USD, then $30 USD is deducted when the discount is applied. * **percentage**: Applies a percentage discount of `value`. For example, if `value` is -30, then 30% will be deducted when the discount is applied. If `target_type` is `shipping_line`, then only `percentage` is accepted. price\_​rule.value:​"-10.0" deprecated The value of the price rule. If if the value of `target_type` is `shipping_line`, then only `-100` is accepted. The value must be negative. price\_​rule.customer\_​selection:​"all" deprecated The customer selection for the price rule. Valid values: Show customer\_selection properties * **all**: The price rule is valid for all customers. * **prerequisite**: The customer must either belong to one of the customer segments specified by `customer_segment_prerequisite_ids`, or be one of the customers specified by `prerequisite_customer_ids`. price\_​rule.starts\_​at:​"2017-01-19T17:59:10Z" deprecated The date and time ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) when the price rule starts. Create a price rule that gives the buyer 15% off a specific collection Request body price\_​rule​ Price\_rule resource Show price\_rule properties price\_​rule.title:​"15OFFCOLLECTION" deprecated The title of the price rule. This is used by the Shopify admin search to retrieve discounts. It is also displayed on the **Discounts** page of the Shopify admin for bulk discounts. For non-bulk discounts, the discount code is displayed on the admin. Caution For a consistent search experience, use the same value for `title` as the `code` property of the associated discount code. price\_​rule.target\_​type:​"line\_item" deprecated The target type that the price rule applies to. Valid values: Show target\_type properties * **line\_item**: The price rule applies to the cart's line items. * **shipping\_line**: The price rule applies to the cart's shipping lines. price\_​rule.target\_​selection:​"entitled" deprecated The target selection method of the price rule. Valid values: Show target\_selection properties * **all**: The price rule applies the discount to all line items in the checkout. * **entitled**: The price rule applies the discount to selected entitlements only. price\_​rule.allocation\_​method:​"across" deprecated The allocation method of the price rule. Valid values: Show allocation\_method properties * **each**: The discount is applied to each of the entitled items. For example, for a price rule that takes $15 off, each entitled line item in a checkout will be discounted by $15. * **across**: The calculated discount amount will be applied across the entitled items. For example, for a price rule that takes $15 off, the discount will be applied across all the entitled items. When the value of `target_type` is `shipping_line`, then this value must be `each`. price\_​rule.value\_​type:​"percentage" deprecated The value type of the price rule. Valid values: Show value\_type properties * **fixed\_amount**: Applies a discount of `value` as a unit of the store's currency. For example, if `value` is -30 and the store's currency is USD, then $30 USD is deducted when the discount is applied. * **percentage**: Applies a percentage discount of `value`. For example, if `value` is -30, then 30% will be deducted when the discount is applied. If `target_type` is `shipping_line`, then only `percentage` is accepted. price\_​rule.value:​"-15.0" deprecated The value of the price rule. If if the value of `target_type` is `shipping_line`, then only `-100` is accepted. The value must be negative. price\_​rule.customer\_​selection:​"all" deprecated The customer selection for the price rule. Valid values: Show customer\_selection properties * **all**: The price rule is valid for all customers. * **prerequisite**: The customer must either belong to one of the customer segments specified by `customer_segment_prerequisite_ids`, or be one of the customers specified by `prerequisite_customer_ids`. price\_​rule.entitled\_​collection\_​ids:​\[841564295] deprecated 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`. price\_​rule.starts\_​at:​"2017-01-19T17:59:10Z" deprecated The date and time ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) when the price rule starts. Create a price rule that gives the buyer free shipping on orders over $50.00 that can be used up to 20 times Request body price\_​rule​ Price\_rule resource Show price\_rule properties price\_​rule.title:​"FREESHIPPING" deprecated The title of the price rule. This is used by the Shopify admin search to retrieve discounts. It is also displayed on the **Discounts** page of the Shopify admin for bulk discounts. For non-bulk discounts, the discount code is displayed on the admin. Caution For a consistent search experience, use the same value for `title` as the `code` property of the associated discount code. price\_​rule.target\_​type:​"shipping\_line" deprecated The target type that the price rule applies to. Valid values: Show target\_type properties * **line\_item**: The price rule applies to the cart's line items. * **shipping\_line**: The price rule applies to the cart's shipping lines. price\_​rule.target\_​selection:​"all" deprecated The target selection method of the price rule. Valid values: Show target\_selection properties * **all**: The price rule applies the discount to all line items in the checkout. * **entitled**: The price rule applies the discount to selected entitlements only. price\_​rule.allocation\_​method:​"each" deprecated The allocation method of the price rule. Valid values: Show allocation\_method properties * **each**: The discount is applied to each of the entitled items. For example, for a price rule that takes $15 off, each entitled line item in a checkout will be discounted by $15. * **across**: The calculated discount amount will be applied across the entitled items. For example, for a price rule that takes $15 off, the discount will be applied across all the entitled items. When the value of `target_type` is `shipping_line`, then this value must be `each`. price\_​rule.value\_​type:​"percentage" deprecated The value type of the price rule. Valid values: Show value\_type properties * **fixed\_amount**: Applies a discount of `value` as a unit of the store's currency. For example, if `value` is -30 and the store's currency is USD, then $30 USD is deducted when the discount is applied. * **percentage**: Applies a percentage discount of `value`. For example, if `value` is -30, then 30% will be deducted when the discount is applied. If `target_type` is `shipping_line`, then only `percentage` is accepted. price\_​rule.value:​"-100.0" deprecated The value of the price rule. If if the value of `target_type` is `shipping_line`, then only `-100` is accepted. The value must be negative. price\_​rule.usage\_​limit:​20 deprecated The maximum number of times the price rule can be used, per discount code. price\_​rule.customer\_​selection:​"all" deprecated The customer selection for the price rule. Valid values: Show customer\_selection properties * **all**: The price rule is valid for all customers. * **prerequisite**: The customer must either belong to one of the customer segments specified by `customer_segment_prerequisite_ids`, or be one of the customers specified by `prerequisite_customer_ids`. price\_​rule.prerequisite\_​subtotal\_​range:​{"greater\_than\_or\_equal\_to":"50.0"} deprecated The minimum subtotal for the price rule to be applicable. It has the following property: Show prerequisite\_subtotal\_range properties * **greater\_than\_or\_equal\_to**: The subtotal of the entitled cart items must be greater than or equal to this value for the discount to apply. price\_​rule.starts\_​at:​"2017-01-19T17:59:10Z" deprecated The date and time ([ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format) when the price rule starts. post ## /admin/api/2024-10/price\_​rules.​json ```bash curl -d '{"price_rule":{"title":"Buy2iPodsGetiPodTouchForFree","value_type":"percentage","value":"-100.0","customer_selection":"all","target_type":"line_item","target_selection":"entitled","allocation_method":"each","starts_at":"2018-03-22T00:00:00-00:00","prerequisite_collection_ids":[841564295],"entitled_product_ids":[921728736],"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":2,"entitled_quantity":1},"allocation_limit":3}}' \ -X POST "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` {} ## Response JSON ```json HTTP/1.1 201 Created { "price_rule": { "id": 1057371197, "value_type": "percentage", "value": "-100.0", "customer_selection": "all", "target_type": "line_item", "target_selection": "entitled", "allocation_method": "each", "allocation_limit": 3, "once_per_customer": false, "usage_limit": null, "starts_at": "2018-03-21T20:00:00-04:00", "ends_at": null, "created_at": "2025-01-02T11:20:21-05:00", "updated_at": "2025-01-02T11:20:21-05:00", "entitled_product_ids": [ 921728736 ], "entitled_variant_ids": [], "entitled_collection_ids": [], "entitled_country_ids": [], "prerequisite_product_ids": [], "prerequisite_variant_ids": [], "prerequisite_collection_ids": [ 841564295 ], "customer_segment_prerequisite_ids": [], "prerequisite_customer_ids": [], "prerequisite_subtotal_range": null, "prerequisite_quantity_range": null, "prerequisite_shipping_price_range": null, "prerequisite_to_entitlement_quantity_ratio": { "prerequisite_quantity": 2, "entitled_quantity": 1 }, "prerequisite_to_entitlement_purchase": { "prerequisite_amount": null }, "title": "Buy2iPodsGetiPodTouchForFree", "admin_graphql_api_id": "gid://shopify/PriceRule/1057371197" } } ``` ### examples * #### Create a Buy X Get Y price rule that gives one free ipod touch if customer buys 2 ipods ##### ```curl curl -d '{"price_rule":{"title":"Buy2iPodsGetiPodTouchForFree","value_type":"percentage","value":"-100.0","customer_selection":"all","target_type":"line_item","target_selection":"entitled","allocation_method":"each","starts_at":"2018-03-22T00:00:00-00:00","prerequisite_collection_ids":[841564295],"entitled_product_ids":[921728736],"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":2,"entitled_quantity":1},"allocation_limit":3}}' \ -X POST "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ##### ```remix const { admin, session } = await authenticate.admin(request); const price_rule = new admin.rest.resources.PriceRule({session: session}); price_rule.title = "Buy2iPodsGetiPodTouchForFree"; price_rule.value_type = "percentage"; price_rule.value = "-100.0"; price_rule.customer_selection = "all"; price_rule.target_type = "line_item"; price_rule.target_selection = "entitled"; price_rule.allocation_method = "each"; price_rule.starts_at = "2018-03-22T00:00:00-00:00"; price_rule.prerequisite_collection_ids = [ 841564295 ]; price_rule.entitled_product_ids = [ 921728736 ]; price_rule.prerequisite_to_entitlement_quantity_ratio = { "prerequisite_quantity": 2, "entitled_quantity": 1 }; price_rule.allocation_limit = 3; await price_rule.save({ update: true, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session price_rule = ShopifyAPI::PriceRule.new(session: test_session) price_rule.title = "Buy2iPodsGetiPodTouchForFree" price_rule.value_type = "percentage" price_rule.value = "-100.0" price_rule.customer_selection = "all" price_rule.target_type = "line_item" price_rule.target_selection = "entitled" price_rule.allocation_method = "each" price_rule.starts_at = "2018-03-22T00:00:00-00:00" price_rule.prerequisite_collection_ids = [ 841564295 ] price_rule.entitled_product_ids = [ 921728736 ] price_rule.prerequisite_to_entitlement_quantity_ratio = { "prerequisite_quantity" => 2, "entitled_quantity" => 1 } price_rule.allocation_limit = 3 price_rule.save! ``` ##### ```node // Session is built by the OAuth process const price_rule = new shopify.rest.PriceRule({session: session}); price_rule.title = "Buy2iPodsGetiPodTouchForFree"; price_rule.value_type = "percentage"; price_rule.value = "-100.0"; price_rule.customer_selection = "all"; price_rule.target_type = "line_item"; price_rule.target_selection = "entitled"; price_rule.allocation_method = "each"; price_rule.starts_at = "2018-03-22T00:00:00-00:00"; price_rule.prerequisite_collection_ids = [ 841564295 ]; price_rule.entitled_product_ids = [ 921728736 ]; price_rule.prerequisite_to_entitlement_quantity_ratio = { "prerequisite_quantity": 2, "entitled_quantity": 1 }; price_rule.allocation_limit = 3; await price_rule.save({ update: true, }); ``` #### response ```json HTTP/1.1 201 Created{"price_rule":{"id":1057371197,"value_type":"percentage","value":"-100.0","customer_selection":"all","target_type":"line_item","target_selection":"entitled","allocation_method":"each","allocation_limit":3,"once_per_customer":false,"usage_limit":null,"starts_at":"2018-03-21T20:00:00-04:00","ends_at":null,"created_at":"2025-01-02T11:20:21-05:00","updated_at":"2025-01-02T11:20:21-05:00","entitled_product_ids":[921728736],"entitled_variant_ids":[],"entitled_collection_ids":[],"entitled_country_ids":[],"prerequisite_product_ids":[],"prerequisite_variant_ids":[],"prerequisite_collection_ids":[841564295],"customer_segment_prerequisite_ids":[],"prerequisite_customer_ids":[],"prerequisite_subtotal_range":null,"prerequisite_quantity_range":null,"prerequisite_shipping_price_range":null,"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":2,"entitled_quantity":1},"prerequisite_to_entitlement_purchase":{"prerequisite_amount":null},"title":"Buy2iPodsGetiPodTouchForFree","admin_graphql_api_id":"gid://shopify/PriceRule/1057371197"}} ``` * #### Create a price rule that gives a select group of customers $5 off their order ##### ```curl curl -d '{"price_rule":{"title":"5OFFCUSTOMERGROUP","target_type":"line_item","target_selection":"all","allocation_method":"across","value_type":"fixed_amount","value":"-5.0","customer_selection":"prerequisite","customer_segment_prerequisite_ids":[210588551],"starts_at":"2017-01-19T17:59:10Z"}}' \ -X POST "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ##### ```remix const { admin, session } = await authenticate.admin(request); const price_rule = new admin.rest.resources.PriceRule({session: session}); price_rule.title = "5OFFCUSTOMERGROUP"; price_rule.target_type = "line_item"; price_rule.target_selection = "all"; price_rule.allocation_method = "across"; price_rule.value_type = "fixed_amount"; price_rule.value = "-5.0"; price_rule.customer_selection = "prerequisite"; price_rule.customer_segment_prerequisite_ids = [ 210588551 ]; price_rule.starts_at = "2017-01-19T17:59:10Z"; await price_rule.save({ update: true, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session price_rule = ShopifyAPI::PriceRule.new(session: test_session) price_rule.title = "5OFFCUSTOMERGROUP" price_rule.target_type = "line_item" price_rule.target_selection = "all" price_rule.allocation_method = "across" price_rule.value_type = "fixed_amount" price_rule.value = "-5.0" price_rule.customer_selection = "prerequisite" price_rule.customer_segment_prerequisite_ids = [ 210588551 ] price_rule.starts_at = "2017-01-19T17:59:10Z" price_rule.save! ``` ##### ```node // Session is built by the OAuth process const price_rule = new shopify.rest.PriceRule({session: session}); price_rule.title = "5OFFCUSTOMERGROUP"; price_rule.target_type = "line_item"; price_rule.target_selection = "all"; price_rule.allocation_method = "across"; price_rule.value_type = "fixed_amount"; price_rule.value = "-5.0"; price_rule.customer_selection = "prerequisite"; price_rule.customer_segment_prerequisite_ids = [ 210588551 ]; price_rule.starts_at = "2017-01-19T17:59:10Z"; await price_rule.save({ update: true, }); ``` #### response ```json HTTP/1.1 422 Unprocessable Entity{"errors":{"customer_segment_prerequisite_ids":["segment with id: 210588551 is invalid"]}} ``` * #### Create a price rule that gives the buyer $10.00 off an order ##### ```curl curl -d '{"price_rule":{"title":"SUMMERSALE10OFF","target_type":"line_item","target_selection":"all","allocation_method":"across","value_type":"fixed_amount","value":"-10.0","customer_selection":"all","starts_at":"2017-01-19T17:59:10Z"}}' \ -X POST "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ##### ```remix const { admin, session } = await authenticate.admin(request); const price_rule = new admin.rest.resources.PriceRule({session: session}); price_rule.title = "SUMMERSALE10OFF"; price_rule.target_type = "line_item"; price_rule.target_selection = "all"; price_rule.allocation_method = "across"; price_rule.value_type = "fixed_amount"; price_rule.value = "-10.0"; price_rule.customer_selection = "all"; price_rule.starts_at = "2017-01-19T17:59:10Z"; await price_rule.save({ update: true, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session price_rule = ShopifyAPI::PriceRule.new(session: test_session) price_rule.title = "SUMMERSALE10OFF" price_rule.target_type = "line_item" price_rule.target_selection = "all" price_rule.allocation_method = "across" price_rule.value_type = "fixed_amount" price_rule.value = "-10.0" price_rule.customer_selection = "all" price_rule.starts_at = "2017-01-19T17:59:10Z" price_rule.save! ``` ##### ```node // Session is built by the OAuth process const price_rule = new shopify.rest.PriceRule({session: session}); price_rule.title = "SUMMERSALE10OFF"; price_rule.target_type = "line_item"; price_rule.target_selection = "all"; price_rule.allocation_method = "across"; price_rule.value_type = "fixed_amount"; price_rule.value = "-10.0"; price_rule.customer_selection = "all"; price_rule.starts_at = "2017-01-19T17:59:10Z"; await price_rule.save({ update: true, }); ``` #### response ```json HTTP/1.1 201 Created{"price_rule":{"id":1057371199,"value_type":"fixed_amount","value":"-10.0","customer_selection":"all","target_type":"line_item","target_selection":"all","allocation_method":"across","allocation_limit":null,"once_per_customer":false,"usage_limit":null,"starts_at":"2017-01-19T12:59:10-05:00","ends_at":null,"created_at":"2025-01-02T11:20:24-05:00","updated_at":"2025-01-02T11:20:24-05:00","entitled_product_ids":[],"entitled_variant_ids":[],"entitled_collection_ids":[],"entitled_country_ids":[],"prerequisite_product_ids":[],"prerequisite_variant_ids":[],"prerequisite_collection_ids":[],"customer_segment_prerequisite_ids":[],"prerequisite_customer_ids":[],"prerequisite_subtotal_range":null,"prerequisite_quantity_range":null,"prerequisite_shipping_price_range":null,"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":null,"entitled_quantity":null},"prerequisite_to_entitlement_purchase":{"prerequisite_amount":null},"title":"SUMMERSALE10OFF","admin_graphql_api_id":"gid://shopify/PriceRule/1057371199"}} ``` * #### Create a price rule that gives the buyer 15% off a specific collection ##### ```curl curl -d '{"price_rule":{"title":"15OFFCOLLECTION","target_type":"line_item","target_selection":"entitled","allocation_method":"across","value_type":"percentage","value":"-15.0","customer_selection":"all","entitled_collection_ids":[841564295],"starts_at":"2017-01-19T17:59:10Z"}}' \ -X POST "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ##### ```remix const { admin, session } = await authenticate.admin(request); const price_rule = new admin.rest.resources.PriceRule({session: session}); price_rule.title = "15OFFCOLLECTION"; price_rule.target_type = "line_item"; price_rule.target_selection = "entitled"; price_rule.allocation_method = "across"; price_rule.value_type = "percentage"; price_rule.value = "-15.0"; price_rule.customer_selection = "all"; price_rule.entitled_collection_ids = [ 841564295 ]; price_rule.starts_at = "2017-01-19T17:59:10Z"; await price_rule.save({ update: true, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session price_rule = ShopifyAPI::PriceRule.new(session: test_session) price_rule.title = "15OFFCOLLECTION" price_rule.target_type = "line_item" price_rule.target_selection = "entitled" price_rule.allocation_method = "across" price_rule.value_type = "percentage" price_rule.value = "-15.0" price_rule.customer_selection = "all" price_rule.entitled_collection_ids = [ 841564295 ] price_rule.starts_at = "2017-01-19T17:59:10Z" price_rule.save! ``` ##### ```node // Session is built by the OAuth process const price_rule = new shopify.rest.PriceRule({session: session}); price_rule.title = "15OFFCOLLECTION"; price_rule.target_type = "line_item"; price_rule.target_selection = "entitled"; price_rule.allocation_method = "across"; price_rule.value_type = "percentage"; price_rule.value = "-15.0"; price_rule.customer_selection = "all"; price_rule.entitled_collection_ids = [ 841564295 ]; price_rule.starts_at = "2017-01-19T17:59:10Z"; await price_rule.save({ update: true, }); ``` #### response ```json HTTP/1.1 201 Created{"price_rule":{"id":1057371198,"value_type":"percentage","value":"-15.0","customer_selection":"all","target_type":"line_item","target_selection":"entitled","allocation_method":"across","allocation_limit":null,"once_per_customer":false,"usage_limit":null,"starts_at":"2017-01-19T12:59:10-05:00","ends_at":null,"created_at":"2025-01-02T11:20:23-05:00","updated_at":"2025-01-02T11:20:23-05:00","entitled_product_ids":[],"entitled_variant_ids":[],"entitled_collection_ids":[841564295],"entitled_country_ids":[],"prerequisite_product_ids":[],"prerequisite_variant_ids":[],"prerequisite_collection_ids":[],"customer_segment_prerequisite_ids":[],"prerequisite_customer_ids":[],"prerequisite_subtotal_range":null,"prerequisite_quantity_range":null,"prerequisite_shipping_price_range":null,"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":null,"entitled_quantity":null},"prerequisite_to_entitlement_purchase":{"prerequisite_amount":null},"title":"15OFFCOLLECTION","admin_graphql_api_id":"gid://shopify/PriceRule/1057371198"}} ``` * #### Create a price rule that gives the buyer free shipping on orders over $50.00 that can be used up to 20 times ##### ```curl curl -d '{"price_rule":{"title":"FREESHIPPING","target_type":"shipping_line","target_selection":"all","allocation_method":"each","value_type":"percentage","value":"-100.0","usage_limit":20,"customer_selection":"all","prerequisite_subtotal_range":{"greater_than_or_equal_to":"50.0"},"starts_at":"2017-01-19T17:59:10Z"}}' \ -X POST "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ##### ```remix const { admin, session } = await authenticate.admin(request); const price_rule = new admin.rest.resources.PriceRule({session: session}); price_rule.title = "FREESHIPPING"; price_rule.target_type = "shipping_line"; price_rule.target_selection = "all"; price_rule.allocation_method = "each"; price_rule.value_type = "percentage"; price_rule.value = "-100.0"; price_rule.usage_limit = 20; price_rule.customer_selection = "all"; price_rule.prerequisite_subtotal_range = { "greater_than_or_equal_to": "50.0" }; price_rule.starts_at = "2017-01-19T17:59:10Z"; await price_rule.save({ update: true, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session price_rule = ShopifyAPI::PriceRule.new(session: test_session) price_rule.title = "FREESHIPPING" price_rule.target_type = "shipping_line" price_rule.target_selection = "all" price_rule.allocation_method = "each" price_rule.value_type = "percentage" price_rule.value = "-100.0" price_rule.usage_limit = 20 price_rule.customer_selection = "all" price_rule.prerequisite_subtotal_range = { "greater_than_or_equal_to" => "50.0" } price_rule.starts_at = "2017-01-19T17:59:10Z" price_rule.save! ``` ##### ```node // Session is built by the OAuth process const price_rule = new shopify.rest.PriceRule({session: session}); price_rule.title = "FREESHIPPING"; price_rule.target_type = "shipping_line"; price_rule.target_selection = "all"; price_rule.allocation_method = "each"; price_rule.value_type = "percentage"; price_rule.value = "-100.0"; price_rule.usage_limit = 20; price_rule.customer_selection = "all"; price_rule.prerequisite_subtotal_range = { "greater_than_or_equal_to": "50.0" }; price_rule.starts_at = "2017-01-19T17:59:10Z"; await price_rule.save({ update: true, }); ``` #### response ```json HTTP/1.1 201 Created{"price_rule":{"id":1057371196,"value_type":"percentage","value":"-100.0","customer_selection":"all","target_type":"shipping_line","target_selection":"all","allocation_method":"each","allocation_limit":null,"once_per_customer":false,"usage_limit":20,"starts_at":"2017-01-19T12:59:10-05:00","ends_at":null,"created_at":"2025-01-02T11:20:20-05:00","updated_at":"2025-01-02T11:20:20-05:00","entitled_product_ids":[],"entitled_variant_ids":[],"entitled_collection_ids":[],"entitled_country_ids":[],"prerequisite_product_ids":[],"prerequisite_variant_ids":[],"prerequisite_collection_ids":[],"customer_segment_prerequisite_ids":[],"prerequisite_customer_ids":[],"prerequisite_subtotal_range":{"greater_than_or_equal_to":"50.0"},"prerequisite_quantity_range":null,"prerequisite_shipping_price_range":null,"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":null,"entitled_quantity":null},"prerequisite_to_entitlement_purchase":{"prerequisite_amount":null},"title":"FREESHIPPING","admin_graphql_api_id":"gid://shopify/PriceRule/1057371196"}} ``` *** ## getRetrieves a list of price rules [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNodes) [discountNodes](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNodes) Retrieves a list of price rules. **Note:** This endpoint implements pagination by using links that are provided in the response header. To learn more, refer to [Make paginated requests to the REST Admin API](https://shopify.dev/api/usage/pagination-rest). ### Parameters *** api\_version string required *** created\_at\_max Show price rules created before date (format 2017-03-25T16:15:47-04:00). *** created\_at\_min Show price rules created after date (format 2017-03-25T16:15:47-04:00). *** ends\_at\_max Show price rules ending before date (format 2017-03-25T16:15:47-04:00). *** ends\_at\_min Show price rules ending after date (format 2017-03-25T16:15:47-04:00). *** limit ≤ 250 default 50 The maximum number of results to retrieve. *** since\_id Restrict results to after the specified ID. *** starts\_at\_max Show price rules starting before date (format 2017-03-25T16:15:47-04:00). *** starts\_at\_min Show price rules starting after date (format 2017-03-25T16:15:47-04:00). *** times\_used Show price rules with times used. *** updated\_at\_max Show price rules last updated before date (format 2017-03-25T16:15:47-04:00). *** updated\_at\_min Show price rules last updated after date (format 2017-03-25T16:15:47-04:00). *** ### Examples Retrieve all price rules Retrieve all price rules after a specified ID Query parameters since\_​id=​106886545 Restrict results to after the specified ID. get ## /admin/api/2024-10/price\_​rules.​json ```bash curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 200 OK { "price_rules": [ { "id": 507328175, "value_type": "fixed_amount", "value": "-10.0", "customer_selection": "all", "target_type": "line_item", "target_selection": "all", "allocation_method": "across", "allocation_limit": null, "once_per_customer": false, "usage_limit": null, "starts_at": "2024-12-27T11:09:43-05:00", "ends_at": "2025-01-08T11:09:43-05:00", "created_at": "2025-01-02T11:09:43-05:00", "updated_at": "2025-01-02T11:09:43-05:00", "entitled_product_ids": [], "entitled_variant_ids": [], "entitled_collection_ids": [], "entitled_country_ids": [], "prerequisite_product_ids": [], "prerequisite_variant_ids": [], "prerequisite_collection_ids": [], "customer_segment_prerequisite_ids": [], "prerequisite_customer_ids": [], "prerequisite_subtotal_range": null, "prerequisite_quantity_range": null, "prerequisite_shipping_price_range": null, "prerequisite_to_entitlement_quantity_ratio": { "prerequisite_quantity": null, "entitled_quantity": null }, "prerequisite_to_entitlement_purchase": { "prerequisite_amount": null }, "title": "SUMMERSALE10OFF", "admin_graphql_api_id": "gid://shopify/PriceRule/507328175" }, { "id": 106886544, "value_type": "fixed_amount", "value": "-10.0", "customer_selection": "all", "target_type": "line_item", "target_selection": "all", "allocation_method": "across", "allocation_limit": null, "once_per_customer": false, "usage_limit": null, "starts_at": "2024-12-31T11:09:43-05:00", "ends_at": "2025-01-04T11:09:43-05:00", "created_at": "2025-01-02T11:09:43-05:00", "updated_at": "2025-01-02T11:09:43-05:00", "entitled_product_ids": [], "entitled_variant_ids": [], "entitled_collection_ids": [], "entitled_country_ids": [], "prerequisite_product_ids": [], "prerequisite_variant_ids": [], "prerequisite_collection_ids": [], "customer_segment_prerequisite_ids": [], "prerequisite_customer_ids": [], "prerequisite_subtotal_range": null, "prerequisite_quantity_range": null, "prerequisite_shipping_price_range": null, "prerequisite_to_entitlement_quantity_ratio": { "prerequisite_quantity": null, "entitled_quantity": null }, "prerequisite_to_entitlement_purchase": { "prerequisite_amount": null }, "title": "TENOFF", "admin_graphql_api_id": "gid://shopify/PriceRule/106886544" } ] } ``` ### examples * #### Retrieve all price rules ##### ```curl curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.PriceRule.all({ session: session, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::PriceRule.all( session: test_session, ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.PriceRule.all({ session: session, }); ``` #### response ```json HTTP/1.1 200 OK{"price_rules":[{"id":507328175,"value_type":"fixed_amount","value":"-10.0","customer_selection":"all","target_type":"line_item","target_selection":"all","allocation_method":"across","allocation_limit":null,"once_per_customer":false,"usage_limit":null,"starts_at":"2024-12-27T11:09:43-05:00","ends_at":"2025-01-08T11:09:43-05:00","created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","entitled_product_ids":[],"entitled_variant_ids":[],"entitled_collection_ids":[],"entitled_country_ids":[],"prerequisite_product_ids":[],"prerequisite_variant_ids":[],"prerequisite_collection_ids":[],"customer_segment_prerequisite_ids":[],"prerequisite_customer_ids":[],"prerequisite_subtotal_range":null,"prerequisite_quantity_range":null,"prerequisite_shipping_price_range":null,"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":null,"entitled_quantity":null},"prerequisite_to_entitlement_purchase":{"prerequisite_amount":null},"title":"SUMMERSALE10OFF","admin_graphql_api_id":"gid://shopify/PriceRule/507328175"},{"id":106886544,"value_type":"fixed_amount","value":"-10.0","customer_selection":"all","target_type":"line_item","target_selection":"all","allocation_method":"across","allocation_limit":null,"once_per_customer":false,"usage_limit":null,"starts_at":"2024-12-31T11:09:43-05:00","ends_at":"2025-01-04T11:09:43-05:00","created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","entitled_product_ids":[],"entitled_variant_ids":[],"entitled_collection_ids":[],"entitled_country_ids":[],"prerequisite_product_ids":[],"prerequisite_variant_ids":[],"prerequisite_collection_ids":[],"customer_segment_prerequisite_ids":[],"prerequisite_customer_ids":[],"prerequisite_subtotal_range":null,"prerequisite_quantity_range":null,"prerequisite_shipping_price_range":null,"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":null,"entitled_quantity":null},"prerequisite_to_entitlement_purchase":{"prerequisite_amount":null},"title":"TENOFF","admin_graphql_api_id":"gid://shopify/PriceRule/106886544"}]} ``` * #### Retrieve all price rules after a specified ID ##### ```curl curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules.json?since_id=106886545" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.PriceRule.all({ session: session, since_id: "106886545", }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::PriceRule.all( session: test_session, since_id: "106886545", ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.PriceRule.all({ session: session, since_id: "106886545", }); ``` #### response ```json HTTP/1.1 200 OK{"price_rules":[{"id":507328175,"value_type":"fixed_amount","value":"-10.0","customer_selection":"all","target_type":"line_item","target_selection":"all","allocation_method":"across","allocation_limit":null,"once_per_customer":false,"usage_limit":null,"starts_at":"2024-12-27T11:09:43-05:00","ends_at":"2025-01-08T11:09:43-05:00","created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","entitled_product_ids":[],"entitled_variant_ids":[],"entitled_collection_ids":[],"entitled_country_ids":[],"prerequisite_product_ids":[],"prerequisite_variant_ids":[],"prerequisite_collection_ids":[],"customer_segment_prerequisite_ids":[],"prerequisite_customer_ids":[],"prerequisite_subtotal_range":null,"prerequisite_quantity_range":null,"prerequisite_shipping_price_range":null,"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":null,"entitled_quantity":null},"prerequisite_to_entitlement_purchase":{"prerequisite_amount":null},"title":"SUMMERSALE10OFF","admin_graphql_api_id":"gid://shopify/PriceRule/507328175"}]} ``` *** ## getRetrieves a single price rule [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNode) [discountNode](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNode) Retrieves a single price rule ### Parameters *** api\_version string required *** price\_rule\_id string required *** ### Examples Retrieve a single price rule by its ID Path parameters price\_​rule\_​id=​507328175 string required get ## /admin/api/2024-10/price\_​rules/507328175.​json ```bash curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 200 OK { "price_rule": { "id": 507328175, "value_type": "fixed_amount", "value": "-10.0", "customer_selection": "all", "target_type": "line_item", "target_selection": "all", "allocation_method": "across", "allocation_limit": null, "once_per_customer": false, "usage_limit": null, "starts_at": "2024-12-27T11:09:43-05:00", "ends_at": "2025-01-08T11:09:43-05:00", "created_at": "2025-01-02T11:09:43-05:00", "updated_at": "2025-01-02T11:09:43-05:00", "entitled_product_ids": [], "entitled_variant_ids": [], "entitled_collection_ids": [], "entitled_country_ids": [], "prerequisite_product_ids": [], "prerequisite_variant_ids": [], "prerequisite_collection_ids": [], "customer_segment_prerequisite_ids": [], "prerequisite_customer_ids": [], "prerequisite_subtotal_range": null, "prerequisite_quantity_range": null, "prerequisite_shipping_price_range": null, "prerequisite_to_entitlement_quantity_ratio": { "prerequisite_quantity": null, "entitled_quantity": null }, "prerequisite_to_entitlement_purchase": { "prerequisite_amount": null }, "title": "SUMMERSALE10OFF", "admin_graphql_api_id": "gid://shopify/PriceRule/507328175" } } ``` ### examples * #### Retrieve a single price rule by its ID ##### ```curl curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.PriceRule.find({ session: session, id: 507328175, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::PriceRule.find( session: test_session, id: 507328175, ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.PriceRule.find({ session: session, id: 507328175, }); ``` #### response ```json HTTP/1.1 200 OK{"price_rule":{"id":507328175,"value_type":"fixed_amount","value":"-10.0","customer_selection":"all","target_type":"line_item","target_selection":"all","allocation_method":"across","allocation_limit":null,"once_per_customer":false,"usage_limit":null,"starts_at":"2024-12-27T11:09:43-05:00","ends_at":"2025-01-08T11:09:43-05:00","created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:09:43-05:00","entitled_product_ids":[],"entitled_variant_ids":[],"entitled_collection_ids":[],"entitled_country_ids":[],"prerequisite_product_ids":[],"prerequisite_variant_ids":[],"prerequisite_collection_ids":[],"customer_segment_prerequisite_ids":[],"prerequisite_customer_ids":[],"prerequisite_subtotal_range":null,"prerequisite_quantity_range":null,"prerequisite_shipping_price_range":null,"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":null,"entitled_quantity":null},"prerequisite_to_entitlement_purchase":{"prerequisite_amount":null},"title":"SUMMERSALE10OFF","admin_graphql_api_id":"gid://shopify/PriceRule/507328175"}} ``` *** ## getRetrieves a count of all price rules [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNodesCount?example=retrieves-a-count-of-all-price-rules) [discountNodesCount](https://shopify.dev/docs/api/admin-graphql/latest/queries/discountNodesCount?example=retrieves-a-count-of-all-price-rules) Retrieves a count of all price rules. ### Parameters *** api\_version string required *** ### Examples Retrieve a count of all price rules get ## /admin/api/2024-10/price\_​rules/count.​json ```bash curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules/count.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 200 OK { "count": 2 } ``` ### examples * #### Retrieve a count of all price rules ##### ```curl curl -X GET "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules/count.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.PriceRule.count({ session: session, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::PriceRule.count( session: test_session, ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.PriceRule.count({ session: session, }); ``` #### response ```json HTTP/1.1 200 OK{"count":2} ``` *** ## putUpdates an existing a price rule [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBasicUpdate) [discountCodeBasicUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBasicUpdate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBasicUpdate) [discountAutomaticBasicUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBasicUpdate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBxgyUpdate) [discountCodeBxgyUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeBxgyUpdate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBxgyUpdate) [discountAutomaticBxgyUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticBxgyUpdate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeFreeShippingUpdate) [discountCodeFreeShippingUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeFreeShippingUpdate) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticFreeShippingUpdate) [discountAutomaticFreeShippingUpdate](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticFreeShippingUpdate) Updates an existing a price rule ### Parameters *** api\_version string required *** price\_rule\_id string required *** ### Examples Update the title of a price rule Path parameters price\_​rule\_​id=​507328175 string required Request body price\_​rule​ Price\_rule resource Show price\_rule properties price\_​rule.id:​507328175 read-only deprecated The ID for the price rule. price\_​rule.title:​"WINTER SALE" deprecated The title of the price rule. This is used by the Shopify admin search to retrieve discounts. It is also displayed on the **Discounts** page of the Shopify admin for bulk discounts. For non-bulk discounts, the discount code is displayed on the admin. Caution For a consistent search experience, use the same value for `title` as the `code` property of the associated discount code. put ## /admin/api/2024-10/price\_​rules/507328175.​json ```bash curl -d '{"price_rule":{"id":507328175,"title":"WINTER SALE"}}' \ -X PUT "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` {} ## Response JSON ```json HTTP/1.1 200 OK { "price_rule": { "id": 507328175, "value_type": "fixed_amount", "value": "-10.0", "customer_selection": "all", "target_type": "line_item", "target_selection": "all", "allocation_method": "across", "allocation_limit": null, "once_per_customer": false, "usage_limit": null, "starts_at": "2024-12-27T11:09:43-05:00", "ends_at": "2025-01-08T11:09:43-05:00", "created_at": "2025-01-02T11:09:43-05:00", "updated_at": "2025-01-02T11:20:24-05:00", "entitled_product_ids": [], "entitled_variant_ids": [], "entitled_collection_ids": [], "entitled_country_ids": [], "prerequisite_product_ids": [], "prerequisite_variant_ids": [], "prerequisite_collection_ids": [], "customer_segment_prerequisite_ids": [], "prerequisite_customer_ids": [], "prerequisite_subtotal_range": null, "prerequisite_quantity_range": null, "prerequisite_shipping_price_range": null, "prerequisite_to_entitlement_quantity_ratio": { "prerequisite_quantity": null, "entitled_quantity": null }, "prerequisite_to_entitlement_purchase": { "prerequisite_amount": null }, "title": "WINTER SALE", "admin_graphql_api_id": "gid://shopify/PriceRule/507328175" } } ``` ### examples * #### Update the title of a price rule ##### ```curl curl -d '{"price_rule":{"id":507328175,"title":"WINTER SALE"}}' \ -X PUT "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" \ -H "Content-Type: application/json" ``` ##### ```remix const { admin, session } = await authenticate.admin(request); const price_rule = new admin.rest.resources.PriceRule({session: session}); price_rule.id = 507328175; price_rule.title = "WINTER SALE"; await price_rule.save({ update: true, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session price_rule = ShopifyAPI::PriceRule.new(session: test_session) price_rule.id = 507328175 price_rule.title = "WINTER SALE" price_rule.save! ``` ##### ```node // Session is built by the OAuth process const price_rule = new shopify.rest.PriceRule({session: session}); price_rule.id = 507328175; price_rule.title = "WINTER SALE"; await price_rule.save({ update: true, }); ``` #### response ```json HTTP/1.1 200 OK{"price_rule":{"id":507328175,"value_type":"fixed_amount","value":"-10.0","customer_selection":"all","target_type":"line_item","target_selection":"all","allocation_method":"across","allocation_limit":null,"once_per_customer":false,"usage_limit":null,"starts_at":"2024-12-27T11:09:43-05:00","ends_at":"2025-01-08T11:09:43-05:00","created_at":"2025-01-02T11:09:43-05:00","updated_at":"2025-01-02T11:20:24-05:00","entitled_product_ids":[],"entitled_variant_ids":[],"entitled_collection_ids":[],"entitled_country_ids":[],"prerequisite_product_ids":[],"prerequisite_variant_ids":[],"prerequisite_collection_ids":[],"customer_segment_prerequisite_ids":[],"prerequisite_customer_ids":[],"prerequisite_subtotal_range":null,"prerequisite_quantity_range":null,"prerequisite_shipping_price_range":null,"prerequisite_to_entitlement_quantity_ratio":{"prerequisite_quantity":null,"entitled_quantity":null},"prerequisite_to_entitlement_purchase":{"prerequisite_amount":null},"title":"WINTER SALE","admin_graphql_api_id":"gid://shopify/PriceRule/507328175"}} ``` *** ## delRemove an existing Price​Rule [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeDelete) [discountCodeDelete](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountCodeDelete) [![](https://shopify.dev/images/logos/GraphQL.svg)![](https://shopify.dev/images/logos/GraphQL-dark.svg)](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticDelete?example=remove-an-existing-pricerule) [discountAutomaticDelete](https://shopify.dev/docs/api/admin-graphql/latest/mutations/discountAutomaticDelete?example=remove-an-existing-pricerule) Deletes a price rule ### Parameters *** api\_version string required *** price\_rule\_id string required *** ### Examples Delete a price rule Path parameters price\_​rule\_​id=​507328175 string required del ## /admin/api/2024-10/price\_​rules/507328175.​json ```bash curl -X DELETE "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` {} ## Response JSON ```json HTTP/1.1 204 No Content ``` ### examples * #### Delete a price rule ##### ```curl curl -X DELETE "https://your-development-store.myshopify.com/admin/api/2024-10/price_rules/507328175.json" \ -H "X-Shopify-Access-Token: {access_token}" ``` ##### ```remix await admin.rest.resources.PriceRule.delete({ session: session, id: 507328175, }); ``` ##### ```ruby # Session is activated via Authentication test_session = ShopifyAPI::Context.active_session ShopifyAPI::PriceRule.delete( session: test_session, id: 507328175, ) ``` ##### ```node // Session is built by the OAuth process await shopify.rest.PriceRule.delete({ session: session, id: 507328175, }); ``` #### response ```json HTTP/1.1 204 No Content ```