> 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

# QueryReferralRewards

# Package: referralProgram

# Namespace: ReferralRewards

# Method link: https://dev.wix.com/docs/api-reference/business-management/marketing/referral-program/referral-rewards/query-referral-rewards?apiView=SDK.md

## Permission Scopes:
Manage Referrals: SCOPE.DC-REFERRALS.MANAGE-REFERRALS

## Introduction

Retrieves a list of referral rewards, given the provided paging, filtering, and sorting.

To learn about working with _Query_ endpoints, see
[API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language),
[Sorting and Paging](https://dev.wix.com/api/rest/getting-started/pagination),
and [Field Projection](https://dev.wix.com/api/rest/getting-started/field-projection).

---

## REST API

### Schema

```
 Method: queryReferralRewards
 Description: Retrieves a list of referral rewards, given the provided paging, filtering, and sorting.  To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language), [Sorting and Paging](https://dev.wix.com/api/rest/getting-started/pagination), and [Field Projection](https://dev.wix.com/api/rest/getting-started/field-projection).
 URL: https://www.wixapis.com/_api/referral-rewards/v1/referral-rewards/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: contactId | type: contactId | description: Contact GUID to filter rewards by. Use `"me"` for current identity's rewards.  
   param name: query | type: CursorQuery   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor paging options.  Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging).  
        - 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).  | validation: maxItems 5
           - 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
 Query fields:
   - field: rewardedReferringCustomerId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: rewardedReferredFriendId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: rewardType | operators: $eq, $ne, $in, $exists | 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: QueryReferralRewardsResponse
  - name: referralRewards | type: array<ReferralReward> | description: Retrieved referral rewards.  
     - ONE-OF: 
        - name: rewardedReferringCustomerId | type: string | description: GUID of the referring customer who received the reward.  | read-only: true | validation: format GUID
        - name: rewardedReferredFriendId | type: string | description: GUID of the referred friend who received the reward.  | read-only: true | validation: format GUID
     - ONE-OF: 
        - name: coupon | type: Coupon | description: Details of a coupon reward. Present when `rewardType` is `COUPON`.  
           - name: id | type: string | description: Coupon GUID. Example: `8934b045-7052-4a90-be2b-832c70afc9da`.  | read-only: true | validation: format GUID
           - name: code | type: string | description: The code that customers can use to apply the coupon. Example: `6RFD2A3HSPXW`.  | read-only: true 
           - name: status | type: Status | description: Current status of the coupon.  | read-only: true 
                 - enum:
                 -     UNKNOWN: Coupon status is unknown or not specified.
                 -     ACTIVE: Coupon is active and can be applied to purchases.
                 -     APPLIED: Coupon was applied and can't be used again.
                 -     DELETED: Coupon was deleted and is no longer valid.
           - name: couponSpecification | type: Coupon | description: Detailed specifications of the coupon.  | read-only: true 
              - ONE-OF: 
                 - name: fixedAmountOptions | type: FixedAmountDiscount | description: Options for fixed amount discount.  
                    - name: amount | type: number | description: Amount of the discount as a fixed value.  | validation: minimum 0.01
                 - name: percentageOptions | type: PercentageDiscount | description: Options for percentage discounts.  
                    - name: percentage | type: number | description: Percentage of discount.  | validation: minimum 0, maximum 100
              - ONE-OF: 
                 - name: minimumSubtotal | type: number | description: Limit the coupon to carts with a subtotal above this number.  
                 - name: scope | type: CouponScope | description: Specifies the type of line items this coupon will apply to. See [valid scope values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values).  
                    - name: namespace | type: string | description: Scope namespace (Wix Stores, Wix Bookings, Wix Events, Wix Pricing Plans)  
                    - name: group | type: Group | description: Coupon scope's applied group, for example, Event or ticket in Wix Events.  
                       - name: name | type: string | description: Name of the group.  
                       - name: entityId | type: string | description: Entity GUID of the group.  
              - name: name | type: string | description: Coupon name.  | validation: minLength 1, maxLength 50
              - name: discountType | type: DiscountType | description: Coupon discount type.  
                     - enum:
                     -     UNKNOWN: Unknown discount type.
                     -     FIXED_AMOUNT: Discount as a fixed amount.
                     -     PERCENTAGE: Discount as a percentage.
                     -     FREE_SHIPPING: Free shipping. If `true`, the coupon applies to all items in all `namespaces`.
              - name: limitedToOneItem | type: boolean | description: Whether the coupon is limited to one item. If `true` and a customer pays for multiple items, the discount applies to only the lowest priced item. Coupons with a bookings `scope.namespace` are always limited to one item.  
              - name: appliesToSubscriptions | type: boolean | description: Whether the coupon applies to subscription products.  
              - name: discountedCycleCount | type: integer | description: Specifies the amount of discounted cycles for a subscription item.  - Can only be set when `scope.namespace = pricingPlans`. - If `discountedCycleCount` is empty, the coupon applies to all available cycles. - `discountedCycleCount` is ignored if `appliesToSubscriptions = true`.  Max: `999`  | validation: format int32
        - name: loyaltyPoints | type: LoyaltyPoints | description: Details of a loyalty points reward. Present when `rewardType` is `LOYALTY_POINTS`.  
           - name: transactionId | type: string | description: Loyalty transaction GUID.  | read-only: true | validation: format GUID
           - name: amount | type: integer | description: The number of loyalty points awarded.  | read-only: true 
     - name: id | type: string | description: Referral reward GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the referral reward is updated. To prevent conflicting changes, the current revision must be passed when updating the referral reward.  | validation: format int64, immutable
     - name: createdDate | type: string | description: Date and time the referral reward was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the referral reward was last updated.  | read-only: true | validation: format date-time
     - name: rewardType | type: Type | description: Type of reward given.  
         - enum:
         -     UNKNOWN: Unknown reward type.
         -     COUPON: Loyalty coupon is given.
         -     LOYALTY_POINTS: Loyalty points are awarded.
         -     NOTHING: No reward is given.
  - name: metadata | type: CursorPagingMetadata | description: Metadata for paging.  
     - name: count | type: integer | description: Number of items returned in current page.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - 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
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### Query Referral Rewards
```curl
curl -X POST \
  'https://www.wixapis.com/_api/referral-rewards/v1/referral-rewards/query' \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  -d '{
        "query": {
            "sort": [
              {
                "order": "DESC",
                "fieldName": "revision"
              }
            ],
            "filter": {
              "rewardType": "CouponReward"
            }
          },
        "contactId": "me"
    }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.referral.rewards.queryReferralRewards(query, options)
 Description: Retrieves a list of referral rewards, given the provided paging, filtering, and sorting.  To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language), [Sorting and Paging](https://dev.wix.com/api/rest/getting-started/pagination), and [Field Projection](https://dev.wix.com/api/rest/getting-started/field-projection).
 # 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: ReferralRewardQuery   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor paging options.  Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging).  
        - 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).  | validation: maxItems 5
           - 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.  
   param name: options | type: QueryReferralRewardsOptions  none  
        - name: contactId | type: string | description: Contact GUID to filter rewards by. Use `"me"` for current identity's rewards.  
 Query fields:
   - field: rewardedReferringCustomerId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: rewardedReferredFriendId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: rewardType | operators: $eq, $ne, $in, $exists | 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<QueryReferralRewardsResponse>
  - name: referralRewards | type: array<ReferralReward> | description: Retrieved referral rewards.  
     - ONE-OF: 
        - name: rewardedReferringCustomerId | type: string | description: GUID of the referring customer who received the reward.  | read-only: true | validation: format GUID
        - name: rewardedReferredFriendId | type: string | description: GUID of the referred friend who received the reward.  | read-only: true | validation: format GUID
     - ONE-OF: 
        - name: coupon | type: Coupon | description: Details of a coupon reward. Present when `rewardType` is `COUPON`.  
           - name: _id | type: string | description: Coupon GUID. Example: `8934b045-7052-4a90-be2b-832c70afc9da`.  | read-only: true | validation: format GUID
           - name: code | type: string | description: The code that customers can use to apply the coupon. Example: `6RFD2A3HSPXW`.  | read-only: true 
           - name: status | type: Status | description: Current status of the coupon.  | read-only: true 
                 - enum:
                 -     UNKNOWN: Coupon status is unknown or not specified.
                 -     ACTIVE: Coupon is active and can be applied to purchases.
                 -     APPLIED: Coupon was applied and can't be used again.
                 -     DELETED: Coupon was deleted and is no longer valid.
           - name: couponSpecification | type: Coupon | description: Detailed specifications of the coupon.  | read-only: true 
              - ONE-OF: 
                 - name: fixedAmountOptions | type: FixedAmountDiscount | description: Options for fixed amount discount.  
                    - name: amount | type: number | description: Amount of the discount as a fixed value.  | validation: minimum 0.01
                 - name: percentageOptions | type: PercentageDiscount | description: Options for percentage discounts.  
                    - name: percentage | type: number | description: Percentage of discount.  | validation: minimum 0, maximum 100
              - ONE-OF: 
                 - name: minimumSubtotal | type: number | description: Limit the coupon to carts with a subtotal above this number.  
                 - name: scope | type: CouponScope | description: Specifies the type of line items this coupon will apply to. See [valid scope values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values).  
                    - name: namespace | type: string | description: Scope namespace (Wix Stores, Wix Bookings, Wix Events, Wix Pricing Plans)  
                    - name: group | type: Group | description: Coupon scope's applied group, for example, Event or ticket in Wix Events.  
                       - name: name | type: string | description: Name of the group.  
                       - name: entityId | type: string | description: Entity GUID of the group.  
              - name: name | type: string | description: Coupon name.  | validation: minLength 1, maxLength 50
              - name: discountType | type: DiscountType | description: Coupon discount type.  
                     - enum:
                     -     UNKNOWN: Unknown discount type.
                     -     FIXED_AMOUNT: Discount as a fixed amount.
                     -     PERCENTAGE: Discount as a percentage.
                     -     FREE_SHIPPING: Free shipping. If `true`, the coupon applies to all items in all `namespaces`.
              - name: limitedToOneItem | type: boolean | description: Whether the coupon is limited to one item. If `true` and a customer pays for multiple items, the discount applies to only the lowest priced item. Coupons with a bookings `scope.namespace` are always limited to one item.  
              - name: appliesToSubscriptions | type: boolean | description: Whether the coupon applies to subscription products.  
              - name: discountedCycleCount | type: integer | description: Specifies the amount of discounted cycles for a subscription item.  - Can only be set when `scope.namespace = pricingPlans`. - If `discountedCycleCount` is empty, the coupon applies to all available cycles. - `discountedCycleCount` is ignored if `appliesToSubscriptions = true`.  Max: `999`  | validation: format int32
        - name: loyaltyPoints | type: LoyaltyPoints | description: Details of a loyalty points reward. Present when `rewardType` is `LOYALTY_POINTS`.  
           - name: transactionId | type: string | description: Loyalty transaction GUID.  | read-only: true | validation: format GUID
           - name: amount | type: integer | description: The number of loyalty points awarded.  | read-only: true 
     - name: _id | type: string | description: Referral reward GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the referral reward is updated. To prevent conflicting changes, the current revision must be passed when updating the referral reward.  | validation: format int64, immutable
     - name: _createdDate | type: Date | description: Date and time the referral reward was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the referral reward was last updated.  | read-only: true 
     - name: rewardType | type: Type | description: Type of reward given.  
         - enum:
         -     UNKNOWN: Unknown reward type.
         -     COUPON: Loyalty coupon is given.
         -     LOYALTY_POINTS: Loyalty points are awarded.
         -     NOTHING: No reward is given.
  - name: metadata | type: CursorPagingMetadata | description: Metadata for paging.  
     - name: count | type: integer | description: Number of items returned in current page.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - 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
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### queryReferralRewards
```javascript
import { rewards } from '@wix/referral';

async function queryReferralRewards(query,options) {
  const response = await rewards.queryReferralRewards(query,options);
};
```

### queryReferralRewards (with elevated permissions)
```javascript
import { rewards } from '@wix/referral';
import { auth } from '@wix/essentials';

async function myQueryReferralRewardsMethod(query,options) {
  const elevatedQueryReferralRewards = auth.elevate(rewards.queryReferralRewards);
  const response = await elevatedQueryReferralRewards(query,options);
}
```

### queryReferralRewards (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 { rewards } from '@wix/referral';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function queryReferralRewards(query,options) {
  const response = await myWixClient.rewards.queryReferralRewards(query,options);
};
```

---