# 更新兑换码促销活动

更新兑换码促销活动。

Endpoint: PUT /v3/project/{project_id}/admin/promocode/{external_id}
Version: 2.0.0
Security: basicAuth

## Path parameters:

  - `project_id` (integer, required)
    项目ID。您可以在发布商帐户的项目名称旁找到此参数；使用项目时，也可以在浏览器地址栏中找到此参数。URL格式如下：https://publisher.xsolla.com//projects/。
    Example: 44056

  - `external_id` (integer, required)
    促销活动外部ID。项目内的唯一促销活动标识符。
    Example: "coupon_44056_1"

## Request fields (application/json):

  - `promotion_periods` (array)
    促销活动有效期。若指定了多个时间段，则date_from和date_until均为必需。

  - `promotion_periods.date_from` (string, required)
    指定促销活动的开始日期。
    Example: "2020-08-11T10:00:00+03:00"

  - `promotion_periods.date_until` (string,null)
    促销活动的结束日期。设置为null时，促销活动永久有效。仅在指定单个有效期时可设置为null。
    Example: "2020-08-11T20:00:00+03:00"

  - `name` (object, required)
    促销活动名称。应包含键/值对，
其中键是"^[a-z]{2}-[A-Z]{2}$"格式的区域设置，值是字符串。

  - `bonus` (array,null)

  - `bonus.sku` (string)
    商品SKU。

  - `bonus.quantity` (number)
    商品数量。

  - `redeem_total_limit` (integer,null)
    限制优惠券的总数。

  - `redeem_user_limit` (integer,null)
    限制单个用户兑换的优惠券总数。

  - `redeem_code_limit` (integer,null)
    每个代码的核销次数。

  - `discount` (object,null)
    Example: {"percent":"10.10"}

  - `discount.percent` (string,null)
    百分比折扣。
购物车价格将按照此百分比打折，然后四舍五入到小数点后两位。
    Example: "10.10"

  - `discounted_items` (array,null)
    通过兑换码享受折扣的商品列表。

  - `discounted_items.sku` (string, required)
    商品SKU。

  - `discounted_items.discount` (object, required)

  - `discounted_items.discount.percent` (string, required)
    百分比折扣。

购物车商品价格将按照此百分比打折，
然后四舍五入到小数点后两位。

  - `attribute_conditions` (array)
    用于验证用户属性的条件。根据用户属性是否匹配所有指定条件，确定促销活动是否可用。

  - `price_conditions` (array,null)
    包含条件的对象数组，用于设置对整个购物车应用促销活动的价格范围。
系统会将用户购物车中所有商品的总价与条件中指定的价格范围进行比较。如果购物车价格满足指定条件，则会对购物车中的所有商品应用[赠品](/zh/api/shop-builder/operation/create-promo-code/#!path=bonus&t=request)和[折扣](/zh/api/shop-builder/operation/create-promo-code/#!path=discount&t=request)
如果传入此数组，请将[discounted_items](/zh/api/shop-builder/operation/create-promo-code/#!path=discounted_items&t=request)数组的值设置为null。

  - `price_conditions.operator` (string, required)
    用于设置应用促销活动的价格范围的比较运算符。

可能值：
- ge — 大于或等于
- gt — 大于
- le — 小于或等于
- lt — 小于
- eq — 等于
- ne — 不等于
    Enum: "ge", "gt", "le", "lt", "eq", "ne"

  - `price_conditions.value` (string, required)
    用于决定应用促销活动的价格范围的值。

  - `item_price_conditions` (array,null)
    包含条件的对象数组，用于设置对购物车中特定商品应用促销活动的价格范围。
系统会将用户购物车中每个商品的价格与条件中指定的价格范围进行比较。只有购物车中价格满足条件的商品才会应用[赠品](/zh/api/shop-builder/operation/create-promo-code/#!path=bonus&t=request)和[折扣](/zh/api/shop-builder/operation/create-promo-code/#!path=discount&t=request)
如果传入此数组，请将[discounted_items](/zh/api/shop-builder/operation/create-promo-code/#!path=discounted_items&t=request)数组的值设置为null。

  - `item_price_conditions.operator` (string, required)
    用于设置应用促销活动的价格范围的比较运算符。

可能值：
- ge — 大于或等于
- gt — 大于
- le — 小于或等于
- lt — 小于
- eq — 等于
- ne — 不等于
    Enum: "ge", "gt", "le", "lt", "eq", "ne"

  - `item_price_conditions.value` (string, required)
    用于决定应用促销活动的价格范围的值。

  - `excluded_promotions` (array)
    应用此促销活动时要排除的促销活动ID列表。示例：[12, 789]

## Response 401 fields (application/json):

  - `statusCode` (integer)
    Example: 401

  - `errorCode` (integer)
    Example: 1020

  - `errorMessage` (string)
    Example: "[0401-1020]: Error in Authentication method occurred"

## Response 404 fields (application/json):

  - `statusCode` (integer)
    Example: 404

  - `errorCode` (integer)
    Example: 4001

  - `errorMessage` (string)
    Example: "[0401-9802]: Promocode not found"

  - `transactionId` (string)
    Example: "x-x-x-x-transactionId-mock-x-x-x"

## Response 422 fields (application/json):

  - `statusCode` (integer)
    Example: 422

  - `errorCode` (integer)
    Example: 1102

  - `errorMessage` (string)
    Example: "[0401-1102]: Unprocessable Entity. The property `external_id` is required"


## Response 204 fields
