Create Coupon Code API
POST /createCouponCode
Description
This API endpoint creates a new coupon code with the specified parameters. The coupon code can be used to provide discounts or special offers.
Request Body
The request utilizes GraphQL to perform the createCouponCode
mutation.
Mutation:
mutation createCouponCode ($couponCodeView: CouponCodeView) {
createCouponCode (couponCodeView: $couponCodeView) {
id
couponCode
startDate
expiryDate
discountRate
quantity
createdAt
}
}
Variables:
{
"couponCodeView": {
"couponCode": "<Coupon_Code>",
"startDate": "<Start_Date>",
"expiryDate": "<Expiry_Date>",
"discountRate": <Discount_Rate>,
"quantity": <Quantity>
}
}
- couponCode (String): The code for the coupon.
- startDate (String): The start date of the coupon validity period in ISO 8601 format.
- expiryDate (String): The end date of the coupon validity period in ISO 8601 format.
- discountRate (Float): The discount rate to be applied with the coupon.
- quantity (Int): The number of times the coupon can be used.
Response:
-
Success (200 OK):
- If the coupon code is successfully created, the response will include the details of the created coupon.
{
"data": {
"createCouponCode": {
"id": <Coupon_Id>,
"couponCode": "<Coupon_Code>",
"startDate": "<Start_Date>",
"expiryDate": "<Expiry_Date>",
"discountRate": <Discount_Rate>,
"quantity": <Quantity>,
"createdAt": "<Creation_Date>"
}
}
} -
Error (4XX/5XX):
- If there is an issue with creating the coupon code, the response will include an appropriate error message and status code.
Note:
Ensure that the couponCode
is unique and the startDate
and expiryDate
are correctly formatted. The discountRate
should be a valid percentage or amount, and the quantity
should be a positive integer.