**Version: 202701**

# Update automatic discount

**PUT** `/openapi/2027-01/discounts/automatic/:id`

Updates an automatic discount by ID.

## Request

**Path Parameters**

- `id` string (required)

  Discount ID

**application/json**

**Body | Example**

**Body (required)**

- `discount` object (required)

  Discount data for automatic mode

  - `discount_info` object

    Updated core discount metadata

    - `discount_name` string

      Merchant-facing discount name
    - `display_name` string

      Storefront display name
    - `starts_at` int32

      Start timestamp
    - `ends_at` int32

      End timestamp. -1 means the discount runs indefinitely
  - `entitled_customer` object

    Updated customer eligibility settings

    - `customer_ids` string[]

      Explicit customer IDs that can use the discount. Defaults to all customers if not specified
    - `customer_segment_ids` string[]

      Customer segment IDs that can use the discount
  - `entitled_product` object

    Updated product eligibility settings

    - `product_ids` string[]

      Product IDs included in the entitled scope. Defaults to all products if not specified
    - `variant_ids` string[]

      Variant IDs included in the entitled scope
    - `collection_ids` string[]

      Collection IDs included in the entitled scope
    - `sort` object

      Sorting settings for entitled products

      - `by` string

        The field used to sort selected products
      - `direction` string

        The sort direction, for example asc or desc
    - `selection` string

      Selection strategy identifier:

      *   `entitled`: Only entitled products are included
      *   `exclude`: Entitled products are excluded
      *   `all`: All products are included. (default)
    - `sku_extends` object

      Per-variant extended settings keyed by variant ID

      - `property name*` SkuExtendReq

        - `obtain_value` string

          Discount value for this variant. Currently only supports fixed price reduction; stored as a string
        - `min_purchase_qty` uint32

          Minimum purchase quantity for this variant
        - `seq` uint32

          Custom display sequence number for sorting
        - `virtual_sales` int32

          Virtual sales count configured for this variant
        - `follow_stock` string

          Whether the activity stock follows the product stock:

          *   `product`: Follow product stock
          *   `discount`: Use discount stock
        - `stock` int32

          Activity-level stock limit for this variant
        - `collection_id` string

          Collection ID if this variant was selected via a collection
  - `discount_rule` object

    Updated global rule settings

    - `limit_max_discount` int32

      Maximum total usage count of the discount; -1 means unlimited
    - `limit_user_discount` int32

      Maximum usage count per customer; -1 means unlimited
    - `limit_order_discount` int32

      Maximum usage count per order; -1 means unlimited
    - `limit_user_product_type` string

      Per-customer product limit strategy type:

      *   `no_limit`: No per-product purchase limit
      *   `customer_all_product`: Per customer per discount, accumulated across all eligible variants
      *   `customer_product`: Per customer per discount per product
      *   `customer_variant`: Per customer per discount per variant
    - `limit_user_product_discount` int32

      Max times a customer can purchase each eligible product under the discount
    - `price_rule` string

      Price base used for discount calculation:

      *   `price`: Use sale price
      *   `compare_at_price`: Use compare-at/original price
    - `product_discount_order` string

      Product ordering strategy used when applying discounts:

      *   `desc`: Apply by product price in descending order
      *   `asc`: Apply by product price in ascending order
    - `virtual_sales` int32

      Virtual sales value used for display or ranking
    - `stock` int32

      Discount stock when stock-based limiting is enabled
    - `follow_stock` string

      Whether the promotion stock follows the product stock:

      *   `product`: Use product stock
      *   `discount`: Set a custom promotion stock
    - `discount_combines` string[]

      Other discount categories that can be combined:

      *   `product`: Can combine with product discounts
      *   `order`: Can combine with order discounts
      *   `shipping`: Can combine with shipping discounts
    - `mn_discount_scope` string

      Scope strategy for multi-layer discount evaluation:

      *   `highest`: Apply the highest matched layer only
      *   `all`: Apply all matched layers
      *   `highest_all`: Apply all matched layers; quantities above the highest layer use the highest-layer benefit
  - `discount_layer` object

    Updated layered discount settings

    - `condition_type` string

      Condition type:

      *   `no_condition`: No condition required
      *   `purchase_quantity`: Requires purchase quantity
      *   `purchase_amount`: Requires purchase amount
    - `obtain_type` string

      Benefit type:

      *   `no_discount`: No discount
      *   `free_acquisition`: Free acquisition
      *   `percent`: Percentage discount
      *   `fixed_price_reduction`: Fixed amount reduction
      *   `fixed_price`: Fixed final price
      *   `fixed_quantity`: Fixed quantity granted
      *   `product_price_reduction`: Product-level price reduction
    - `layers` object[]

      Layered discount rules from lower to higher thresholds

      *   Array \[

      - `condition_value` string

        Condition threshold value for this layer
      - `obtain_value` string

        Discount value granted when the condition is met
      - `obtain_count` uint32

        Number of items granted as the discount benefit
      *   \]

