Skip to main content

Update a Rule Promotion

PUT 

https://useast.api.elasticpath.com/v2/rule-promotions/:promotionID

Updates an existing Rule Promotion specified by its promotion ID. This includes both semantic and syntactic validation to ensure correctness. For example, the start date must be earlier than the end date.

Editable fields include:

  • name
  • description
  • enabled
  • start
  • end
  • automatic
  • stackable
  • override_stacking
  • rule_set

Please refer to the OpenAPI examples section on this page for sample update requests.

Request

Path Parameters

    promotionID stringrequired

    The unique identifier of the promotion to be updated.

Header Parameters

    Authorization Bearerrequired

    The Bearer token required to get access to the API.

Bodyrequired

    data object
    typestring

    Possible values: [rule_promotion]

    namestring

    Specifies a name for the promotion.

    descriptionstring

    Specifies a description for the rule promotion.

    priorityinteger

    Specifies the priority order of a promotion, with larger numbers indicating higher priorities.

    enabledboolean

    Specifies whether the promotion is enabled. The options are true or false, and the default setting is false.

    automaticboolean

    Specifies whether the promotion is applied automatically to the cart or a code is required to apply the promotion. The default setting is false. When this value is set to true, a code is autogenerated. If this value is set to false, you must create the code manually.

    stackableboolean

    Specifies whether this promotion can stack with other promotions.

    override_stackingboolean

    Enables a promotion to be stacked with an otherwise non-stackable promotion.

    startdate-time

    Specifies the start date and time of the promotion or the start date of the promotion. You can provide a specific time in the HH:MM format. If no time is specified, the default start and end time is set to 00:00.

    enddate-time

    Specifies the end date and time of the promotion or the end date of the promotion.

    rule_set object
    catalog_idsstring[]

    Specifies the catalogs that are eligible for the promotion. By default, the promotion applies to all items, including custom items. However, when catalog_ids is defined, the promotion is only applied to items within the specified catalogs. If catalog IDs are specified, custom items cannot be applied as part of the promotion.

    currenciesstring[]

    Specifies currencies that are applied for the promotion.

    rules object
    strategystring

    Specifies a given strategy for the rule. Strategies determine how rules are applied. Supported strategies include cart_total, cart_custom_attribute, item_price, item_sku, item_product_id, item_quantity, item_category, item_attribute, item_identifier, items_bundle , and and or.

    operatorstring

    Specifies the operators used for the rule strategy.

    argsstring[]

    Represents the condition value associated with each rule within the rule set. It requires at least three arguments.

    children object[]
  • Array [
  • strategystring
    operatorstring
    argsstring[]
  • ]
  • actions object[]
  • Array [
  • strategystring

    Specifies the strategy for the promotion action. Supported action strategies include cart_discount, item_discount, shipping_discount, items_bundle_discount.

    argsstring[]
    condition object
    strategystring
    children object[]
  • Array [
  • strategystring
    operatorstring
    argsstring[]
  • ]
  • limitations object
    max_discountinteger

    Specifies the maximum amount of discount applied to the shopping cart.

    max_quantityinteger

    Specifies the maximum quantity of each eligible item to which the promotion is applied.

    items object
    max_itemsinteger

    Specifies the maximum number of items eligible for the discount.

    price_strategystring

    Specifies the strategy for determining which items to discount based on their individual prices.

    Possible values: [cheapest, expensive]

  • ]

Responses

OK

Schema
    data object
    typestring

    Possible values: [rule_promotion]

    idstring
    store_idstring
    namestring
    descriptionstring
    priorityinteger
    enabledboolean
    automaticboolean
    stackableboolean
    override_stackingboolean
    rule_set object
    catalog_idsstring[]
    currenciesstring[]
    rules object
    strategystring
    operatorstring
    argsstring[]
    children object[]
  • Array [
  • strategystring
    operatorstring
    argsstring[]
  • ]
  • actions object[]
  • Array [
  • strategystring
    argsstring[]
    condition object
    strategystring
    children object[]
  • Array [
  • strategystring
    operatorstring
    argsstring[]
  • ]
  • limitations object
    max_discountinteger
    max_quantityinteger
    items object
    max_itemsinteger
    price_strategystring

    Possible values: [cheapest, expensive]

  • ]
  • startdate-time
    enddate-time
    meta object
    timestamps object
    created_atdate-time
    updated_atdate-time

Authorization: http

name: BearerAuthtype: httpscheme: bearer
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put, "https://useast.api.elasticpath.com/v2/rule-promotions/:promotionID");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"data\": {\n \"type\": \"rule_promotion\",\n \"name\": \"string\",\n \"description\": \"string\",\n \"priority\": 0,\n \"enabled\": true,\n \"automatic\": true,\n \"stackable\": true,\n \"override_stacking\": true,\n \"start\": \"2024-07-29T15:51:28.071Z\",\n \"end\": \"2024-07-29T15:51:28.071Z\",\n \"rule_set\": {\n \"catalog_ids\": [\n \"string\"\n ],\n \"currencies\": [\n \"string\"\n ],\n \"rules\": {\n \"strategy\": \"string\",\n \"operator\": \"string\",\n \"args\": [\n \"string\"\n ],\n \"children\": [\n {\n \"strategy\": \"string\",\n \"operator\": \"string\",\n \"args\": [\n \"string\"\n ]\n }\n ]\n },\n \"actions\": [\n {\n \"strategy\": \"string\",\n \"args\": [\n \"string\"\n ],\n \"condition\": {\n \"strategy\": \"string\",\n \"children\": [\n {\n \"strategy\": \"string\",\n \"operator\": \"string\",\n \"args\": [\n \"string\"\n ]\n }\n ]\n },\n \"limitations\": {\n \"max_discount\": 0,\n \"max_quantity\": 0,\n \"items\": {\n \"max_items\": 0,\n \"price_strategy\": \"cheapest\"\n }\n }\n }\n ]\n }\n }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
Request Collapse all
Base URL
https://useast.api.elasticpath.com
Auth
Parameters
— pathrequired
— headerrequired
Body required
{
  "data": {
    "type": "rule_promotion",
    "name": "string",
    "description": "string",
    "priority": 0,
    "enabled": true,
    "automatic": true,
    "stackable": true,
    "override_stacking": true,
    "start": "2024-07-29T15:51:28.071Z",
    "end": "2024-07-29T15:51:28.071Z",
    "rule_set": {
      "catalog_ids": [
        "string"
      ],
      "currencies": [
        "string"
      ],
      "rules": {
        "strategy": "string",
        "operator": "string",
        "args": [
          "string"
        ],
        "children": [
          {
            "strategy": "string",
            "operator": "string",
            "args": [
              "string"
            ]
          }
        ]
      },
      "actions": [
        {
          "strategy": "string",
          "args": [
            "string"
          ],
          "condition": {
            "strategy": "string",
            "children": [
              {
                "strategy": "string",
                "operator": "string",
                "args": [
                  "string"
                ]
              }
            ]
          },
          "limitations": {
            "max_discount": 0,
            "max_quantity": 0,
            "items": {
              "max_items": 0,
              "price_strategy": "cheapest"
            }
          }
        }
      ]
    }
  }
}
ResponseClear

Click the Send API Request button above and see the response here!

We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies.