Create a batch discount code template. Template must be activated before generating child codes.
https://api.unibee.dev/merchant/discount/batch/template/new
Create a batch discount code template. Template must be activated before generating child codes.
| 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, enable advanced configurations |
billingType | integer | Yes | The billing type of the discount code, 1-one-time, 2-recurring |
codePrefix | string | Yes | The unique code prefix for this batch template, will be used as template identifier and child code prefix, length 1-20 |
currency | string | No | The discount currency, available when discount_type is fixed_amount |
cycleLimit | integer | No | The count limitation of subscription cycle, 0-no limit |
discountAmount | integer | No | The discount amount, available when discount_type is fixed_amount |
discountPercentage | integer | No | The discount percentage, 100=1%, available when discount_type is percentage |
discountType | integer | Yes | The discount type of the discount code, 1-percentage, 2-fixed_amount |
endTime | integer | Yes | The end time of discount code can effect, utc timestamp in seconds |
metadata | object | No | Metadata, custom key-value pairs |
name | string | No | The batch template’s display 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, 4-Apply to Plans except by Groups |
planIds | array | No | Ids of plan which discount code can effect |
quantity | integer | Yes | Target number of child codes to generate, max 10000 |
startTime | integer | Yes | The start time of discount code can effect, utc timestamp in seconds |
subscriptionLimit | integer | No | The limit of every subscription apply, 0-unlimited |
upgradeLongPlanOnly | boolean | No | AdvanceConfig, true-forbid for all except upgrade to longer plan |
upgradeOnly | boolean | No | AdvanceConfig, true-forbid for all except same interval upgrade action |
userLimit | integer | No | AdvanceConfig, The limit of every customer can apply, 0-unlimited |
userScope | integer | No | AdvanceConfig, Apply user scope, 0-for all, 1-for only new user, 2-for only renewals |
code, data, message, redirect, and requestId. code 0 indicates success.
| Field | Type | Description |
|---|---|---|
code | integer | Response code. 0 = success |
data | object | Response payload |
data.template | 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 batch discount code template. Template must be activated before generating child codes.
The billing type of the discount code, 1-one-time, 2-recurring
The unique code prefix for this batch template, will be used as template identifier and child code prefix, length 1-20
The discount type of the discount code, 1-percentage, 2-fixed_amount
The end time of discount code can effect, utc timestamp in seconds
Target number of child codes to generate, max 10000
The start time of discount code can effect, utc timestamp in seconds
AdvanceConfig, enable advanced configurations
The discount currency, available when discount_type is fixed_amount
The count limitation of subscription cycle, 0-no limit
The discount amount, available when discount_type is fixed_amount
The discount percentage, 100=1%, available when discount_type is percentage
Metadata, custom key-value pairs
The batch template's display name
Plan apply type, 0-apply for all, 1-apply for plans specified, 2-exclude for plans specified, 3-Apply to Plans by Groups, 4-Apply to Plans except by Groups
Ids of plan which discount code can effect
The limit of every subscription apply, 0-unlimited
AdvanceConfig, true-forbid for all except upgrade to longer plan
AdvanceConfig, true-forbid for all except same interval upgrade action
AdvanceConfig, The limit of every customer can apply, 0-unlimited
AdvanceConfig, Apply user scope, 0-for all, 1-for only new user, 2-for only renewals