Promotion API
Use the REST API to interact with EverShop promotions.
Create a coupon
Use this endpoint to create a coupon.
Request Schema (application/json)
Field Name | Field Type | Required | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
coupon | string (^[a-zA-Z0-9]+$) | Yes | |||||||||||||||||||||||||||||||||
status | string or integer ('0', '1', 0, 1) | Yes | |||||||||||||||||||||||||||||||||
description | string | No | |||||||||||||||||||||||||||||||||
discount_amount | string or number | Yes | |||||||||||||||||||||||||||||||||
free_shipping | string or integer ('0', '1', 0, 1) | No | |||||||||||||||||||||||||||||||||
discount_type | string | Yes | |||||||||||||||||||||||||||||||||
target_products | object | No | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
condition | object | No | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
user_condition | object | No | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
max_uses_time_per_coupon | string (^[0-9]*$) | No | |||||||||||||||||||||||||||||||||
max_uses_time_per_customer | string (integer) | No | |||||||||||||||||||||||||||||||||
start_date | string | No | |||||||||||||||||||||||||||||||||
end_date | string | No |
POST/api/coupons
- cURL
- JavaScript
curl -H "Accept: application/json" -H "Cookie: admin_token=<your jwt token id>" https://<your domain>/api/coupons
fetch('https://<your domain>/api/coupons', { headers: { 'Accept': 'application/json', 'Cookie': 'admin_token=<your jwt token id>' }}) .then(response => response.json()) .then(data => { if(data.error) { // Handle the error } else { // Handle the data } }) .catch(error => { // Handle the error });
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
Use this endpoint to update a coupon.
Request Schema (application/json)
Field Name | Field Type | Required | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
coupon | string (^[a-zA-Z0-9]+$) | Yes | |||||||||||||||||||||||||||||||||
status | string or integer ('0', '1', 0, 1) | No | |||||||||||||||||||||||||||||||||
description | string | No | |||||||||||||||||||||||||||||||||
discount_amount | string or number | No | |||||||||||||||||||||||||||||||||
free_shipping | string or integer ('0', '1', 0, 1) | No | |||||||||||||||||||||||||||||||||
discount_type | string | No | |||||||||||||||||||||||||||||||||
target_products | object | No | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
condition | object | No | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
user_condition | object | No | |||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
max_uses_time_per_coupon | string (^[0-9]*$) | No | |||||||||||||||||||||||||||||||||
max_uses_time_per_customer | string (integer) | No | |||||||||||||||||||||||||||||||||
start_date | string | No | |||||||||||||||||||||||||||||||||
end_date | string | No |
PATCH/api/coupons/{id}
- cURL
- JavaScript
curl -H "Accept: application/json" -H "Cookie: admin_token=<your jwt token id>" https://<your domain>/api/coupons/{id}
fetch('https://<your domain>/api/coupons/{id}', { headers: { 'Accept': 'application/json', 'Cookie': 'admin_token=<your jwt token id>' }}) .then(response => response.json()) .then(data => { if(data.error) { // Handle the error } else { // Handle the data } }) .catch(error => { // Handle the error });
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" ] } ] }}
Delete a coupon
Use this endpoint to delete a coupon.
Request Schema (application/json)
No request body requiredDELETE/api/coupons/{id}
- cURL
- JavaScript
curl -H "Accept: application/json" -H "Cookie: admin_token=<your jwt token id>" https://<your domain>/api/coupons/{id}
fetch('https://<your domain>/api/coupons/{id}', { headers: { 'Accept': 'application/json', 'Cookie': 'admin_token=<your jwt token id>' }}) .then(response => response.json()) .then(data => { if(data.error) { // Handle the error } else { // Handle the data } }) .catch(error => { // Handle the error });
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" }}
Apply a coupon
Use this endpoint to apply a coupon to a cart.
Request Schema (application/json)
Field Name | Field Type | Required |
---|---|---|
coupon | string | Yes |
POST/api/carts/{cart_id}/coupons
- cURL
- JavaScript
curl -H "Accept: application/json" -H "Cookie: admin_token=<your jwt token id>" https://<your domain>/api/carts/{cart_id}/coupons
fetch('https://<your domain>/api/carts/{cart_id}/coupons', { headers: { 'Accept': 'application/json', 'Cookie': 'admin_token=<your jwt token id>' }}) .then(response => response.json()) .then(data => { if(data.error) { // Handle the error } else { // Handle the data } }) .catch(error => { // Handle the error });
Sample Of Response
{ "data": { "coupon": "coupon" }}