Creating Discount profile
Endpoint: POST /admin/discount_profiles
Purpose
This endpoint allows administrators to create a new discount profile, including its name, rules, coupon settings, usage limits, and discount details. It supports configuring flat or tiered discounts applicable to products or orders.
Path Parameters
This endpoint does not require any path parameters.
Query Parameters
This endpoint does not require any query parameters.
Use Case
An admin sets up a new discount campaign or promotion by defining how the discount applies, any coupon settings, usage limits, and product or customer scope. This is useful for running targeted marketing promotions, loyalty discounts, or seasonal offers.
Request Body
Field | Type | Description |
---|---|---|
name | string | Name of the discount profile |
amount_details | object | Discount amount configuration |
apply_to | string | Whether to apply to selected_products or entire_order |
type | string | Discount type logic |
singleAmount | string/number | Value of the flat discount |
singleAmountType | string | FLAT for fixed amount |
{
"name": "DISCOUNT_NAME",
"is_active": true,
"start_date": "START_DATETIME",
"is_specify_end_date": true,
"end_date": "END_DATETIME",
"type": "customer",
"is_exclude_products_on_sale": false,
"is_used_with_other_discounts": false,
"is_maximum_use_limit": true,
"maximum_use_limit": 10,
"is_maximum_use_limit_by_customer": true,
"maximum_use_limit_by_customer": 10,
"is_maximum_discount_allowed": true,
"maximum_discount_allowed": 10.0,
"is_apply_coupon_code": true,
"is_coupon_code_auto_generated": true,
"default_coupon_code": "COUPON_CODE",
"is_unique_coupon_code": false,
"unique_coupon_code": false,
"is_applied__to_all_customer": true,
"customers": [],
"is_applied_to_all_products": true,
"products": [],
"discount_Details_Type": "amount",
"amount_details": {
"apply_to": "selected_products",
"type": "single",
"singleAmount": 10,
"singleAmountType": "FLAT"
}
}
Response
The response returns the created discount profile, including its configuration, status, coupon behavior, discount type and amount, and flags for visibility and application. This ensures full visibility of the created promotion and allows immediate use in the system.
{
"discount": {
"id": DISCOUNT_ID,
"name": "DISCOUNT_NAME",
"type": "DISCOUNT_TYPE",
"is_active": IS_ACTIVE,
"discount_details_type": "DISCOUNT_AMOUNT_TYPE",
"default_coupon_code": "COUPON_CODE",
"is_apply_coupon_code": IS_COUPON_REQUIRED,
"is_coupon_code_auto_generate": IS_AUTO_GENERATE,
"is_exclude_products_on_sale": IS_EXCLUDE_SALE_PRODUCTS,
"is_maximum_discount_allowed": IS_MAX_DISCOUNT_ENABLED,
"maximum_discount_allowed_amount": MAX_DISCOUNT_AMOUNT,
"is_maximum_use_total": IS_MAX_USE_TOTAL,
"maximum_use_count": MAX_USE_COUNT,
"is_maximum_use_customer": IS_MAX_USE_PER_CUSTOMER,
"maximum_use_customer_count": MAX_USE_CUSTOMER_COUNT,
"is_discount_used_with_other_discount": IS_COMBINABLE,
"is_specify_end_date": IS_END_DATE_SPECIFIED,
"start_from": "START_DATE",
"start_to": "END_DATE",
"details_id": DETAILS_ID,
"coupon": COUPON_ID,
"assoc": ASSOCIATION_ID,
"details": {
"id": DETAILS_ID,
"type": "DETAIL_TYPE",
"apply_to": "APPLY_TO_SCOPE",
"single_amount_type": "FLAT",
"single_amount": DISCOUNT_AMOUNT,
"tiers": [],
"minimum_amount_on": "each_item"
},
"customer_coupons": [],
"exclude_products": [],
"usage": [],
"is_imported_coupon": false,
"is_create_unique_coupon_each_customer": false,
"is_display_text_coupon": false,
"display_text_coupon": null,
"is_display_text_cart": false,
"display_text_cart": null,
"is_display_text_partial_discount_condition": false,
"display_text_partial_discount_condition": null,
"is_display_discount_information_prod_detail": false
}
}
Creating Discount Coupons
Endpoint: POST/admin/discount_profiles/{profile_id}/create-coupons
Purpose
This API allows administrators to generate a specified number of unique coupon codes under an existing discount profile. It is used to quickly create multiple coupons for campaigns, special events, or targeted marketing initiatives.
Path Parameters
Parameter | Type | Description |
---|---|---|
id
|
Integer | The unique ID of the discount profile to create coupons for |
Query Parameters
This endpoint does not have any query parameters.
Use Case
An admin may use this endpoint to generate a batch of coupon codes for distribution to customers. This is useful for time-limited promotions, individual targeting, or bulk discount campaigns where codes need to be uniquely tracked.
Request Body
Parameter | Type | Description |
---|---|---|
requested_codes | number | Number of unique coupon codes to generate |
{
"requested_codes": "NUMBER_OF_CODES"
}
Response
The response generates a specific number of unique coupon codes tied to the discount profile. The response confirms successful creation and returns the list of newly generated coupon codes. This is particularly useful when a promotion requires multiple personalized codes for distribution or tracking.
{
"status": "success",
"message": "X new codes generated.",
"codes": [
"COUPON_CODE_1",
"COUPON_CODE_2",
"COUPON_CODE_3",
"COUPON_CODE_4",
"COUPON_CODE_5"
]
}
Assigning Discount Coupon to Customer
Endpoint: POST /admin/discount_coupons/assign-customer
Purpose
This API allows administrators to assign a specific discount coupon code to a customer based on their email. This is useful for personalized promotions, targeted marketing, or limiting coupon use to specific individuals.
Path Parameters
This endpoint does not have any path parameters.
Query Parameters
This endpoint does not have any query parameters.
Use Case
An administrator wants to issue a specific discount coupon to an individual customer by linking the coupon code directly to their email address.
Request Body
Parameter | Type | Description |
---|---|---|
code | string | Coupon code to assign |
string | Email address of the customer |
{
"code": "COUPON_CODE",
"email": "CUSTOMER_EMAIL"
}
Response
The response assigns a coupon code to a specific customer via their email address. The response confirms the operation with a success message, indicating that the selected code has been successfully linked to the user, making the discount available for use in their checkout process.
{
"status": "success",
"message": "Customer has been assigned successfully."
}