Create a new discount code, code can used in onetime or subscription purchase to make discount
https://api.unibee.dev/merchant/discount/new
Create a new discount code, code can used in onetime or subscription purchase to make discount
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <your_api_key> |
Content-Type | Yes | application/json (for request body) |
| Name | Type | Required | Description |
|---|---|---|---|
advance | boolean | No | AdvanceConfig, 0-false,1-true, will enable all advance config if set true |
billingType | integer | Yes | The billing type of the discount code, 1-one-time, 2-recurring, define the situation the code can be used, the code of one-time billing_type can used for all situation that effect only once, the code of recurring billing_tye can only used for subscription purchase |
code | string | Yes | The discount’s unique code, customize by merchant |
currency | string | No | The discount currency of discount code, available when discount_type is fixed_amount |
cycleLimit | integer | No | The count limitation of subscription cycle, each subscription is valid separately , 0-no limit |
discountAmount | integer | No | The discount amount of the discount code, available when discount_type is fixed_amount |
discountPercentage | integer | No | The discount percentage of discount code, 100=1%, available when discount_type is percentage |
discountType | integer | Yes | The discount type of the discount code, 1-percentage, 2-fixed_amount, the discountType of code, the discountPercentage will be effect when discountType is percentage, the discountAmount and currency will be effect when discountTYpe is fixed_amount |
endTime | integer | Yes | The end time of discount code can effect, utc time |
metadata | object | No | Metadata,Map |
name | string | No | The discount’s name |
planApplyGroup | string | No | |
planApplyType | integer | No | plan apply type, 0-apply for all, 1-apply for plans specified, 2-exclude for plans specified, 3-Apply to Plans by Groups(Billing Period Included), 4-Apply to Plans except by Groups(Billing Period Included) |
planIds | array | No | Ids of plan which discount code can effect, default effect all plans if not set |
quantity | integer | No | Quantity of code, default 0, set 0 to disable quantity management |
startTime | integer | Yes | The start time of discount code can effect, utc time |
upgradeLongPlanOnly | boolean | No | AdvanceConfig, true or false, will forbid for all except upgrade to longer plan if set true |
upgradeOnly | boolean | No | AdvanceConfig, true or false, will forbid for all except same interval upgrade action if set true |
userLimit | integer | No | AdvanceConfig, The limit of every customer can apply, the recurring apply not involved, 0-unlimited |
userScope | integer | No | AdvanceConfig, Apply user scope,0-for all, 1-for only new user, 2-for only renewals, renewals is upgrade&downgrade&renew |
code, data, message, redirect, and requestId. code 0 indicates success.
| Field | Type | Description |
|---|---|---|
code | integer | Response code. 0 = success |
data | object | Response payload |
data.discount | object | |
message | string | Human-readable message |
requestId | string | Request ID for support |
| HTTP status | Meaning |
|---|---|
| 400 | Bad request — invalid or missing parameters. Check message in the body. |
| 401 | Unauthorized — missing or invalid API key. |
| 404 | Not found — invalid path or resource. |
| 500 | Server error — retry with backoff. |
code in the response body is non-zero, check message for details. Use requestId when contacting support.Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Create a new discount code, code can used in onetime or subscription purchase to make discount
The billing type of the discount code, 1-one-time, 2-recurring, define the situation the code can be used, the code of one-time billing_type can used for all situation that effect only once, the code of recurring billing_tye can only used for subscription purchase
The discount's unique code, customize by merchant
The discount type of the discount code, 1-percentage, 2-fixed_amount, the discountType of code, the discountPercentage will be effect when discountType is percentage, the discountAmount and currency will be effect when discountTYpe is fixed_amount
The end time of discount code can effect, utc time
The start time of discount code can effect, utc time
AdvanceConfig, 0-false,1-true, will enable all advance config if set true
The discount currency of discount code, available when discount_type is fixed_amount
The count limitation of subscription cycle, each subscription is valid separately , 0-no limit
The discount amount of the discount code, available when discount_type is fixed_amount
The discount percentage of discount code, 100=1%, available when discount_type is percentage
Metadata,Map
The discount's name
plan apply type, 0-apply for all, 1-apply for plans specified, 2-exclude for plans specified, 3-Apply to Plans by Groups(Billing Period Included), 4-Apply to Plans except by Groups(Billing Period Included)
Ids of plan which discount code can effect, default effect all plans if not set
Quantity of code, default 0, set 0 to disable quantity management
AdvanceConfig, true or false, will forbid for all except upgrade to longer plan if set true
AdvanceConfig, true or false, will forbid for all except same interval upgrade action if set true
AdvanceConfig, The limit of every customer can apply, the recurring apply not involved, 0-unlimited
AdvanceConfig, Apply user scope,0-for all, 1-for only new user, 2-for only renewals, renewals is upgrade&downgrade&renew