# 创建优惠券促销活动

创建优惠券促销活动。

Endpoint: POST /v3/project/{project_id}/admin/coupon
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):

  - `external_id` (string, required)
    唯一促销活动ID。 external_id只能包含大小写英文字母和数字字符、句点、破折号和下划线。

  - `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)
    每个代码的核销次数。

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

## Response 201 fields (application/json):

  - `external_id` (string)
    唯一促销活动ID。 external_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 `external_id` is required"


