Check Coupon Code API
POST /checkCouponCode
Description
This API endpoint checks if a coupon code exists and retrieves its details. It provides information such as the coupon's start and expiry dates, discount rate, and quantity.
Request Body
The request utilizes GraphQL to perform the checkCouponCode
mutation.
Mutation:
mutation checkCouponCode ($code: String) {
checkCouponCode (code: $code) {
id
couponCode
startDate
expiryDate
discountRate
quantity
createdAt
}
}
Variables:
{
"code": "<Coupon_Code>"
}
- code (String): The coupon code to check.
Response:
-
Success (200 OK):
- If the coupon code exists, the response will include the details of the coupon.
{
"data": {
"checkCouponCode": {
"id": <Coupon_Id>,
"couponCode": "<Coupon_Code>",
"startDate": "<Start_Date>",
"expiryDate": "<Expiry_Date>",
"discountRate": <Discount_Rate>,
"quantity": <Quantity>,
"createdAt": "<Creation_Date>"
}
}
} -
Error (4XX/5XX):
- If the coupon code does not exist or there is an issue with the request, the response will include an appropriate error message and status code.
Note:
Ensure the code
is correctly formatted. If the coupon code is invalid or does not exist, the response will indicate this in the error message.