createCoupon( )


Creates a new coupon.

The createCoupon() function returns a Promise that resolves to the new coupon when it is created.

When creating a coupon, the specification object must contain values for name, code, startTime, and either scope or minimumSubtotal. The exception is for a freeShipping coupon type, for which you cannot apply a scope and minimumSubtotal is optional.

The coupon scope defines the items a coupon applies to. A coupon can apply to all items in a specific Wix application, a group within the application, or a single item within a group. See the introduction for a table of currently supported coupon scopes.

The specification object must also contain a value for exactly 1 of the following coupon properties. This defines the coupon type.

  • "moneyOffAmount"
  • "percentOffRate"
  • "freeShipping"
  • "fixedPriceAmount"
  • "buyXGetY"
Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Coupons
Manage Stores - all permissions
Learn more about app permissions.
Method Declaration
Copy
function createCoupon(
  specification: Specification,
): Promise<CreateCouponResponse>;
Method Parameters
specificationSpecificationRequired

Coupon to create.

Returns
Return Type:Promise<CreateCouponResponse>
JavaScript
import { coupons } from "wix-marketing.v2"; export function createCoupon() { let specification = { name: "My Coupon", code: "myCouponCode", startTime: `${new Date().getTime()}`, expirationTime: `${new Date(2030, 12, 31).getTime()}`, usageLimit: 100, limitedToOneItem: true, limitPerCustomer: 1, active: true, scope: { namespace: "stores", }, moneyOffAmount: 10, }; return coupons.createCoupon(specification); } // Returns promise that resolves to: // {"id": "058b0b56-e90d-4f4e-a8a3-8bf90b3fc4e6"}
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?