Create Coupon
Create a discount coupon (promo code) — at least one of flatDiscount or percentageDiscount off, redeemable on one or more of the creator's mangoes, or creator-wide when no mango is given. If both discount fields are given, percentageDiscount takes priority and flatDiscount is ignored entirely. Mirrors the dashboard "create coupon" flow, including the checks the dashboard form itself relies on the browser for: a mango a coupon is attached to must be one-time-priced (a free, zero-cost, open-ended, or recurring mango is rejected); without the 100%-discount plan entitlement, the discount is capped at 80%; startAt/validTill are full date-times (not bare dates) and validTill must be at least 5 minutes after startAt by actual elapsed time — see those fields' own descriptions for the exact precision required; targetUsers requires targetMangoes; and every targetUsers id must have an active subscription to one of the targetMangoes. The coupon is always created in your own account's currency (there is no currency field to set) — every selected mango must already be priced in that same currency. code must be unique among your own existing coupons, and is stored uppercase (lookups are case-insensitive).
Authorization
bearer In: header
Header Parameters
Host name of the dashboard, ex: mydomain.tagmango.com
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
application/json
application/json
application/json
application/json
application/json
application/json
curl -X POST "https://api-prod-new.tagmango.com/api/v1/external/coupons" \ -H "x-whitelabel-host: string" \ -H "Content-Type: application/json" \ -d '{ "code": "WELCOME50", "startAt": "2026-01-28T07:47:29.862Z", "validTill": "2026-02-28T07:47:29.862Z" }'{
"_id": "66a1390268a76f2f5c9f39a3",
"code": "WELCOME50",
"type": "creator_discount_coupon",
"creator": "77b2390268a76f2f5c9f39a4",
"startAt": "2024-08-11T10:20:30Z",
"validTill": "2024-12-31T23:59:59Z",
"active": true,
"flatDiscount": 100,
"percentageDiscount": 10,
"remainingOrder": 50,
"totalUsage": 5,
"currency": "INR",
"createdAt": "2024-08-11T10:20:30Z",
"updatedAt": "2024-08-11T10:20:30Z",
"mangoes": [
"64fbc8d765c6e5b324d45678"
],
"targetMangoes": [
"64fbc8d765c6e5b324d45678"
],
"targetUsers": [
"64fbc8d765c6e5b324d67890"
]
}{
"code": 400,
"type": "Bad Request",
"statusMessage": "BAD_REQUEST",
"errorCode": "COUPON_MANGO_NOT_ELIGIBLE",
"message": "A coupon can only target a one-time-priced mango — free, zero-cost, open-ended, and recurring (subscription) mangoes can never redeem a coupon, so one cannot be created for them.",
"result": "A coupon can only target a one-time-priced mango — free, zero-cost, open-ended, and recurring (subscription) mangoes can never redeem a coupon, so one cannot be created for them.",
"success": false
}{
"code": 401,
"type": "Unauthorized",
"statusMessage": "UNAUTHORIZED",
"message": "Invalid token",
"result": "Invalid token",
"success": false
}{
"code": 403,
"type": "Forbidden",
"statusMessage": "FORBIDDEN",
"errorCode": "COUPON_CREATOR_NOT_FOUND",
"message": "The creator associated with the API key does not exist.",
"result": "The creator associated with the API key does not exist.",
"success": false
}{
"code": 404,
"type": "Not Found",
"statusMessage": "NOT_FOUND",
"errorCode": "COUPON_MANGOES_NOT_FOUND",
"message": "One or more mango IDs in the request do not exist or have been deleted.",
"result": "One or more mango IDs in the request do not exist or have been deleted.",
"success": false
}{
"code": 409,
"type": "Conflict",
"statusMessage": "CONFLICT",
"errorCode": "COUPON_CODE_ALREADY_EXISTS",
"message": "Coupon codes must be unique among your own existing coupons (case-insensitive). Choose a different `code`.",
"result": "Coupon codes must be unique among your own existing coupons (case-insensitive). Choose a different `code`.",
"success": false
}{
"code": 429,
"type": "Too Many Requests",
"statusMessage": "TOO_MANY_REQUESTS",
"message": "Request limit exceeded. try after 10 seconds",
"result": "Request limit exceeded. try after 10 seconds",
"success": false
}