Skip to main content
curl --request POST 'https://api.mayar.id/hl/v2/coupons/create' \
--header 'Authorization: Bearer Paste-Your-API-Key-Here' \
--data-raw '{
    "name": "Diskon Murmer",
    "expiredAt": "2030-01-01T09:06:14.933Z",
    "discount": {
        "discountType": "monetary",
        "eligibleCustomerType": "all",
        "minimumPurchase": 500000,
        "value": 100000,
        "totalCoupons": 100
    },
    "coupon": {
        "code": "haribaik",
        "type": "reusable"
    },
    "products": []
}
'
{
    "statusCode": 200,
    "messages": "success",
    "data": {
        "id": "c9aa143a-53f9-44e7-a9c6-83229ad7199b",
        "name": "Diskon Murmer",
        "discountType": "monetary",
        "value": 100000,
        "minimumPurchase": 500000,
        "eligibleCustomerType": "all",
        "totalCoupons": 100,
        "discountProductType": "all",
        "expiredAt": "2030-01-01T09:06:14.933Z",
        "isLifeTime": null,
        "status": "active",
        "coupons": [
            {
                "id": "532858fe-3722-4cf4-a8eb-f7c6765aba17",
                "code": "haribaik",
                "type": "reusable",
                "expiredAt": "2030-01-01T09:06:14.933Z"
            }
        ],
        "products": [],
        "createdAt": "2026-06-29T07:12:41.029Z"
    }
}
Endpoint:
https://api.mayar.id/hl/v2/coupons/create

Authorization

Authorization
string
required
Example:Authorization | Bearer Paste-Your-API-Key-Here

Request Body

name
string
required
Discount name (minimum 5 characters).
expiredAt
string | datetime
Discount coupon expiration date. When omitted, the discount and its coupon do not expire (expiredAt is stored as null).
discount
object
required
Details of the discount conditions.
coupon
object
required
Coupon code details.
products
array of object
List of eligible products (maximum 2). Leave empty to apply the discount to all products. When provided, each item requires a product id you own.

discount Structure (Object)

discountType
string
required
Discount type:
  • monetary
  • percentage
For percentage, a value greater than 99 is automatically capped at 99.
eligibleCustomerType
string
required
Target customers who can use the discount coupon:
  • all
  • new
  • old
minimumPurchase
number | integer
Minimum purchase amount required to use the discount.
value
number | integer
required
Discount amount (must be positive).
totalCoupons
number | integer
required
Available coupon quota (must be positive). For onetime coupons, a maximum of 50 codes are generated per request.

coupon Structure (Object)

code
string
Discount coupon code. Optional — when omitted, a random code is generated. Only used for reusable coupons; onetime coupons always receive generated codes.
type
string
required
Coupon type:
  • reusable
  • onetime

products Structure (Array Of Object)

id
string
required
Product (payment link) ID to attach the discount to.

Response

Successful Response

Main Structure (Root)

statusCode
integer
Status code from API.
messages
string
Status message that describes the status code.
data
object
The created discount details.

data Structure (Object)

id
string<uuid>
Discount ID.
name
string
Discount name.
discountType
string
Discount type.
value
number
Discount value.
minimumPurchase
number | null
Minimum purchase amount to apply the discount. null if not set.
eligibleCustomerType
string
Eligible customer scope.
totalCoupons
integer
Total number of coupons available.
discountProductType
string
Discount product scope: all when no products are attached, selected when one or more products are provided.
expiredAt
string (ISO 8601) | null
Expiration date in ISO 8601 format, or null when the discount does not expire.
isLifeTime
boolean | null
Indicates if the discount is lifetime (true/false) or null.
status
string
Discount status (example: "active").
coupons
array of object
List of coupons created for this discount.
products
array of object
List of products attached to the discount (empty when applied to all products).
createdAt
string (ISO 8601)
Creation time in ISO 8601 format.

coupons Structure (Array Of Object)

id
string<uuid>
Coupon ID. Present for reusable coupons; omitted for onetime coupons.
code
string
Coupon code.
type
string
Coupon type (reusable or onetime).
expiredAt
string (ISO 8601) | null
Coupon expiration date, or null when it does not expire.

products Structure (Array Of Object)

id
string<uuid>
Attached product (payment link) ID.

Errors

400 Validation Error
object
Returned with messages: "Validation Error" when the request body fails validation (e.g. missing or malformed name, discount, or coupon fields).
400 Product Tidak Bisa Ditambahkan
object
Returned with messages: "Product Tidak Bisa Ditambahkan" when an attached product is not owned by the authenticated account.
404 Product Tidak Ditemukan
object
Returned with messages: "Product Tidak Ditemukan" when an attached product cannot be found.
409 Coupon code already in use
object
Returned with messages: "Coupon code already in use" when a reusable coupon code already exists.