```json
{
  "discount": {
    "discount_info": {
      "discount_name": "string",
      "display_name": "string",
      "starts_at": 0,
      "ends_at": 0
    },
    "entitled_customer": {
      "customer_ids": [
        "string"
      ],
      "customer_segment_ids": [
        "string"
      ]
    },
    "entitled_product": {
      "product_ids": [
        "string"
      ],
      "variant_ids": [
        "string"
      ],
      "collection_ids": [
        "string"
      ],
      "sort": {
        "by": "string",
        "direction": "string"
      },
      "selection": "string",
      "sku_extends": {}
    },
    "discount_rule": {
      "limit_max_discount": 0,
      "limit_user_discount": 0,
      "limit_order_discount": 0,
      "limit_user_product_type": "string",
      "limit_user_product_discount": 0,
      "price_rule": "string",
      "product_discount_order": "string",
      "virtual_sales": 0,
      "stock": 0,
      "follow_stock": "string",
      "discount_combines": [
        "string"
      ],
      "mn_discount_scope": "string"
    },
    "discount_layer": {
      "condition_type": "string",
      "obtain_type": "string",
      "layers": [
        {
          "condition_value": "string",
          "obtain_value": "string",
          "obtain_count": 0
        }
      ]
    }
  }
}
```

## Responses

**200**

OK

**application/json**

**Schema | Example**

**Schema**

- `code` string

  error code
- `message` string

  error message
