# Create coupons

# Interface call request specification

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

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

# Request Parameter Sample

{
    "type": 1,
    "name" : "Double 11 special offers over 100-50,"  //length <= 10
    "discount_info" : 
    {
        "discount_condition" : 
        {
            "product_cnt" : 10,//Discount Coupon
            "product_ids" : //Product coupon fill
            [
                1673110742,
                1673110743
            ],
            "product_price" : 100//Full discount coupon fill
        },
        "discount_fee" : 50,//Full reduction
        "discount_in one" : 5000//Discount coupon filling, conversion rules, such as 5000 = 50%, 7800 = 7.8%, range is 1000-10000, must be an integer of 100
    },
    "ext_info" : 
    {
        "jump_product_id" : 1673110742,//Coupons can be filled, after receiving jump
        "notes" : "Remarks,"
        "valid_time" : 1673110742,  // valid_Type = 1 with valid_info.start_Time consistent, valid_Type = 2 when the merchant fills in an absolute start time
        "invalid_time" : 1673110742 // valid_Type = 1 with valid_info.end_Time consistent, valid_Type = 2 when the merchant fills in an absolute end time
    },
    "promote_info" : 
    {
        "customize_channel" : "//Custom promotion channels, specific content " ,
        "promote_type" : 1     //Promotion type, 1: store promotion, 2: custom promotion channel
    },
    "receive_info" : // Settings that allow users to collect coupons
    {
        "end_time" : 1673110742,
        "limit_A_one_person" : 1,
        "start_time" : 1673110742,
        "total_in one" : 100
    },
    "valid_info" : 
    {
        "end_time" : 1673110742,        //Absolute effective start time, valid_Required when type = 1
        "start_time" : 1673110742,      //End time of absolute effect, valid_Required when type = 1
        "valid_day_in one" : 1,            //Relative to the time of entry into force, When the user receives the ticket, valid_Required when type = 2
         "valid_type" : 1
    }
}

# Return Package Example

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

# Request Parameter Dxplaination

parameter type Is it necessary to fill out Introductions
type number yes Coupon Type
name string yes Coupon Name
discount_info.discount_condition.product_cnt number no Discount Amount of Merchandise Coupon
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 price, full discount coupon need to fill in
discount_info.discount_fee number yes Full reduction
discount_info.discount_A number no The number of discounted goods, the full coupon to fill, conversion rules, 5000 = 50 fold, 7000 = 30 fold, the range is 1000-10000, must be an integer of 100
ext_info.invalid_time number yes Coupon Expiration Time Stamp
ext_info.jump_product_id number no Product id after receiving discount coupon
ext_info.notes string no Remarks information
ext_info.valid_time number yes Coupon Valid Time Stamp
promote_info.customize_channel string yes User-defined promotion channels
promote_info.promote_type number yes Type of promotion
receive_info.end_time number yes Coupon End Time Stamp
receive_info.limit_A_one_person number yes Single Limited Tickets
receive_info.start_time number yes Coupon Collection Start Time Stamp
receive_info.total_A number yes Total number of coupons received
valid_info.end_time number no Coupon end time, if you fill out start
valid_info.start_time number no Coupon Validity Start Time, and Valid_day_Num choose two
valid_info.valid_day_A number yes Coupon Validity Number of Days, and Start_Time Choice Two
valid_info.valid_type number yes Coupon Validity Type

# Return parameter specification

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

# Enumerate - coupon _type

Enumeration value describe
1 Commodity conditions coupon, discount_condition.product_ids, discount_condition.product_cnt, discount_info.discount_A Required
2 Commodities full discount coupon, discount_condition.product_ids, discount_condition.product_price, discount_info.discount_fee Required
3 Product unified discount coupon, discount_condition.product_ids, discount_info.discount_Num Required
4 Commodities Direct Discount Coupon, If less than the minimum price of the available item will alert(No goods when more than 50w reminder), discount_condition.product_ids, discount_fee Required
101 Store Condition Discount Coupon, discount_condition.product_cnt, discount_info.discount_Num Required
102 Shop full discount coupons, discount_condition.product_price, discount_info.discount_fee Required
103 Shop unified discount coupon, discount_info.discount_A Required
104 Shop direct discount coupons, If less than the minimum price of the available item will alert(No goods when more than 50w reminder), discount_fee Required

# Enumerations-valid_type

Enumeration value describe
1 Specified timeframe takes effect
2 Days of entry into force

# Return code

Return code Type of error
-1 System exception
-2 Token is too long
9401020 Wrong parameter