Skip to main content

Promotion API

The Promotion API allows you to programmatically manage promotional offers and discount coupons in your EverShop store. This RESTful interface provides endpoints for creating, updating, deleting, and applying coupons.

Endpoints

Create a Coupon

Creates a new discount coupon in your EverShop store with the specified attributes.

Request Schema (application/json)
Field NameField TypeRequired
couponstring (^[a-zA-Z0-9]+$)No
statusstring or integer ('0', '1', 0, 1)No
descriptionstringNo
discount_amountstring or numberNo
free_shippingstring or integer or boolean ('0', '1', 0, 1, true, false)No
discount_typestringNo
target_productsobjectNo
Field NameField TypeRequired
maxQtystring or integerNo
productsarray of objectNo
Field NameField TypeRequired
keystringYes
operatorstring (IN, NOT IN, =, !=, >, >=, <, <=)Yes
valueYes
conditionobjectNo
Field NameField TypeRequired
order_totalstring or numberNo
order_qtystring or integerNo
required_productsarray of objectNo
Field NameField TypeRequired
keystringYes
operatorstring (IN, NOT IN, =, !=, >, >=, <, <=)Yes
qtystring or integerYes
valueYes
additionalPropertiesNo
user_conditionobjectNo
Field NameField TypeRequired
groupsarray of string,integerNo
emailsarray of stringNo
purchasednumberNo
max_uses_time_per_couponstring (^[0-9]*$)No
max_uses_time_per_customerstring (^[0-9]*$)No
start_dateNo
end_dateNo
POST/api/coupons
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/coupons
Sample Of Response
{
"data": {
"coupon_id": 30,
"uuid": "d63601a5a67311edb46b60d819134f39",
"status": 1,
"description": "y2RFMOdn9LuiUtob5n1c",
"discount_amount": 10,
"free_shipping": 0,
"discount_type": "fixed_discount_to_entire_order",
"coupon": "y2RFMOdn9LuiUtob5n1c",
"used_time": 0,
"target_products": null,
"condition": null,
"user_condition": null,
"buyx_gety": null,
"max_uses_time_per_coupon": null,
"max_uses_time_per_customer": null,
"start_date": null,
"end_date": null,
"created_at": "2023-02-07 15:07:53",
"updated_at": "2023-02-07 15:07:53",
"links": [
{
"rel": "couponGrid",
"href": "/admin/coupons",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "edit",
"href": "/admin/coupon/edit/d63601a5a67311edb46b60d819134f39",
"action": "GET",
"types": [
"text/xml"
]
}
]
}
}

Update a Coupon

Updates an existing coupon with new attribute values.

Request Schema (application/json)
Field NameField TypeRequired
couponstring (^[a-zA-Z0-9]+$)No
statusstring or integer ('0', '1', 0, 1)No
descriptionstringNo
discount_amountstring or numberNo
free_shippingstring or integer or boolean ('0', '1', 0, 1, true, false)No
discount_typestringNo
target_productsobjectNo
Field NameField TypeRequired
maxQtystring or integerNo
productsarray of objectNo
Field NameField TypeRequired
keystringYes
operatorstring (IN, NOT IN, =, !=, >, >=, <, <=)Yes
valueYes
conditionobjectNo
Field NameField TypeRequired
order_totalstring or numberNo
order_qtystring or integerNo
required_productsarray of objectNo
Field NameField TypeRequired
keystringYes
operatorstring (IN, NOT IN, =, !=, >, >=, <, <=)Yes
qtystring or integerYes
valueYes
additionalPropertiesNo
user_conditionobjectNo
Field NameField TypeRequired
groupsarray of string,integerNo
emailsarray of stringNo
purchasednumberNo
max_uses_time_per_couponstring (^[0-9]*$)No
max_uses_time_per_customerstring (^[0-9]*$)No
start_dateNo
end_dateNo
PATCH/api/coupons/{id}
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/coupons/{id}
Sample Of Response
{
"data": {
"coupon_id": 30,
"uuid": "d63601a5a67311edb46b60d819134f39",
"status": 1,
"description": "y2RFMOdn9LuiUtob5n1c",
"discount_amount": 10,
"free_shipping": 0,
"discount_type": "fixed_discount_to_entire_order",
"coupon": "y2RFMOdn9LuiUtob5n1c",
"used_time": 0,
"target_products": null,
"condition": null,
"user_condition": null,
"buyx_gety": null,
"max_uses_time_per_coupon": null,
"max_uses_time_per_customer": null,
"start_date": null,
"end_date": null,
"created_at": "2023-02-07 15:07:53",
"updated_at": "2023-02-07 15:07:53",
"links": [
{
"rel": "couponGrid",
"href": "/admin/coupons",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "edit",
"href": "/admin/coupon/edit/d63601a5a67311edb46b60d819134f39",
"action": "GET",
"types": [
"text/xml"
]
}
]
}
}

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe UUID of the coupon to update

Delete a Coupon

Removes a coupon from your EverShop store.

Request Schema (application/json)
No request body required
DELETE/api/coupons/{id}
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
https://<your domain>/api/coupons/{id}
Sample Of Response
{
"data": {
"coupon_id": 30,
"uuid": "d63601a5a67311edb46b60d819134f39",
"status": 1,
"description": "TRNfYH0X7kQL4Evddsy6",
"discount_amount": 20,
"free_shipping": 0,
"discount_type": "fixed_discount_to_entire_order",
"coupon": "TRNfYH0X7kQL4Evddsy6",
"used_time": 0,
"target_products": null,
"condition": null,
"user_condition": null,
"buyx_gety": null,
"max_uses_time_per_coupon": null,
"max_uses_time_per_customer": null,
"start_date": null,
"end_date": null,
"created_at": "2023-02-07 15:07:53",
"updated_at": "2023-02-07 15:07:53"
}
}

Path Parameters

ParameterTypeRequiredDescription
idstringYesThe UUID of the coupon to delete

Apply a Coupon

Applies a coupon code to a specific shopping cart.

Request Schema (application/json)
Field NameField TypeRequired
couponstringYes
POST/api/carts/{cart_id}/coupons
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/carts/{cart_id}/coupons
Sample Of Response
{
"data": {
"coupon": "coupon"
}
}

Path Parameters

ParameterTypeRequiredDescription
cart_idstringYesThe UUID of the cart to apply the coupon to

Remove a Coupon from Cart

Removes a previously applied coupon from a shopping cart.

Request Schema (application/json)
No request body required
DELETE/api/carts/{cart_id}/coupons/{coupon}
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
https://<your domain>/api/carts/{cart_id}/coupons/{coupon}
Sample Of Response
{
"data": {
"success": true
}
}

Path Parameters

ParameterTypeRequiredDescription
cart_idstringYesThe UUID of the cart
couponstringYesThe coupon code to remove from the cart

Discount Types

EverShop supports various discount types that can be specified in the discount_type parameter:

Discount TypeDescription
fixed_discount_to_entire_orderApplies a fixed amount discount to the entire order
percentage_discount_to_entire_orderApplies a percentage discount to the entire order
fixed_discount_to_specific_productsApplies a fixed amount discount to specific products only
percentage_discount_to_specific_productsApplies a percentage discount to specific products only
buy_x_get_yBuy X quantity of products, get Y quantity free