- `data` object

  - `discount` object

    Discount detail payload

    - `discount_info` object

      Core discount information

      - `id` string

        Discount ID
      - `discount_name` string

        Merchant-facing discount name
      - `display_name` string

        Storefront display name
      - `discount_target` string

        Discount target category:

        *   `product`: Product discount
        *   `order`: Order discount
        *   `shipping`: Shipping discount
      - `category` string

        Discount category, top-level discount type:

        *   `buy_one_get_one`: Buy one get one
        *   `buy_x_get_y`: Buy X get Y
        *   `bundle`: Bundle discount
        *   `rebate`: Rebate discount
        *   `m_n_discount`: M-for-N discount
        *   `flash_sale`: Flash sale
        *   `code`: Discount code
        *   `coupon_old`: Legacy coupon
        *   `plugin_old`: Legacy plugin
        *   `rebate_old`: Legacy rebate
        *   `cycle_subscribe_old`: Legacy cycle subscription
      - `discount_type` string

        Discount type identifier:

        *   `rebate_cta_otr`: Amount-threshold fixed reduction
        *   `rebate_ctq_otr`: Quantity-threshold fixed reduction
        *   `rebate_cta_otp`: Amount-threshold percentage discount
        *   `rebate_ctq_otp`: Quantity-threshold percentage discount
        *   `m_n_discount`: M-for-N discount
        *   `flashsale`: Flash sale discount
        *   `code_percent`: Discount-code percentage discount
        *   `code_fix_price_reduction`: Discount-code fixed reduction
        *   `code_bxgy`: Discount-code buy X get Y
        *   `code_free_shipping`: Discount-code free shipping
      - `discount_method` string

        Discount application method identifier:

        *   `automatic`: Applied automatically
        *   `discount_code`: Applied by discount code
      - `discount_code` string

        Primary discount code
      - `discount_codes` string[]

        All discount codes under this discount
      - `starts_date` string

        Start datetime string in center/store format
      - `ends_date` string

        End datetime string in center/store format
      - `starts_at` int32

        Start timestamp
      - `ends_at` int32

        End timestamp
      - `created_at` string

        Creation datetime string
      - `updated_at` string

        Last update datetime string
      - `is_old_discount` boolean

        Whether this discount is old discount
      - `progress` string

        Current progress status:

        *   `ongoing`: Ongoing
        *   `not_started`: Not started
        *   `finished`: Finished
        *   `paused`: Paused
      - `enable_all_customer` boolean

        Whether all customers are enabled
      - `is_show_admin` string

        Backoffice visibility marker
      - `time_used` int32

        Number of times this discount has been used
    - `entitled_customer` object

      Customer scope of the discount

      - `customer_ids` string[]

        Explicit customer IDs that can use the discount
      - `customer_segment_ids` string[]

        Customer segment IDs that can use the discount
    - `entitled_product` object

      Product scope of the discount

      - `product_ids` string[]

        Product IDs included in the entitled scope
      - `variant_ids` string[]

        Variant IDs included in the entitled scope
      - `collection_ids` string[]

        Collection IDs included in the entitled scope
      - `sort` object

        Sorting settings for entitled products

        - `by` string

          The field used to sort selected products
        - `direction` string

          The sort direction
        - `before` string

          If non-empty, sort by time range for legacy flash sale compatibility. Unit: seconds
      - `selection` string

        Selection strategy identifier:

        *   `entitled`: Only entitled products are included
        *   `exclude`: Entitled products are excluded
        *   `all`: All products are included
      - `sku_extends` object

        Per-variant extended settings keyed by variant ID

        - `property name*` SkuExtendResp

          - `obtain_value` string

            Discount value for this variant. Currently only supports fixed price reduction; stored as a string
          - `min_purchase_qty` uint32

            Minimum purchase quantity for this variant
          - `seq` uint32

            Custom display sequence number for sorting
          - `virtual_sales` int32

            Virtual sales count configured for this variant
          - `follow_stock` string

            Whether the activity stock follows the product stock:

            *   `product`: Follow product stock
            *   `discount`: Use discount stock
          - `stock` int32

            Activity-level stock limit for this variant
          - `collection_id` string

            Collection ID if this variant was selected via a collection
    - `obtain_product` object

      Product scope that receives the obtained benefit. Only present for automatic discounts

      - `product_ids` string[]

        Product IDs included in the entitled scope
      - `variant_ids` string[]

        Variant IDs included in the entitled scope
      - `collection_ids` string[]

        Collection IDs included in the entitled scope
      - `sort` object

        Sorting settings for entitled products

        - `by` string

          The field used to sort selected products
        - `direction` string

          The sort direction
        - `before` string

          If non-empty, sort by time range for legacy flash sale compatibility. Unit: seconds
      - `selection` string

        Selection strategy identifier:

        *   `entitled`: Only entitled products are included
        *   `exclude`: Entitled products are excluded
        *   `all`: All products are included
      - `sku_extends` object

        Per-variant extended settings keyed by variant ID

        - `property name*` SkuExtendResp

          - `obtain_value` string

            Discount value for this variant. Currently only supports fixed price reduction; stored as a string
          - `min_purchase_qty` uint32

            Minimum purchase quantity for this variant
          - `seq` uint32

            Custom display sequence number for sorting
          - `virtual_sales` int32

            Virtual sales count configured for this variant
          - `follow_stock` string

            Whether the activity stock follows the product stock:

            *   `product`: Follow product stock
            *   `discount`: Use discount stock
          - `stock` int32

            Activity-level stock limit for this variant
          - `collection_id` string

            Collection ID if this variant was selected via a collection
    - `discount_rule` object

      Rule settings for limit and behavior

      - `limit_max_discount` int32

        Maximum total usage count of the discount; -1 means unlimited
      - `limit_user_discount` int32

        Maximum usage count per customer; -1 means unlimited
      - `limit_order_discount` int32

        Maximum usage count per order; -1 means unlimited
      - `limit_user_product_type` string

        Per-customer product limit strategy type:

        *   `no_limit`: No per-product purchase limit
        *   `customer_all_product`: Per customer per discount, accumulated across all eligible variants
        *   `customer_product`: Per customer per discount per product
        *   `customer_variant`: Per customer per discount per variant
      - `limit_user_product_discount` int32

        Max times a customer can purchase each eligible product under the discount
      - `stock` int32

        Discount stock when stock-based limiting is enabled
      - `follow_stock` string

        Whether the promotion stock follows the product stock:

        *   `product`: use product stock
        *   `discount`: set a custom promotion stock
      - `virtual_sales` int32

        Virtual sales value used for display or ranking
      - `price_rule` string

        Price base used for discount calculation:

        *   `price`: Use sale price
        *   `compare_at_price`: Use compare-at/original price
      - `extends` string

        Reserved extension payload
      - `product_discount_order` string

        Product ordering strategy used when applying discounts:

        *   `desc`: Apply by product price in descending order
        *   `asc`: Apply by product price in ascending order
      - `discount_combines` string[]

        Other discount categories that can be combined:

        *   `product`: Can combine with product discounts
        *   `order`: Can combine with order discounts
        *   `shipping`: Can combine with shipping discounts
      - `obtain_full` boolean

        Whether all required items must be fully met
      - `mn_discount_scope` string

        Scope strategy for multi-layer discount evaluation:

        *   `highest`: Apply the highest matched layer only
        *   `all`: Apply all matched layers
        *   `highest_all`: Apply all matched layers; quantities above the highest layer use the highest-layer benefit
      - `limit_code_max_discount` int32

        Maximum usage count per discount code; -1 means unlimited. Only applicable to non-automatic discounts
      - `limit_code_user_discount` int32

        Maximum usage count per customer per discount code. Only applicable to non-automatic discounts
      - `enable_product_extends` boolean

        Whether per-product extension discount settings are enabled
    - `discount_layer` object

      Layered discount settings

      - `condition_type` string

        Condition type:

        *   `no_condition`: No condition required
        *   `purchase_quantity`: Requires purchase quantity
        *   `purchase_amount`: Requires purchase amount
      - `obtain_type` string

        Benefit type:

        *   `no_discount`: No discount
        *   `free_acquisition`: Free acquisition
        *   `percent`: Percentage discount
        *   `fixed_price_reduction`: Fixed amount reduction
        *   `fixed_price`: Fixed final price
        *   `fixed_quantity`: Fixed quantity granted
        *   `product_price_reduction`: Product-level price reduction
      - `layers` object[]

        Layered discount rules from lower to higher thresholds

        *   Array \[

        - `condition_value` string

          Condition threshold value for this layer
        - `obtain_value` string

          Discount value granted when the condition is met
        - `obtain_count` uint32

          Number of items granted as the discount benefit
        *   \]
    - `discount_combine` object

      Combined-discount settings

      - `use_with_other` boolean

        Whether this discount can be combined with other promotions
    - `entitled_area` object

      Geographic areas where the discount can be applied. Only present for non-automatic discounts

      - `areas` object[]

        Geographic areas where the discount can be applied

        *   Array \[

        - `country_code` string

          ISO country code
        - `province_codes` string[]

          Province or region codes under the country
        *   \]

