Plan Apply Preview
Check discount can apply to plan, Only check rules about plan,the actual usage is subject to the subscription interface
Endpoint Overview
POSThttps://api.unibee.dev/merchant/discount/plan_apply_preview
Check discount can apply to plan, Only check rules about plan,the actual usage is subject to the subscription interface
Authorization
All UniBee Merchant API requests require authentication via API key.| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <your_api_key> |
Content-Type | Yes | application/json (for request body) |
Parameters
Parameters for this endpoint are listed below. The schema is also shown in the Try it panel.Request body
| Name | Type | Required | Description |
|---|---|---|---|
addonParams | array | No | Addon list with quantity, align with subscription create preview |
code | string | Yes | The discount’s unique code, customize by merchant |
currency | string | No | The currency of plan which code to apply |
email | string | No | |
externalPlanId | string | No | The externalId of plan which code to apply, either planId or externalPlanId is needed |
isChangeToLongPlan | boolean | No | IsChangeToLongPlan |
isChangeToSameIntervalPlan | boolean | No | IsChangeToSameIntervalPlan |
isUpgrade | boolean | No | IsUpgrade |
planId | integer | No | The id of plan which code to apply, either planId or externalPlanId is needed |
quantity | integer | No | Main plan quantity, default 1; align with subscription create preview |
Request examples
cURL
Sandbox
Response
Success responses return a JSON envelope withcode, data, message, redirect, and requestId. code 0 indicates success.
| Field | Type | Description |
|---|---|---|
code | integer | Response code. 0 = success |
data | object | Response payload |
data.allPlansAllowed | boolean | True = discount applies to all plans in cart; false = only to allowedPlanIds |
data.allowedPlanIds | array | Plan ids that get this discount (when partial apply); empty or same as main+addons when all plans allowed |
data.discountAmount | integer | The discount amount can apply to plan |
data.discountCode | object | |
data.failureReason | string | The apply preview failure reason |
data.valid | boolean | The apply preview result, true or false |
message | string | Human-readable message |
requestId | string | Request ID for support |
Error handling
| 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.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Check discount can apply to plan, Only check rules about plan,the actual usage is subject to the subscription interface
The discount's unique code, customize by merchant
Addon list with quantity, align with subscription create preview
The currency of plan which code to apply
The externalId of plan which code to apply, either planId or externalPlanId is needed
IsChangeToLongPlan
IsChangeToSameIntervalPlan
IsUpgrade
The id of plan which code to apply, either planId or externalPlanId is needed
Main plan quantity, default 1; align with subscription create preview

