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.

Requires 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.

Was this section helpful?

Properties

allocation_method
deprecated

The allocation method of the price rule. Valid values:


created_at
read-only
deprecated

The date and time (ISO 8601 format) when the price rule was created.


updated_at
read-only
deprecated

The date and time (ISO 8601 format) when the price rule was updated.


customer_selection
deprecated

The customer selection for the price rule. Valid values:


ends_at
deprecated

The date and time (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.

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.

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.

If prerequisite_customer_ids is populated, then customer_segment_prerequisite_ids must be empty.


Was this section helpful?
{}The PriceRule resource
{
  "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
}

Was this section helpful?
Request body
pricerule
Price_rule resource
Was this section helpful?
post
/admin/api/2024-10/price_rules.json
Copy
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
HTTP/1.1 201 Created
{
  "price_rule": {
    "id": 1057371198,
    "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": "2024-09-30T17:53:16-04:00",
    "updated_at": "2024-09-30T17:53:16-04: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/1057371198"
  }
}

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.

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).

Was this section helpful?
Was this section helpful?
get
/admin/api/2024-10/price_rules.json
Copy
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
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-09-24T17:52:44-04:00",
      "ends_at": "2024-10-06T17:52:44-04:00",
      "created_at": "2024-09-30T17:52:44-04:00",
      "updated_at": "2024-09-30T17:52:44-04: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-09-28T17:52:44-04:00",
      "ends_at": "2024-10-02T17:52:44-04:00",
      "created_at": "2024-09-30T17:52:44-04:00",
      "updated_at": "2024-09-30T17:52:44-04: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"
    }
  ]
}

Retrieves a single price rule

api_version
string
required

price_rule_id
string
required

Was this section helpful?
Path parameters
priceruleid=507328175
string
required
Was this section helpful?
get
/admin/api/2024-10/price_rules/507328175.json
Copy
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
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-09-24T17:52:44-04:00",
    "ends_at": "2024-10-06T17:52:44-04:00",
    "created_at": "2024-09-30T17:52:44-04:00",
    "updated_at": "2024-09-30T17:52:44-04: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"
  }
}

Was this section helpful?
Was this section helpful?
get
/admin/api/2024-10/price_rules/count.json
Copy
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
HTTP/1.1 200 OK
{
  "count": 2
}

Was this section helpful?
Path parameters
priceruleid=507328175
string
required
Request body
pricerule
Price_rule resource
Was this section helpful?
put
/admin/api/2024-10/price_rules/507328175.json
Copy
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
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-09-24T17:52:44-04:00",
    "ends_at": "2024-10-06T17:52:44-04:00",
    "created_at": "2024-09-30T17:52:44-04:00",
    "updated_at": "2024-09-30T17:53:11-04: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"
  }
}

Was this section helpful?
Path parameters
priceruleid=507328175
string
required
Was this section helpful?
del
/admin/api/2024-10/price_rules/507328175.json
Copy
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
HTTP/1.1 204 No Content