```json
{
  "code": "string",
  "message": "string",
  "data": {
    "discount": {
      "discount_info": {
        "id": "string",
        "discount_name": "string",
        "display_name": "string",
        "discount_target": "string",
        "category": "string",
        "discount_type": "string",
        "discount_method": "string",
        "discount_code": "string",
        "discount_codes": [
          "string"
        ],
        "starts_date": "string",
        "ends_date": "string",
        "starts_at": 0,
        "ends_at": 0,
        "created_at": "string",
        "updated_at": "string",
        "is_old_discount": true,
        "progress": "string",
        "enable_all_customer": true,
        "is_show_admin": "string",
        "time_used": 0
      },
      "entitled_customer": {
        "customer_ids": [
          "string"
        ],
        "customer_segment_ids": [
          "string"
        ]
      },
      "entitled_product": {
        "product_ids": [
          "string"
        ],
        "variant_ids": [
          "string"
        ],
        "collection_ids": [
          "string"
        ],
        "sort": {
          "by": "string",
          "direction": "string",
          "before": "string"
        },
        "selection": "string",
        "sku_extends": {}
      },
      "obtain_product": {
        "product_ids": [
          "string"
        ],
        "variant_ids": [
          "string"
        ],
        "collection_ids": [
          "string"
        ],
        "sort": {
          "by": "string",
          "direction": "string",
          "before": "string"
        },
        "selection": "string",
        "sku_extends": {}
      },
      "discount_rule": {
        "limit_max_discount": 0,
        "limit_user_discount": 0,
        "limit_order_discount": 0,
        "limit_user_product_type": "string",
        "limit_user_product_discount": 0,
        "stock": 0,
        "follow_stock": "string",
        "virtual_sales": 0,
        "price_rule": "string",
        "extends": "string",
        "product_discount_order": "string",
        "discount_combines": [
          "string"
        ],
        "obtain_full": true,
        "mn_discount_scope": "string",
        "limit_code_max_discount": 0,
        "limit_code_user_discount": 0,
        "enable_product_extends": true
      },
      "discount_layer": {
        "condition_type": "string",
        "obtain_type": "string",
        "layers": [
          {
            "condition_value": "string",
            "obtain_value": "string",
            "obtain_count": 0
          }
        ]
      },
      "discount_combine": {
        "use_with_other": true
      },
      "entitled_area": {
        "areas": [
          {
            "country_code": "string",
            "province_codes": [
              "string"
            ]
          }
        ]
      }
    }
  }
}
```
