๐๏ธ Coupons API โ
โ Validate Coupon โ
POST /api/coupons/validatePublic. Validates a coupon code and returns the discount.
Request:
json
{
"code": "WELCOME10",
"orderTotal": 25.00
}Response:
json
{
"success": true,
"data": {
"valid": true,
"coupon": {
"id": "cuid",
"code": "WELCOME10",
"type": "PERCENTAGE",
"value": 10,
"maxDiscount": 5.00
},
"discount": 2.50
}
}Error Response (invalid coupon):
json
{
"success": false,
"error": "Coupon has expired"
}๐ List Coupons โ
GET /api/coupons
Authorization: Bearer <staff-token>Staff only. Returns all coupons with pagination.
๐ Get Coupon โ
GET /api/coupons/:id
Authorization: Bearer <staff-token>โ Create Coupon โ
POST /api/coupons
Authorization: Bearer <staff-token>Request:
json
{
"code": "SUMMER20",
"type": "PERCENTAGE",
"value": 20,
"minOrder": 30.00,
"maxDiscount": 10.00,
"usageLimit": 100,
"perCustomer": 1,
"startsAt": "2025-06-01T00:00:00Z",
"expiresAt": "2025-08-31T23:59:59Z",
"isActive": true
}โ๏ธ Update Coupon โ
PATCH /api/coupons/:id
Authorization: Bearer <staff-token>๐๏ธ Delete Coupon โ
DELETE /api/coupons/:id
Authorization: Bearer <manager-token>Manager or Super Admin only.
๐ Permissions Summary โ
| Action | Required Role |
|---|---|
| โ Validate coupon | Public |
| ๐ List / get coupons | Staff |
| โ Create / update coupons | Staff |
| ๐๏ธ Delete coupons | Manager, Super Admin |