Create Price Rule

Allows you to create a new price rule for discounts or promotions on the store.

🔒

Requires price_rules access scope. More access scope

The Create Price Rule API allows you to create a new price rule for discounts or promotions on the store.

This API is especially useful for:

  1. Managing discounts and promotional campaigns.
  2. Creating conditional offers based on cart total or product quantity.
  3. Automating discount rules for specific products or product variants.

Request Parameters

Public Request Parameters

📘

Body Parameters

ParameterTypeRequiredDescriptionExample
price_ruleobjectYesThe price rule configuration object{...}

Price Rule Object Structure

ParameterTypeRequiredDescriptionExample
titlestringYesName of the price ruleSummer Sale 2023
valuefloatYesDiscount value amount10.0
value_typestringYesType of discount value (fixed_amount, percentage)percentage
usage_limitint32NoMaximum number of times the rule can be used100
allocation_limitint32NoLimit of discount allocation1
once_per_customerint32NoWhether the rule applies once per customer (1=yes, 0=no)1
prerequisiteint32NoPrerequisite condition flag0
target_selectionstringYesTarget selection method (all, prism, explicit)all
target_typestringYesType of target (line_item, shipping_line)line_item
starts_atstringYesStart date of the price rule (Format: YYYY-MM-DDTHH:mm:ssZ)2023-06-01T00:00:00Z
ends_atstringYesEnd date of the price rule (Format: YYYY-MM-DDTHH:mm:ssZ)2023-06-30T23:59:59Z
entitled_product_idsarray of stringsNoList of entitled product IDs["prod_123", "prod_456"]
entitled_variant_idsarray of stringsNoList of entitled variant IDs["var_123", "var_456"]
entitled_collection_idsarray of stringsNoList of entitled collection IDs["coll_123", "coll_456"]
prerequisite_subtotal_rangearray of objectsNoPrerequisite subtotal range conditions[ {...} ]
prerequisite_quantity_rangearray of objectsNoPrerequisite quantity range conditions[ {...} ]

Prerequisite Subtotal Range Object Structure

ParameterTypeRequiredDescriptionExample
greater_than_or_equal_tostringNoMinimum subtotal amount100.0
valuestringNoSubtotal value100.0
value_percentagestringNoSubtotal percentage value10.0
value_event_typestringNoEvent type for value calculationpurchase
value_conditionstringNoCondition for value comparisongreater_than
target_typestringNoTarget type for valueline_item
target_dataarray of stringsNoTarget data for value["prod_123"]

Prerequisite Quantity Range Object Structure

ParameterTypeRequiredDescriptionExample
greater_than_or_equal_tostringNoMinimum quantity5
valuestringNoQuantity value5
value_percentagestringNoQuantity percentage value10.0
value_event_typestringNoEvent type for quantitypurchase
value_conditionstringNoCondition for quantity comparisongreater_than
target_typestringNoTarget type for quantityline_item
target_dataarray of stringsNoTarget data for quantity["prod_123"]

Response Explanation

Public Response Parameters

📘

Successful Response

ParameterTypeExampleDescription
codestring200Error code (200 indicates success)
messagestringSuccessError message
dataobject{...}Contains the price rules data
data.price_ruleobject{...}price rule object
Price Rule Object Structure
ParameterTypeExampleDescription
idstringpr_123456Unique identifier of the price rule
titlestringSummer SaleName of the price rule
valuefloat10.0Discount value amount
value_typestringfixed_amountType of discount value (fixed_amount, percentage)
usage_limitint32100Maximum number of times the rule can be used
times_usedint3245Number of times the rule has been used
allocation_methodstringeachHow the discount is allocated (each, across)
allocation_limitint321Limit of discount allocation
allocation_limit_amountfloat5.0Maximum amount for allocation limit
once_per_customerint321Whether the rule applies once per customer (1=yes, 0=no)
prerequisiteint320Prerequisite condition flag
customer_selectionstringallCustomer selection method (all, prism, explicit)
target_selectionstringallTarget selection method (all, prism, explicit)
target_typestringline_itemType of target (line_item, shipping_line)
target_price_typestringoriginalPrice type target (original, current)
created_atstring2023-06-20T15:30:00ZTimestamp when the price rule was created
updated_atstring2023-06-21T09:15:00ZTimestamp when the price rule was last updated
starts_atstring2023-06-01T00:00:00ZStart date of the price rule
ends_atstring2023-06-30T23:59:59ZEnd date of the price rule
prerequisite_customer_idsarray of strings["cust_123", "cust_456"]List of prerequisite customer IDs
prerequisite_customer_segment_idsarray of strings["seg_123", "seg_456"]List of prerequisite customer segment IDs
entitled_product_idsarray of strings["prod_123", "prod_456"]List of entitled product IDs
entitled_variant_idsarray of strings["var_123", "var_456"]List of entitled variant IDs
entitled_filter_idsarray of strings["flt_123", "flt_456"]List of entitled filter IDs
entitled_filter_listarray of strings["filter1", "filter2"]List of entitled filter list items
variant_product_idsarray of strings["prod_123", "prod_456"]List of variant product IDs
entitled_collection_idsarray of strings["coll_123", "coll_456"]List of entitled collection IDs
entitled_area_listarray of strings["area1", "area2"]List of entitled area list items
prerequisite_subtotal_rangearray of objects[ {...} ]Prerequisite subtotal range conditions
prerequisite_quantity_rangearray of objects[ {...} ]Prerequisite quantity range conditions

Error Response

FieldTypeExampleDescription
codestringInvalidParameterError http message
messagestring``Error message

API Structure Overview

Language
Credentials
Header
URL
Click Try It! to start a request and see the response here!