# 为商品创建折扣促销活动

为商品创建折扣促销活动。

促销活动提供商品折扣(%)。
折扣应用于指定商品的所有价格。

Endpoint: POST /v3/project/{project_id}/admin/promotion/item
Version: 2.0.0
Security: basicAuth

## Path parameters:

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

## Request fields (application/json):

  - `name` (object, required)
    促销活动名称。应包含键/值对，
其中键是格式为"^[a-z]{2}-[A-Z]{2}$"的区域设置，值是字符串。
    Example: {"en-US":"Promotion","ru-RU":"Акция"}

  - `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"

  - `discount` (object, required)

  - `discount.percent` (string, required)
    百分比折扣。
商品价格将按照此百分比打折，然后四舍五入到小数点后两位。
    Example: 10

  - `items` (array, required)

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

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

  - `price_conditions` (array,null)
    具有设置促销价格范围的条件的对象数组。 促销仅适用于价格符合数组中所有条件的商品。如果传递此数组，请设置[items](/zh/api/shop-builder/operation/create-item-promotion/#!path=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)
    用于决定应用促销活动的价格范围的值。

  - `limits` (object)
    促销活动限制。

  - `limits.per_user` (integer,null)
    针对单独用户的促销活动限制。

  - `limits.recurrent_schedule` (object,null)
    限制数刷新周期。

  - `limits.recurrent_schedule.per_user` (any)
    用户的限制数刷新周期。

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

  - `is_enabled` (boolean)
    是否启用了促销活动。

## Response 201 fields (application/json):

  - `promotion_id` (integer)
    促销活动ID。项目内的唯一促销活动标识符。

## Response 401 fields (application/json):

  - `statusCode` (integer)
    Example: 401

  - `errorCode` (integer)
    Example: 1020

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

## Response 422 fields (application/json):

  - `statusCode` (integer)
    Example: 422

  - `errorCode` (integer)
    Example: 1102

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

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


