# 创建促销码活动 创建促销码活动。 Endpoint: POST /v3/project/{project_id}/admin/promocode Version: 2.0.0 Security: basicAuth ## Path parameters: - `project_id` (integer, required) 项目ID。您可以在您的发布商帐户项目名称旁边找到。 Example: 44056 ## Request fields (application/json): - `attribute_conditions` (array) 用户属性验证条件。 根据用户属性是否满足所有指定条件来确定促销活动可用性。 - `bonus` (array,null) - `bonus.quantity` (number) 商品数量。 - `bonus.sku` (string) 物品 SKU。 - `discount` (object,null) Example: {"percent":"10.10"} - `discount.percent` (string,null) 百分比折扣。 购物车价格将按照此百分比打折,然后四舍五入到小数点后两位。 Example: "10.00" - `discounted_items` (array,null) 通过促销码打折的商品列表。 - `excluded_promotions` (array) 应用此促销活动时要排除的促销活动ID列表。Example:[12, 789] Example: [12,789] - `external_id` (string, required) 唯一促销活动ID。 external_id只能包含大小写英文字母和数字字符、句点、破折号和下划线。 Example: "coupon_external_id" - `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) 用于设置应用促销活动的价格范围的比较运算符。 Enum: "ge", "gt", "le", "lt", "eq", "ne" - `item_price_conditions.value` (string, required) 用于决定应用促销活动的价格范围的值。 - `name` (object, required) 促销活动名称。应包含键/值对, 其中键是"^[a-z]{2}-[A-Z]{2}$"格式的区域设置,值是字符串。 Example: {"de-DE":"Gutscheintitel","en-US":"Coupon title"} - `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。 - `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" - `redeem_code_limit` (integer,null) 每个代码的兑换次数。 Example: 10 - `redeem_total_limit` (integer,null) 限制优惠券的总数。 Example: 10 - `redeem_user_limit` (integer,null) 限制单个用户兑换的优惠券总数。 Example: 10 ## Response 201 fields (application/json): - `external_id` (string) 唯一促销活动ID。 external_id只能包含大小写英文字母和数字字符、句点、破折号和下划线。 Example: "coupon_external_id" ## Response 401 fields (application/json): - `errorCode` (integer) Example: 1020 - `errorMessage` (string) Example: "[0401-1020]: Error in Authentication method occurred" - `statusCode` (integer) Example: 401 ## Response 422 fields (application/json): - `errorCode` (integer) Example: 1102 - `errorMessage` (string) Example: "[0401-1102]: Unprocessable Entity. The property `external_id` is required" - `statusCode` (integer) Example: 422