# Create a coupon

# Dxplaination of Interface Call Request

When creating the coupon, status = 1, note that all the time fields below are timestamps in seconds!

Http request method: POST
https://api.weixin.qq.com/product/coupon/create?access_token=xxxxxxxxx 

# Example of request parameters

{
    "type": 1,
    "name" : "Double 11 specials are 100-50,"  //length <= 10
    "discount_info" : 
    {
        "discount_condition" : 
        {
            "product_CNT  : 10,//Merchandise discount vouchers are filled out
            "product_ids" : //Product coupons fill out
            [
                1673110742,
                1673110743
            ],
            "product_price" : 100//Fill out the full reduced coupon
        },
        "discount_fee" : 50,//Full amount reduced
        "discount_num" : 5000//Discount coupon filling, conversion rules, such as 5000 = 5 discount, 7800 = 7.8 discount, the range is 1000-10000, and must be an integer of 100.
    },
    "ext_info" : 
    {
        "jump_product_id" : 1673110742,//Product coupons can be filled in, jump to receive them
        "notes" : "Note,"
        "valid_time" : 1673110742,  // valid_Valid when type = 1_info.start_Time is consistent, valid_Type = 2 when the business itself to fill in an absolute start time
        "invalid_time" : 1673110742 // valid_Valid when type = 1_info.end_Time is consistent, valid_Type = 2 when the business itself fills in an absolute end time
    },
    "promote_info" : 
    {
        "customize_channel" : "//Customize promotional channel, specific content " ,
        "promote_type" : 1     //Promotion Types, 1: In-store Promotion, 2: Custom Promotion Channels
    },
    "receive_info" : // Settings that allow users to collect coupons
    {
        "end_time" : 1673110742,
        "limit_num_one_person" : 1,
        "start_time" : 1673110742,
        "total_num" : 100
    },
    "valid_info" : 
    {
        "end_time" : 1673110742,        //Absolute entry into force starting time, valid_Required when type = 1
        "start_time" : 1673110742,      //The end date of absolute entry into force, valid_Required when type = 1
        "valid_day_num" : 1,            //Relative duration of entry into force, Starting with the time the user receives the coupon, valid_Required when type = 2
         "valid_type" : 1
    }
}

# Examples of back-up

{
    "errcode": 0,
    "errmsg": "ok",
    "data": {
        "coupon_id": 111
    }
}

# Dxplaination of request parameters

parameter type Is it compulsory? Introductions
type number yes Types of coupons
Name string yes Coupon Name
discount_info.discount_condition.product_CNT number no The amount of discounted merchandise vouchers
discount_info.discount_condition.product_ids number no Product id, product discount coupon need to fill in
discount_info.discount_condition.product_price number no Product prices, full coupons need to be filled in
discount_info.discount_fee number no The amount reduced is in units. Direct reductions and full reductions are required
discount_info.discount_num number no Number of items discounted, full discount vouchers need to be filled in, conversion rules, 5000 = 5 discount, 7000 = 7 discount, range is 1000 - 10000, must be an integer of 100
ext_info.invalid_Time number yes Coupon expiration timestamp
ext_info.jump_product_id number no The product id of the jump after the product discount coupon is received
ext_info.notes string no Note information
ext_info.valid_Time number yes Coupon Expiration Date
promote_info.customize_channel string yes User-Defined Promotion Channel
promote_info.promote_type number yes Types of promotion
receive_info.end_Time number yes Coupon Acceptance End Time Stamp
receive_info.limit_num_one_person number yes Limit on number of tickets per person
receive_info.start_Time number yes Coupon Acceptance Begins Date
receive_info.total_num number yes Total number of coupons received
valid_info.end_Time number no Voucher expiration date, if start is required
valid_info.start_Time number no Coupon valid start time, and valid_day_Num Choose One
valid_info.valid_day_num number yes Number of days the coupon is valid, and start_Time to choose one
valid_info.valid_type number yes Type of coupon validity

# Dxplaination of callback parameters

parameter type Introductions
Error code number Error code
errmsg string Error message
data.coupon_id number Coupon ID

# Enumeration - coupon _type

The enumeration value describe
1 Goods conditions coupon, discount_condition.product_ids, discount_condition.product_CNT, discount_info.discount_num Required to fill in
2 Commodities are sold off full coupons, discount_condition.product_ids, discount_condition.product_price, discount_info.discount_fee Required to fill in
3 Uniform discount coupons for goods, discount_condition.product_ids, discount_info.discount_Num required
4 Direct coupons for commodities, A reminder if it is less than the minimum price in the item available(More than 50w reminder when no item is available), discount_condition.product_ids, discount_fee Required to fill in
101 Shop conditions Discount vouchers, discount_condition.product_CNT, discount_info.discount_Num required
102 Stores are full of coupons, discount_condition.product_price, discount_info.discount_fee Required to fill in
103 Stores have unified discount coupons, discount_info.discount_num Required to fill in
104 Shops cut coupons directly, A reminder if it is less than the minimum price in the item available(More than 50w reminder when no item is available), discount_fee Required to fill in

# Enumeration - valid _type

The enumeration value describe
1 The specified time frame takes effect
2 Number of days in effect

# Return code

Return code Error Type
-1 System exceptions
-2 Token too long
9401020 The parameter is incorrect.