I am trying to create a specific Coupon code for Magento using API REST I am able to create random coupon code using but i want a specific coupon like HOLI100. How to achieve that
API(URL/rest/V1/coupons/generate)
{
"couponSpec": {
"rule_id":254,
"quantity": 1,
"length": 7, // character length of coupon excluding prefix/suffix. ie = EY-QRF7J-WA
"prefix": "HOLI",
"suffix": "100"
}
}
The
POST /rest/V1/coupons/generateAPI endpoint is used to auto-generate coupon codes based on a template. In order to add a specific coupon you need to usePOST /rest/V1/couponsendpoint. But there is a couple of things you should keep in mind:Based on the information above, you should do the following API requests:
Update coupon_type attribute for the sales rule:
Add a specific coupon code to this rule:
Here is the result: