Setup Coupons

Download skillThe skill is a reference md and part of wix-manage skill. You can use the following command to add the full wix-manage skill to your project:
Copy

Prerequisites

  • Wix Stores (or another eCommerce business solution) installed on the site

Required APIs


Step 1: Query existing coupons

Before creating a coupon, check for code conflicts and existing promotions on the same scope.

Endpoint: POST https://www.wixapis.com/v2/coupons/query

Request:

Copy

Response:

Copy

Check for: duplicate codes, overlapping scopes with active coupons, and cross-mechanism stacking with active automatic discount rules.


Step 2: Create a percentage-off coupon

Endpoint: POST https://www.wixapis.com/v2/coupons

Request — 15% off all store products:

Copy

Response:

Copy

Request — 20% off a specific collection:

Copy

Request — 10% off a specific product:

Copy

Step 3: Create a fixed-amount coupon

Request — $10 off all products:

Copy

Step 4: Create a minimum subtotal coupon

Instead of targeting a scope, you can require a minimum cart subtotal. This is a oneOf with scope — you set EITHER scope OR minimumSubtotal, not both.

Request — 15% off orders over $100:

Copy

Key field rules

FieldRequiredNotes
nameYesDisplay name shown to customers
codeYesUnique coupon code. Max 20 characters. Case-insensitive at checkout.
startTimeYesUNIX epoch in milliseconds (not seconds). E.g., 1714521600000 for 2024-05-01T00:00
expirationTimeNoUNIX epoch in milliseconds. Omit for no expiration.
scope OR minimumSubtotalOne requiredOneOf — set scope to target items, OR minimumSubtotal for cart threshold. Cannot set both. Exception: freeShipping type ignores scope.
usageLimitNoTotal uses across all customers. Omit for unlimited.
limitPerCustomerNoMax uses per customer. Omit for unlimited.
limitedToOneItemNoIf true, discount applies only to lowest-priced item when customer buys multiple.
activeNoDefault true. Set false to create as draft.

Coupon types (oneOf — set exactly one)

TypeFieldValueExample
Percentage offpercentOffRateDouble (e.g., 15 for 15%)"percentOffRate": 15
Fixed amount offmoneyOffAmountDouble (e.g., 10 for $10 off)"moneyOffAmount": 10
Fixed pricefixedPriceAmountDouble (e.g., 29.99)"fixedPriceAmount": 29.99
Free shippingfreeShippingBoolean true"freeShipping": true
Buy X Get YbuyXGetYObject with x and y fields"buyXGetY": {"x": 2, "y": 1}

Scope values for Wix Stores

Scope targetnamespacegroup.namegroup.entityId
All store products"stores""product"Omit (applies to all)
Specific product"stores""product"Product UUID
Specific collection"stores""collection"Collection UUID

Recommendation → Coupon API Mapping

When the recommendation output has mechanism: "COUPON", use this mapping to convert it into a Coupons API payload.

Scope mapping

Recommendation scopeCoupon scope
SITE{ "namespace": "stores", "group": { "name": "product" } } (all products, no entityId)
CATEGORY{ "namespace": "stores", "group": { "name": "collection", "entityId": "<first categoryId>" } }
ITEMS{ "namespace": "stores", "group": { "name": "product", "entityId": "<first productId>" } }

Important limitation: The Coupons API scope supports only one entityId (one product or one collection). If the recommendation targets multiple products or categories:

  • For CATEGORY with multiple categoryIds: Create one coupon per collection, or pick the primary collection.
  • For ITEMS with multiple productIds: Create one coupon per product, or use minimumSubtotal instead of scope if the intent is cart-level.

Discount type mapping

Recommendation discountTypeCoupon field
PERCENTAGE"percentOffRate": <value>
FIXED_AMOUNT"moneyOffAmount": <value>
FIXED_PRICE"fixedPriceAmount": <value>

Condition mapping

Recommendation conditionCoupon approach
minSubTotal > 0Use minimumSubtotal instead of scope (they are oneOf — cannot use both)
minItemQuantity > 0Not natively supported by Coupons API. Mention in the coupon name (e.g., "Buy 3+, use code BUNDLE15") but the API cannot enforce item quantity.
startDateConvert to UNIX epoch milliseconds: Date.parse("2026-06-01") → 1748736000000. Set as startTime.
endDateConvert to UNIX epoch milliseconds. Set as expirationTime.

Code generation

Recommendation fieldCoupon fieldRules
code from recommendationspecification.codeMax 20 characters. Must be unique on the site. Suggest memorable, brand-relevant codes (e.g., SUMMER25, SAVE15, VIP20).
usageLimit from recommendationspecification.usageLimitTotal times the coupon can be used. 0 in recommendation → omit (unlimited).
limitPerCustomer from recommendationspecification.limitPerCustomerMax per customer. 0 → omit (unlimited). Recommend setting to 1 for most campaigns.

Full mapping example

Recommendation output:

Copy

Coupon API request:

Copy

Key differences from Automatic Discounts

AspectAutomatic Discount (Discount Rules API)Coupon (Coupons API)
Scope supports multiple itemsYes (multiple IDs in arrays)No (one entityId per scope)
minSubTotal + scope togetherYes (scope + trigger)No (oneOf — choose one)
minItemQuantity enforcementYes (ITEM_QUANTITY_RANGE trigger)Not supported by API
Date formatISO 8601 timestampsUNIX epoch milliseconds
Created stateactive: false, status: PENDINGactive: true by default
Triggers/conditionsSeparate trigger object with typed rangesOnly minimumSubtotal (simple threshold)

Error Handling

ErrorCauseFix
Duplicate codeAnother coupon uses the same codeGenerate a different code
Invalid startTimeValue too low (must be epoch ms, not seconds)Multiply by 1000 if in seconds
Both scope and minimumSubtotal setThese are oneOf — cannot use bothChoose scope OR minimumSubtotal
Code exceeds 20 charactersCode is too longShorten the code

References

Did this help?