Skip to main content
POST
/
merchant
/
discount
/
new
New Discount Code
curl --request POST \
  --url https://api.unibee.dev/merchant/discount/new \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "billingType": 123,
  "code": "<string>",
  "discountType": 123,
  "endTime": 123,
  "startTime": 123,
  "advance": true,
  "currency": "<string>",
  "cycleLimit": 123,
  "discountAmount": 123,
  "discountPercentage": 123,
  "metadata": {},
  "name": "<string>",
  "planApplyGroup": {
    "currency": [
      "<string>"
    ],
    "groupPlanIntervalSelector": [
      {
        "intervalCount": 123,
        "intervalUnit": "<string>"
      }
    ],
    "type": [
      123
    ]
  },
  "planApplyType": 123,
  "planIds": [
    123
  ],
  "quantity": 123,
  "upgradeLongPlanOnly": true,
  "upgradeOnly": true,
  "userLimit": 123,
  "userScope": 123
}
'
{
  "code": 123,
  "data": {
    "discount": {
      "advance": true,
      "billingType": 123,
      "code": "<string>",
      "createTime": 123,
      "currency": "<string>",
      "cycleLimit": 123,
      "discountAmount": 123,
      "discountPercentage": 123,
      "discountType": 123,
      "endTime": 123,
      "id": 123,
      "isDeleted": 123,
      "merchantId": 123,
      "metadata": {},
      "name": "<string>",
      "planApplyGroup": {
        "currency": [
          "<string>"
        ],
        "groupPlanIntervalSelector": [
          {
            "intervalCount": 123,
            "intervalUnit": "<string>"
          }
        ],
        "type": [
          123
        ]
      },
      "planApplyType": 123,
      "planIds": [
        123
      ],
      "quantity": 123,
      "startTime": 123,
      "status": 123,
      "upgradeLongerOnly": true,
      "upgradeOnly": true,
      "userLimit": 123,
      "userScope": 123
    }
  },
  "message": "<string>",
  "redirect": "<string>",
  "requestId": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

Create a new discount code, code can used in onetime or subscription purchase to make discount

billingType
integer<int>
required

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<string>
required

The discount's unique code, customize by merchant

discountType
integer<int>
required

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<*int64>
required

The end time of discount code can effect, utc time

startTime
integer<*int64>
required

The start time of discount code can effect, utc time

advance
boolean<*bool>

AdvanceConfig, 0-false,1-true, will enable all advance config if set true

currency
string<string>

The discount currency of discount code, available when discount_type is fixed_amount

cycleLimit
integer<int>

The count limitation of subscription cycle, each subscription is valid separately , 0-no limit

discountAmount
integer<int64>

The discount amount of the discount code, available when discount_type is fixed_amount

discountPercentage
integer<int64>

The discount percentage of discount code, 100=1%, available when discount_type is percentage

metadata
object

Metadata,Map

name
string<*string>

The discount's name

planApplyGroup
object
planApplyType
integer<*int>

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
integer<int64>[]

Ids of plan which discount code can effect, default effect all plans if not set

quantity
integer<*int64>

Quantity of code, default 0, set 0 to disable quantity management

upgradeLongPlanOnly
boolean<*bool>

AdvanceConfig, true or false, will forbid for all except upgrade to longer plan if set true

upgradeOnly
boolean<*bool>

AdvanceConfig, true or false, will forbid for all except same interval upgrade action if set true

userLimit
integer<*int>

AdvanceConfig, The limit of every customer can apply, the recurring apply not involved, 0-unlimited

userScope
integer<*int>

AdvanceConfig, Apply user scope,0-for all, 1-for only new user, 2-for only renewals, renewals is upgrade&downgrade&renew

Response

200 - application/json
code
integer<int>
data
object
message
string<string>
redirect
string<string>
requestId
string<string>