Introduction

The Coupons API allows you to create and manage coupons to promote loyalty and increase sales. Customers can then apply the coupon codes at checkout to take advantage of your offers. With the Coupons API, you can create and update your coupons.

Terminology

  • Scope: The coupon scope defines the items a coupon applies to. You can apply a coupon to all items in a specific Wix application, a group within the application, or a single item within a group.

The following table lists the currently supported coupon scopes:

namespacegroupentityIdResult
stores----Applies to all store products
storesproductproduct IDApplies to the specific store product with the provided ID
storescollectioncollection IDApplies to the specific store collection with the provided ID
bookings----Applies to all bookings services
bookingsserviceservice IDApplies to the specific bookings service with the provided ID
eventseventevent IDApplies to the specific event with the provided ID
eventsticket--Applies to all event tickets
eventsticketticket IDApplies to the specific event ticket with the provided ID
pricingPlans----Applies to all pricing plans
pricingPlansplanplan IDApplies to the specific pricing plan with the provided ID
Was this helpful?
Yes
No

Setup

To use the Coupons API, install the @wix/marketing package using npm or Yarn:

Copy
1
npm install @wix/marketing

or

Copy
1
yarn add @wix/marketing

Then import { coupons } from @wix/marketing:

Copy
1
import { coupons } from '@wix/marketing'
Was this helpful?
Yes
No

Coupons: Supported Filters and Sorting

The following table shows field support for filters and sorting for the Coupon object:

FieldSupported FiltersSortable
id$eq,$ne,$hasSome,$contains,$startsWithSortable
dateCreated$eq,$ne,$hasSome,$lt,$lte,$gt,$gteSortable
expired$eq,$ne
specification.active$eq,$ne
specification.name$eq,$ne,$hasSome,$contains,$startsWithSortable
specification.code$eq,$ne,$hasSome,$contains,$startsWithSortable
specification.usageLimit$eq,$ne,$hasSome,$contains,$startsWithSortable
specification.limitedToOneItem$eq,$ne
scope.namespace$eq,$ne,$hasSome,$contains,$startsWithSortable
scope.group.name$eq,$ne,$hasSome,$contains,`$startsWithSortable`
scope.group.entityId$eq,$ne,$hasSome,$contains,$startsWithSortable

Related content: API Query Language, queryCoupons( )

Was this helpful?
Yes
No

bulkCreateCoupons( )

Creates multiple coupons.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Coupons
Manage Stores - all permissions
Learn more about permission scopes.
Copy
function bulkCreateCoupons(specifications: Array<Specification>, options: BulkCreateCouponsOptions): Promise<BulkCreateCouponsResponse>
Method Parameters
specificationsArray<Specification>Required
List of coupon specifications to be created.

optionsBulkCreateCouponsOptions
Returns
Return Type:Promise<BulkCreateCouponsResponse>
Was this helpful?
Yes
No

bulkDeleteCoupons( )

Deletes multiple coupons.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Coupons
Manage Stores - all permissions
Learn more about permission scopes.
Copy
function bulkDeleteCoupons(ids: Array<string>): Promise<BulkDeleteCouponsResponse>
Method Parameters
idsArray<string>Required
IDs of coupons to delete.
Returns
Return Type:Promise<BulkDeleteCouponsResponse>
Was this helpful?
Yes
No

createCoupon( )

Creates a new coupon.

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"

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Coupons
Manage Stores - all permissions
Learn more about permission scopes.
Copy
function createCoupon(specification: Specification): Promise<CreateCouponResponse>
Method Parameters
specificationSpecificationRequired
Coupon to create.
Returns
Return Type:Promise<CreateCouponResponse>
Was this helpful?
Yes
No

deleteCoupon( )

Deletes a coupon.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Coupons
Manage Stores - all permissions
Learn more about permission scopes.
Copy
function deleteCoupon(_id: string): Promise<void>
Method Parameters
_idstringRequired
ID of the coupon to delete.
Returns
Return Type:Promise<void>
Was this helpful?
Yes
No

getCoupon( )

Retrieves a coupon by ID.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Coupons
Manage Stores - all permissions
Learn more about permission scopes.
Copy
function getCoupon(_id: string): Promise<Coupon>
Method Parameters
_idstringRequired
ID of the coupon to retrieve.
Returns
Return Type:Promise<Coupon>
Was this helpful?
Yes
No

queryCoupons( )

Retrieves a list of coupons with pagination and filters. A maximum of 100 coupons will be returned per request.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Coupons
Manage Stores - all permissions
Learn more about permission scopes.
Copy
function queryCoupons(query: Query): Promise<QueryCouponsResponse>
Method Parameters
queryQueryRequired
Returns
Return Type:Promise<QueryCouponsResponse>
Was this helpful?
Yes
No

updateCoupon( )

Updates a coupon.

Only the properties passed in the specification object will be updated. All other properties will remain the same.

To remove a value from the coupon, pass its corresponding property with a value of null.

When updating a coupon, you cannot change the coupon's type. For example, if the coupon's type is moneyOffAmount, you cannot change it to fixedPriceAmount. You can update the coupon type's value. For example, you can change the value of moneyOffAmount from 5 to 10.

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.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Coupons
Manage Stores - all permissions
Learn more about permission scopes.
Copy
function updateCoupon(_id: string, specification: Specification): Promise<void>
Method Parameters
_idstringRequired
ID of the coupon to update.

specificationSpecificationRequired
Coupon information to update.
Returns
Return Type:Promise<void>
Was this helpful?
Yes
No