Skip to main content
Version: 202201

Create Price Rule

POST 

/openapi/2022-01/price_rules

Creates a new price rule for discounts or promotions on the store.

Request

Body

    price_rule object
    titlestringrequired

    Title of this price rule

    valuedoublerequired

    Value for this discount , e.g. 50.25

    value_typestringrequired

    Discount type, options: 1. fixed_amount for fixed amount of value to be reduced, 2. percentage for percentage of the value to be reduced

    usage_limitint32

    The usage limit, -1 means no limit

    allocation_limitint32

    Redeem count limit for checkout: 0~999, 0 means only one redeem allowed, 999 means no limit

    Default value: 0
    once_per_customerint32

    The max usage per customer,-1 or 0 means no limit

    prerequisiteint32

    Does this discount has prerequisite or not, 1 means yes, 0 means no

    Default value: 1
    target_selectionstringrequired

    The target products allowed of this discount, all means all products, entitled means only for the specific products

    target_typestring

    Target type of this discount, for example: line_item, shipping_line

    Default value: line_item
    starts_atstringrequired

    Discount started at

    ends_atstringrequired

    Discount ended at, -1 means no limit

    entitled_product_idsstring[]

    Specify the target products allowed for the price rule. This field is required only when target_selection is entitled, e.g. [ "ac8ed089-55d9-4f58-a0f9-3dda4e4607cc", "0b76afba-e068-4bf6-85f5-660019f58488" ]

    entitled_variant_idsstring[]

    Specify the variants products allowed of the discount, e.g. [ "cea210d5-a419-4d4e-a17d-5bbd0bc4af76", "de2c55f5-c3e1-45e1-92f6-e65faf816ecc" ]

    entitled_collection_idsstring[]

    Specify the collections allowed of the discount, e.g. ["aa92c677-e5be-4cab-8e65-9ebc55b98240","e6152ca6-791b-4385-a9e1-49adb336b289"]

    prerequisite_subtotal_range object[]

    Prerequisite for the total amount of the money, for example: [ { "greater_than_or_equal_to": "10", "value": "1", "target_type": "", "target_data": [] } ] means total money must great than 10, then you could use the discount to reduce 1 dollar.

  • Array [
  • greater_than_or_equal_tostring

    To specify the value which the price has to greater than or equal to.

    valuestring

    The value used for the discount to apply, the reduction type is decided by value_type specified in Price Rule params

    target_typestring

    Target type

    target_datastring[]

    Target data

    Default value: []
  • ]
  • prerequisite_quantity_range object[]

    Prerequisite for the total count of the products,e.g. [ { "greater_than_or_equal_to":"5", "value":"20", "target_type":"", "target_data":[] } ] means products count must great than 5, then you could use discount to reduce 20 dollars

  • Array [
  • greater_than_or_equal_tostring

    To specify the value which the price has to greater than or equal to.

    valuestring

    The value used for the discount to apply, the reduction type is decided by value_type specified in Price Rule params

    target_typestring

    Target type

    target_datastring[]

    Target data

    Default value: []
  • ]

Responses

200

Schema
    price_rule object
    idstring
    Example: 2d7e416a-444f-4491-ae04-c50f47154140
    titlestring
    Example: TITLE
    valueinteger
    Default value: 0
    Example: 0
    value_typestring
    Example: percentage
    usage_limitstring
    Example: -1
    times_usedstring
    Example: 0
    allocation_methodstring
    Example:
    allocation_limitstring
    Example: 0
    once_per_customerstring
    Example: 1
    prerequisitestring
    Example: 1
    customer_selectionstring
    Example: all
    target_selectionstring
    Example: entitled
    target_typestring
    Example:
    created_atstring
    Example: 2020-03-06 17:00:32
    updated_atstring
    Example: 2020-03-12 15:29:44
    starts_atstring
    Example: 1583424000
    ends_atstring
    Example: 1583942399
    entitled_product_idsstring[]
    entitled_variant_idsarray
    prerequisite_quantity_range object[]
  • Array [
  • greater_than_or_equal_tostring
    Example: 1
    valuestring
    Example: 5
    target_typestring
    Example:
    target_dataarray
  • ]
  • prerequisite_subtotal_range