> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# QueryLoyaltyCoupon

# Package: rewards

# Namespace: LoyaltyCoupons

# Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/rewards/coupons/query-loyalty-coupon?apiView=SDK.md

## Permission Scopes:
Read Loyalty: SCOPE.DC-LOYALTY.READ-LOYALTY

## Introduction

Retrieves a list of loyalty coupons, with the specified paging, filtering, and sorting.

---

## REST API

### Schema

```
 Method: queryLoyaltyCoupon
 Description: Retrieves a list of loyalty coupons, with the specified paging, filtering, and sorting.
 URL: https://www.wixapis.com/loyalty-coupons/v1/coupons/query
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  query
 Method parameters: 
   param name: query | type: QueryV2   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`.  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about [filtering](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#filters).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting).  
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
           - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
              - name: latitude | type: number | description: Address latitude.  | validation: format double
              - name: longitude | type: number | description: Address longitude.  | validation: format double
        - name: fields | type: array<string> | description: Array of projected fields. A list of specific field names to return. If `fieldsets` are also specified, the union of `fieldsets` and `fields` is returned.  
        - name: fieldsets | type: array<string> | description: Array of named, predefined sets of projected fields. A array of predefined named sets of fields to be returned. Specifying multiple `fieldsets` will return the union of fields from all sets. If `fields` are also specified, the union of `fieldsets` and `fields` is returned.  
 Query fields:
   - field: accountId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: memberId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: transactionId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: couponReference | operators: $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: status | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: rewardName | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: updatedDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryLoyaltyCouponResponse
  - name: loyaltyCoupons | type: array<LoyaltyCoupon> | description: Retrieved loyalty coupons.  
     - name: id | type: string | description: Loyalty coupon GUID.  | read-only: true | validation: format GUID
     - name: accountId | type: string | description: Loyalty [account GUID](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/account-object.md) of the customer that redeemed points for a coupon.  | read-only: true | validation: format GUID
     - name: memberId | type: string | description: Member GUID of the customer that redeemed points for a coupon. See the Members API for more information.  | read-only: true | validation: format GUID
     - name: transactionId | type: string | description: [Transaction GUID](https://dev.wix.com/docs/rest/crm/loyalty-program/transactions/loyalty-transaction-object.md) for the transaction that created a coupon.  | read-only: true | validation: format GUID
     - name: couponReference | type: CouponReference | description: Reference coupon information for the corresponding [coupon](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/coupon-object.md) that is created along with the loyalty coupon.  | read-only: true 
        - name: couponId | type: string | description: Coupon GUID.  | read-only: true | validation: format GUID
        - name: code | type: string | description: Coupon code.  Unique code entered by a customer to apply the coupon.  | read-only: true | validation: maxLength 20
        - name: name | type: string | description: Name of coupon.  | read-only: true | validation: maxLength 80
        - name: specification | type: Specification | description: The information to use when creating the coupon.  | read-only: true 
           - ONE-OF: 
              - name: moneyOffAmount | type: number | description: Fixed price discount.  | validation: minimum 0.01
              - name: percentOffRate | type: number | description: Discount as a percentage.  
              - name: freeShipping | type: boolean | description: Free shipping. If true, the coupon applies to all items in all `namespaces` on a site.  
              - name: fixedPriceAmount | type: number | description: Specific sale price. Currently only supported for coupons with a `stores` `namespace`.  
              - name: buyXGetY | type: BuyXGetY | description: Free products when making a purchase. `buyXGetY` is an object that specifies `x` and `y` in the following scenario: if a visitor purchases x number of products, they receive y number of products for free. C urrently only supported for coupons with a `stores` `namespace`.  
                 - name: x | type: integer | description: Number of purchased items required to receive free items.  
                 - name: y | type: integer | description: Number of items received for free if required number of items were purchased.  
           - ONE-OF: 
              - name: scope | type: Scope | description: Scope of the coupon. When no scope is defined, the coupon applies to all items in all `namespaces` in the site.  
                 - name: name | type: string | description: Group within a `namespace` for which the coupon is applicable.  If no group is specified, the coupon applies to all items in the namespace. `group` is required in some namespaces. See [Scope Values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values) for a list of currently supported groups for each namespace.  
                 - name: entityId | type: string | description: GUID of the specific entity in the group for which the coupon is applicable.  If no `entityId` is specified, the coupon applies to all entities in the group. In some cases when a group is specified, an `entityId` is required. See [Scope Values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values) for a list of currently supported entities for each namespace and group.  
                 - name: namespace | type: string | description: Wix application for which the coupon is applicable.  One of the following: + `"stores"` + `"bookings"` + `"events"` + `"pricingPlans"`  
              - name: minimumSubtotal | type: number | description: The coupon is only applicable when the order subtotal is over this amount.  | validation: format double
           - name: name | type: string | description: Name of coupon.  
           - name: type | type: Type | description:   
                 - enum: UNKNOWN, MONEY_OFF_AMOUNT, PERCENT_OFF_RATE, FREE_SHIPPING, FIXED_PRICE_AMOUNT, BUY_X_GET_Y
           - name: limitedToOneItem | type: boolean | description: Whether the coupon is limited to 1 discount per order. If true and a customer pays for multiple items that the coupon applies to, only the lowest priced item is discounted. Coupons with a `bookings` `namespace` are always limited to 1 item.  
           - name: appliesToSubscriptions | type: boolean | description: Whether the coupon also applies to subscriptions.  
           - name: discountedCycleCount | type: integer | description: Specifies the amount of cycles to apply the discount to for a subscription item.  Can only be set when `appliesToSubscriptions` is `TRUE` and `specification.scope.namespace` is `pricingPlans`. If `discountedCycleCount` is empty, the coupon applies to all available cycles.  Min: `1`  Max: `999`  | validation: format int32
        - name: deleted | type: boolean | description: Whether the referenced coupon was deleted.  | read-only: true 
     - name: status | type: Status | description: Loyalty coupon status.  This status relates to the corresponding coupon that is created at the same time as the loyalty coupon and is included in `couponReference`.  | read-only: true 
         - enum:
         -     UNKNOWN: Unknown status.
         -     PENDING: The reference coupon was created but the loyalty points have not been redeemed yet.
         -     ACTIVE: The reference coupon is active and available to the customer.
         -     APPLIED: The reference coupon was applied and is no longer available for use.
         -     FAILED: The reference coupon was created but something went wrong when redeeming points from the loyalty account.
         -     ARCHIVED: The reference coupon was deleted.
     - name: rewardName | type: string | description: Name of reward that was redeemed to create this coupon.  | read-only: true | validation: minLength 1, maxLength 50
     - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty coupon is updated.  To prevent conflicting changes, the current `revision` must be passed when updating the loyalty coupon.  | validation: format uint64, immutable
     - name: createdDate | type: string | description: Date and time the loyalty coupon was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the loyalty coupon was last updated.  | read-only: true | validation: format date-time
     - name: refundable | type: boolean | description: Whether the loyalty coupon was created in a "refundable workflow" i.e. checkout-exchange, and therefore can be deleted in the background. Refundable coupons should not be visible to customers in the UI.  | read-only: true 
  - name: metadata | type: PagingMetadataV2 | description: Metadata.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: offset | type: integer | description: Offset that was requested.  | validation: format int32
     - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field.  
     - name: cursors | type: Cursors | description: Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000


```

### Examples

### Query loyalty coupons
```curl
curl -X POST \
  'https://www.wixapis.com/loyalty-coupons/v1/coupons/query' \
  -H 'Authorization: <AUTH>'
  -H 'Content-Type: application/json' \
  --data-raw '{
                "query": {
                  "filter": {"memberId": {"$eq": "e64eee9f-ec4e-4c8a-b015-eb3be0b2761b"}}
                }
              }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.loyalty.coupons.queryLoyaltyCoupons(query)
 Description: Retrieves a list of loyalty coupons, with the specified paging, filtering, and sorting.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  query
 Method parameters: 
   param name: query | type: CouponQuery   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`.  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about [filtering](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#filters).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting).  
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
           - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
              - name: latitude | type: number | description: Address latitude.  
              - name: longitude | type: number | description: Address longitude.  
 Query fields:
   - field: accountId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: memberId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: transactionId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: couponReference | operators: $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: status | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: rewardName | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: _createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: _updatedDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryLoyaltyCouponResponse>
  - name: loyaltyCoupons | type: array<LoyaltyCoupon> | description: Retrieved loyalty coupons.  
     - name: _id | type: string | description: Loyalty coupon GUID.  | read-only: true | validation: format GUID
     - name: accountId | type: string | description: Loyalty [account GUID](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/account-object.md) of the customer that redeemed points for a coupon.  | read-only: true | validation: format GUID
     - name: memberId | type: string | description: Member GUID of the customer that redeemed points for a coupon. See the Members API for more information.  | read-only: true | validation: format GUID
     - name: transactionId | type: string | description: [Transaction GUID](https://dev.wix.com/docs/rest/crm/loyalty-program/transactions/loyalty-transaction-object.md) for the transaction that created a coupon.  | read-only: true | validation: format GUID
     - name: couponReference | type: CouponReference | description: Reference coupon information for the corresponding [coupon](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/coupon-object.md) that is created along with the loyalty coupon.  | read-only: true 
        - name: couponId | type: string | description: Coupon GUID.  | read-only: true | validation: format GUID
        - name: code | type: string | description: Coupon code.  Unique code entered by a customer to apply the coupon.  | read-only: true | validation: maxLength 20
        - name: name | type: string | description: Name of coupon.  | read-only: true | validation: maxLength 80
        - name: specification | type: Specification | description: The information to use when creating the coupon.  | read-only: true 
           - ONE-OF: 
              - name: moneyOffAmount | type: number | description: Fixed price discount.  | validation: minimum 0.01
              - name: percentOffRate | type: number | description: Discount as a percentage.  
              - name: freeShipping | type: boolean | description: Free shipping. If true, the coupon applies to all items in all `namespaces` on a site.  
              - name: fixedPriceAmount | type: number | description: Specific sale price. Currently only supported for coupons with a `stores` `namespace`.  
              - name: buyXGetY | type: BuyXGetY | description: Free products when making a purchase. `buyXGetY` is an object that specifies `x` and `y` in the following scenario: if a visitor purchases x number of products, they receive y number of products for free. C urrently only supported for coupons with a `stores` `namespace`.  
                 - name: x | type: integer | description: Number of purchased items required to receive free items.  
                 - name: y | type: integer | description: Number of items received for free if required number of items were purchased.  
           - ONE-OF: 
              - name: scope | type: Scope | description: Scope of the coupon. When no scope is defined, the coupon applies to all items in all `namespaces` in the site.  
                 - name: name | type: string | description: Group within a `namespace` for which the coupon is applicable.  If no group is specified, the coupon applies to all items in the namespace. `group` is required in some namespaces. See [Scope Values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values) for a list of currently supported groups for each namespace.  
                 - name: entityId | type: string | description: GUID of the specific entity in the group for which the coupon is applicable.  If no `entityId` is specified, the coupon applies to all entities in the group. In some cases when a group is specified, an `entityId` is required. See [Scope Values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values) for a list of currently supported entities for each namespace and group.  
                 - name: namespace | type: string | description: Wix application for which the coupon is applicable.  One of the following: + `"stores"` + `"bookings"` + `"events"` + `"pricingPlans"`  
              - name: minimumSubtotal | type: number | description: The coupon is only applicable when the order subtotal is over this amount.  
           - name: name | type: string | description: Name of coupon.  
           - name: type | type: Type | description:   
                 - enum: UNKNOWN, MONEY_OFF_AMOUNT, PERCENT_OFF_RATE, FREE_SHIPPING, FIXED_PRICE_AMOUNT, BUY_X_GET_Y
           - name: limitedToOneItem | type: boolean | description: Whether the coupon is limited to 1 discount per order. If true and a customer pays for multiple items that the coupon applies to, only the lowest priced item is discounted. Coupons with a `bookings` `namespace` are always limited to 1 item.  
           - name: appliesToSubscriptions | type: boolean | description: Whether the coupon also applies to subscriptions.  
           - name: discountedCycleCount | type: integer | description: Specifies the amount of cycles to apply the discount to for a subscription item.  Can only be set when `appliesToSubscriptions` is `TRUE` and `specification.scope.namespace` is `pricingPlans`. If `discountedCycleCount` is empty, the coupon applies to all available cycles.  Min: `1`  Max: `999`  | validation: format int32
        - name: deleted | type: boolean | description: Whether the referenced coupon was deleted.  | read-only: true 
     - name: status | type: Status | description: Loyalty coupon status.  This status relates to the corresponding coupon that is created at the same time as the loyalty coupon and is included in `couponReference`.  | read-only: true 
         - enum:
         -     UNKNOWN: Unknown status.
         -     PENDING: The reference coupon was created but the loyalty points have not been redeemed yet.
         -     ACTIVE: The reference coupon is active and available to the customer.
         -     APPLIED: The reference coupon was applied and is no longer available for use.
         -     FAILED: The reference coupon was created but something went wrong when redeeming points from the loyalty account.
         -     ARCHIVED: The reference coupon was deleted.
     - name: rewardName | type: string | description: Name of reward that was redeemed to create this coupon.  | read-only: true | validation: minLength 1, maxLength 50
     - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty coupon is updated.  To prevent conflicting changes, the current `revision` must be passed when updating the loyalty coupon.  | validation: format uint64, immutable
     - name: _createdDate | type: Date | description: Date and time the loyalty coupon was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the loyalty coupon was last updated.  | read-only: true 
     - name: refundable | type: boolean | description: Whether the loyalty coupon was created in a "refundable workflow" i.e. checkout-exchange, and therefore can be deleted in the background. Refundable coupons should not be visible to customers in the UI.  | read-only: true 
  - name: metadata | type: PagingMetadataV2 | description: Metadata.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: offset | type: integer | description: Offset that was requested.  | validation: format int32
     - name: total | type: integer | description: Total number of items that match the query. Returned if offset paging is used and the `tooManyToCount` flag is not set.  | validation: format int32
     - name: tooManyToCount | type: boolean | description: Flag that indicates the server failed to calculate the `total` field.  
     - name: cursors | type: Cursors | description: Cursors to navigate through the result pages using `next` and `prev`. Returned if cursor paging is used.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000


```

### Examples

### Query loyalty coupons (with elevated permissions)
```javascript
import { coupons } from "@wix/loyalty";
import { auth } from "@wix/essentials";

/* Sample query value:
 *
 * {
 *   "query": {
 *     "fieldsets": [],
 *     "fields": [],
 *     "sort": [],
 *     "filter": {
 *       "couponReference.name": {
 *         "$eq": "10% off all events"
 *       },
 *       "rewardName": {
 *         "$startsWith": "10%"
 *       }
 *     }
 *   }
 * }
 */

const elevatedQueryLoyaltyCoupons = auth.elevate(coupons.queryLoyaltyCoupons);

async function queryLoyaltyCoupons(query) {
  try {
    const result = await elevatedQueryLoyaltyCoupons(query);
    return result;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * 
 * {
 *   "loyaltyCoupons": [
 *     {
 *       "_id": "56826083-0c4a-4e62-88e3-c6978482bde9",
 *       "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303",
 *       "memberIdDeprecated": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
 *       "transactionId": "33490644-0f84-44e4-aa55-738b203fa4bd",
 *       "couponReference": {
 *         "couponId": "a6df2aeb-50fc-4b15-b18d-765be38a6513",
 *         "code": "6QLGQ9RNNR9R",
 *         "name": "10% off all events",
 *         "specification": {
 *           "name": null,
 *           "type": "PERCENT_OFF_RATE",
 *           "limitedToOneItem": false,
 *           "appliesToSubscriptions": null,
 *           "discountedCycleCount": null,
 *           "percentOffRate": 10,
 *           "scope": {"name": "ticket", "entityId": null, "namespace": "events"}
 *         },
 *         "deleted": null
 *       },
 *       "status": "ACTIVE",
 *       "rewardName": "10% off all events",
 *       "revision": "2",
 *       "_createdDate": "2024-06-12T08:29:56.594Z",
 *       "_updatedDate": "2024-06-12T08:29:56.851Z",
 *       "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32"
 *     },
 *     {
 *       "_id": "6fb2cdc0-863f-4b4b-b76d-a73608654aee",
 *       "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303",
 *       "memberIdDeprecated": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
 *       "transactionId": "0b24afeb-2964-4bb2-a5ab-b32e04128c20",
 *       "couponReference": {
 *         "couponId": "27d5d44d-eb61-4533-8f72-01177097e470",
 *         "code": "6QLGLVTGVH8A",
 *         "name": "10% off all events",
 *         "specification": {
 *           "name": null,
 *           "type": "PERCENT_OFF_RATE",
 *           "limitedToOneItem": false,
 *           "appliesToSubscriptions": null,
 *           "discountedCycleCount": null,
 *           "percentOffRate": 10,
 *           "scope": {"name": "ticket", "entityId": null, "namespace": "events"}
 *         },
 *         "deleted": null
 *       },
 *       "status": "ACTIVE",
 *       "rewardName": "10% off all events",
 *       "revision": "2",
 *       "_createdDate": "2024-06-12T08:14:16.884Z",
 *       "_updatedDate": "2024-06-12T08:14:17.403Z",
 *       "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32"
 *     }
 *   ]
 * }
 */
```

### Query loyalty coupons
```javascript
 import { coupons } from "@wix/loyalty";

 /* Sample query value:
  *
  * {
  *   "query": {
  *     "fieldsets": [],
  *     "fields": [],
  *     "sort": [],
  *     "filter": {
  *       "couponReference.name": {
  *         "$eq": "10% off all events"
  *       },
  *       "rewardName": {
  *         "$startsWith": "10%"
  *       }
  *     }
  *   }
  * }
  */

 async function queryLoyaltyCoupons(query) {
   try {
     const result = await coupons.queryLoyaltyCoupons(query);
     return result;
   } catch (error) {
     console.error(error);
     // Handle the error
   }
 }
 
/* Promise resolves to:
 * 
 * {
 *   "loyaltyCoupons": [
 *     {
 *       "_id": "56826083-0c4a-4e62-88e3-c6978482bde9",
 *       "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303",
 *       "memberIdDeprecated": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
 *       "transactionId": "33490644-0f84-44e4-aa55-738b203fa4bd",
 *       "couponReference": {
 *         "couponId": "a6df2aeb-50fc-4b15-b18d-765be38a6513",
 *         "code": "6QLGQ9RNNR9R",
 *         "name": "10% off all events",
 *         "specification": {
 *           "name": null,
 *           "type": "PERCENT_OFF_RATE",
 *           "limitedToOneItem": false,
 *           "appliesToSubscriptions": null,
 *           "discountedCycleCount": null,
 *           "percentOffRate": 10,
 *           "scope": {"name": "ticket", "entityId": null, "namespace": "events"}
 *         },
 *         "deleted": null
 *       },
 *       "status": "ACTIVE",
 *       "rewardName": "10% off all events",
 *       "revision": "2",
 *       "_createdDate": "2024-06-12T08:29:56.594Z",
 *       "_updatedDate": "2024-06-12T08:29:56.851Z",
 *       "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32"
 *     },
 *     {
 *       "_id": "6fb2cdc0-863f-4b4b-b76d-a73608654aee",
 *       "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303",
 *       "memberIdDeprecated": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32",
 *       "transactionId": "0b24afeb-2964-4bb2-a5ab-b32e04128c20",
 *       "couponReference": {
 *         "couponId": "27d5d44d-eb61-4533-8f72-01177097e470",
 *         "code": "6QLGLVTGVH8A",
 *         "name": "10% off all events",
 *         "specification": {
 *           "name": null,
 *           "type": "PERCENT_OFF_RATE",
 *           "limitedToOneItem": false,
 *           "appliesToSubscriptions": null,
 *           "discountedCycleCount": null,
 *           "percentOffRate": 10,
 *           "scope": {"name": "ticket", "entityId": null, "namespace": "events"}
 *         },
 *         "deleted": null
 *       },
 *       "status": "ACTIVE",
 *       "rewardName": "10% off all events",
 *       "revision": "2",
 *       "_createdDate": "2024-06-12T08:14:16.884Z",
 *       "_updatedDate": "2024-06-12T08:14:17.403Z",
 *       "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32"
 *     }
 *   ]
 * }
 */
```

### queryLoyaltyCoupons (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { coupons } from '@wix/loyalty';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { coupons },
  // Include the auth strategy and host as relevant
});


async function queryLoyaltyCoupons(query) {
  const response = await myWixClient.coupons.queryLoyaltyCoupons(query);
};
```

---