> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mayar.id/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Discount with Coupon

> Endpoint used to create discount coupons

```bash Request Example theme={null}
curl --request POST 'https://api.mayar.id/hl/v1/coupon/create' \
--header 'Authorization: Bearer Paste-Your-API-Key-Here' \
--header 'Content-Type: application/json' \
--data-raw '{
  		"expiredAt": "2030-01-01T09:06:14.933Z", 
  		"name": "Diskon Murmer",
  		"discount": {
    			"discountType": "monetary",
    			"eligibleCustomerType": "all",
    			"minimumPurchase": 500000,
    			"value": 100000,   
    			"totalCoupons": 100
  				},
  			"coupon": {
    		"code": "haribaik",
    		"type": "reusable"
  			},
  		"products": []
	}
'
```

```json Response Example 200 theme={null}
{
    "statusCode": 200,
    "messages": "Success",
    "data": {
        "id": "c9aa143a-53f9-44e7-a9c6-83229ad7199b",
        "createdAt": 1755665561029,
        "expiredAt": 1893488774933,
        "discountType": "monetary",
        "discountProductType": "all",
        "eligibleCustomerType": "all",
        "name": "Diskon Murmer",
        "minimumPurchase": 500000,
        "isLifeTime": null,
        "totalCoupons": 100,
        "value": 100000,
        "coupons": [
            {
                "code": "haribaik",
                "type": "reusable",
                "expiredAt": "2030-01-01T09:06:14.933Z",
                "isActive": true
            }
        ],
        "productDiscount": []
    }
}
```

Endpoint:

```Production Production theme={null}
https://api.mayar.id/hl/v1/coupon/create
```

```Sandbox Sandbox theme={null}
https://api.mayar.io/hl/v1/coupon/create
```

## Authorization

**Authorization** `string` *required*

Example:

`Authorization | Bearer Paste-Your-API-Key-Here`

## Request Body

**expiredAt** `string | datetime` *required*

Discount coupon expiration date.

**name** `string` *required*

Discount name.

**discount** `array of object` *required*

Details of discount conditions.

### discount Structure (Array Of Object)

**discountType** `string` *required*

Discount type;

* monetary
* percentage

**eligibleCustomerType** `string` *required*

Target customers who can use discount coupons.

* all

**minimumPurchase** `number | integer` *required*

Minimum purchase to be able to use the discount.

**value** `number | integer` *required*

Discount amount

**totalCoupons** `number | integer` *required*

Available coupon quota.

**coupon** `array of object`

Coupon code details.

### coupon Structure (Array Of Object)

**code** `string` *required*

Discount coupon code.

**type** `string` *required*

Coupon type;

* reusable
* onetime

**products** `Array`

List of eligible products.

## Response

Successful Response

### Main Structure (Root)

**statusCode** `integer`

Status code form API.

**messages** `string`

Status message that describes the status code.

**data** `array of object`

The main data returned (request payment details).

### data Structure (Array Of Object)

**id** `string\<uuid\>`

Discount ID.

**createdAt** `integer`

Creation time (timestamp in ms).

**expiredAt** `integer`

Expiration time (timestamp in ms).

**discountType** `string`

Discount type.

**discountProductType** `string`

Discount product scope.

**eligibleCustomerType** `string`

Eligible customer scope.

**name** `string`

Discount name.

**minimumPurchase** `integer`

Minimum purchase amount  to apply discount.

**isLifeTime** `boolean | null`

Indicates if discount is lifetime (`true`/`false`) or `null`.

**totalCoupons** `integer`

Total number of coupons available.

**value** `number`

Discount value.

**coupons** `array of object`

List of coupons associated with this discount.

**productDiscount** `array of objext`

Product-specific discount rules (empty if not applied).

### coupons Structure (Array Of Object)

**code** `string`

Coupon code.

**type** `string`

Coupon type.

**expiredAt** `string (ISO 8601 datetime)`

Coupon expiration date.

**isActive** `boolean`

Whether the coupon is active (`true` or `false`).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.