> 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

# SearchGiftCards

# Package: giftCards

# Namespace: GiftCardService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/gift-cards/gift-cards/search-gift-cards.md

## Permission Scopes:
Manage eCommerce - all permissions: SCOPE.DC-ECOM-MEGA.MANAGE-ECOM

## Introduction

Retrieves a list of gift cards that match the provided search options, paging, and filtering.

Learn about working with [Search, Query and List Methods](https://dev.wix.com/docs/rest/articles/get-started/search-query-and-list-methods.md).

---

## REST API

### Schema

```
 Method: searchGiftCards
 Description: Retrieves a list of gift cards that match the provided search options, paging, and filtering.  Learn about working with [Search, Query and List Methods](https://dev.wix.com/docs/rest/articles/get-started/search-query-and-list-methods.md).
 URL: https://www.wixapis.com/gift-cards/v1/gift-cards/search
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  search
 Method parameters: 
   param name: search | type: CursorSearch   | 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 the [filter section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-filter-section).  
        - name: sort | type: array<Sorting> | description: List of sort objects.  Learn more about the [sort section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-sort-section).  | validation: maxItems 10
           - 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: aggregations | type: array<Aggregation> | description: Aggregations | Faceted search: refers to a way to explore large amounts of data by displaying summaries about various partitions of the data and later allowing to narrow the navigation to a specific partition.  | validation: maxItems 10
           - ONE-OF: 
              - name: value | type: ValueAggregation | description: Value aggregation  
                 - ONE-OF: 
                    - name: includeOptions | type: IncludeMissingValuesOptions | description: Options for including missing values  
                       - name: addToBucket | type: string | description: Can specify custom bucket name. Defaults are [string -> "N/A"], [int -> "0"], [bool -> "false"] ...  | validation: maxLength 20
                 - name: sortType | type: SortType | description: Should sort by number of matches or value of the field  
                         - enum:
                         -     COUNT: Should sort by number of matches
                         -     VALUE: Should sort by value of the field alphabetically
                 - name: sortDirection | type: SortDirection | description: Should sort in ascending or descending order  
                         - enum:
                         -     DESC: Should sort in descending order
                         -     ASC: Should sort in ascending order
                 - name: limit | type: integer | description: How many aggregations would you like to return? Can be between 1 and 250. 10 is the default.  | validation: format int32
                 - name: missingValues | type: MissingValues | description: Should missing values be included or excluded from the aggregation results. Default is EXCLUDE  
                         - enum:
                         -     EXCLUDE: Should missing values be excluded from the aggregation results
                         -     INCLUDE: Should missing values be included in the aggregation results
              - name: range | type: RangeAggregation | description: Range aggregation  
                 - name: buckets | type: array<RangeBucket> | description: List of range buckets, where during aggregation each entity will be placed in the first bucket where its value falls into based on provided range bounds  | validation: maxItems 50
                    - name: from | type: number | description: Inclusive lower bound of the range. Required if to is not given  | validation: format double
                    - name: to | type: number | description: Exclusive upper bound of the range. Required if from is not given  | validation: format double
              - name: scalar | type: ScalarAggregation | description: Scalar aggregation  
                 - name: type | type: ScalarType | description: Define the operator for the scalar aggregation  
                         - enum:
                         -     COUNT_DISTINCT: Count of distinct values
                         -     MIN: Minimum value
                         -     MAX: Maximum value
              - name: dateHistogram | type: DateHistogramAggregation | description: Date histogram aggregation  
                 - name: interval | type: Interval | description: Interval for date histogram aggregation  
                         - enum:
                         -     YEAR: Yearly interval
                         -     MONTH: Monthly interval
                         -     WEEK: Weekly interval
                         -     DAY: Daily interval
                         -     HOUR: Hourly interval
                         -     MINUTE: Minute interval
                         -     SECOND: Second interval
              - name: nested | type: NestedAggregation | description: Nested aggregation  
                 - name: nestedAggregations | type: array<NestedAggregationItem> | description: Flattened list of aggregations, where each next aggregation is nested within previous one  | validation: minItems 2, maxItems 3
                    - ONE-OF: 
                       - name: value | type: ValueAggregation | description: Value aggregation  
                       - name: range | type: RangeAggregation | description: Range aggregation  
                       - name: scalar | type: ScalarAggregation | description: Scalar aggregation  
                       - name: dateHistogram | type: DateHistogramAggregation | description: Date histogram aggregation  
                    - name: name | type: string | description: User-defined name of aggregation, should be unique, will appear in aggregation results  | validation: maxLength 100
                    - name: type | type: NestedAggregationType | description: Type of aggregation, client must provide matching aggregation field below  
                             - enum:
                             -     VALUE: An aggregation where result buckets are dynamically built - one per unique value
                             -     RANGE: An aggregation, where user can define set of ranges - each representing a bucket
                             -     SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg
                             -     DATE_HISTOGRAM: An aggregation, where result buckets are dynamically built - one per time interval (hour, day, week, etc.)
                    - name: fieldPath | type: string | description: Field to aggregate by, use dont notation to specify json path  | validation: maxLength 200
           - name: name | type: string | description: User-defined name of aggregation, should be unique, will appear in aggregation results  | validation: maxLength 100
           - name: type | type: AggregationType | description: Type of aggregation, client must provide matching aggregation field below  
                 - enum:
                 -     VALUE: An aggregation where result buckets are dynamically built - one per unique value
                 -     RANGE: An aggregation, where user can define set of ranges - each representing a bucket
                 -     SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg
                 -     DATE_HISTOGRAM: An aggregation, where result buckets are dynamically built - one per time interval (hour, day, week, etc.)
                 -     NESTED: Multi-level aggregation, where each next aggregation is nested within previous one
           - name: fieldPath | type: string | description: Field to aggregate by, use dot notation to specify json path  | validation: maxLength 200
        - name: search | type: SearchDetails | description: Free text to match in searchable fields.  
           - name: mode | type: Mode | description: Defines how separate search terms in `expression` are combined  
                 - enum:
                 -     OR: Any of the search terms must be present
                 -     AND: All search terms must be present
           - name: expression | type: string | description: Search term or expression  | validation: maxLength 100
           - name: fields | type: array<string> | description: Fields to search in. If empty - will search in all searchable fields. Use dot notation to specify json path  | validation: maxItems 20, maxLength 200
           - name: fuzzy | type: boolean | description: Flag if should use auto fuzzy search (allowing typos by a managed proximity algorithm)  
        - name: timeZone | type: string | description: UTC offset or IANA time zone. Valid values are ISO 8601 UTC offsets, such as +02:00 or -06:00, and IANA time zone GUIDs, such as Europe/Rome  Affects all filters and aggregations returned values. You may override this behavior in a specific filter by providing timestamps including time zone. e.g. `"2023-12-20T10:52:34.795Z"`  | validation: maxLength 50
 Searchable fields:
   - field: createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: true | searchable: false
   - field: id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: true | searchable: false
   - field: updatedDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: true | searchable: false
   - field: balance | operators: $exists | sort: ASC, DESC | aggregatable: true | searchable: false
   - field: code | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: false | searchable: true
   - field: codeSuffix | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: true | searchable: true
   - field: expirationDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: true | searchable: false
   - field: initialValue | operators: $exists | sort: ASC, DESC | aggregatable: true | searchable: false
 Return type: SearchGiftCardsResponse
  - name: giftCards | type: array<GiftCard> | description: Retrieved gift cards matching the search criteria.  
     - ONE-OF: 
        - name: orderInfo | type: OrderInfo | description: Order details when the gift card was purchased through an order.  | validation: immutable
           - name: orderId | type: string | description: Order GUID associated with the gift card purchase.  | validation: format GUID, immutable
           - name: orderNumber | type: string | description: Human-readable order number displayed to customers. For example, `"1001"`.  | validation: maxLength 100, format DECIMAL_VALUE, immutable, decimalValue {"gt":"0","maxScale":0}
     - name: id | type: string | description: Gift card GUID.  | read-only: true | validation: format GUID
     - name: code | type: string | description: Gift card code used for redemption.  > **Notes:** > + The gift card code can be custom-provided or automatically generated by omitting the field. > + The `code` field contains the **obfuscated** gift card code, for example, `****-****-****-4444`. > + Only the returned code is obfuscated. You can still find a gift card by filtering `code` with the full code.  | validation: minLength 8, maxLength 20, immutable
     - name: initialValue | type: Amount | description: Initial monetary value assigned to the gift card when created.  | validation: immutable
        - name: amount | type: string | description: Monetary amount in the specified currency as a decimal string. For example, `"10.50"` for $10.50, or `"100"` for $100.00.  | validation: format DECIMAL_VALUE, decimalValue {"gte":"0","maxScale":2}
        - name: formattedAmount | type: string | description: Amount formatted with currency symbol for display purposes. For example: `"$10.50"` or `"€25.00"`.  | read-only: true | validation: maxLength 20
     - name: balance | type: Amount | description: Current available balance that can be spent.  Decreases when the gift card is used for purchases and increases with refunds.  | read-only: true 
     - name: currency | type: string | description: Three-letter currency code in [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) format. For example, `"USD"`, `"EUR"`.  | validation: format CURRENCY, immutable
     - name: expirationDate | type: string | description: Date and time when the gift card expires and becomes unusable.  | validation: format date-time, immutable
     - name: createdDate | type: string | description: Date and time the gift card was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the gift card was last updated.  | read-only: true | validation: format date-time
     - name: disabledDate | type: string | description: Date and time the gift card was disabled, if applicable.  | read-only: true | validation: format date-time
     - name: notificationInfo | type: NotificationInfo | description: Email notification settings including recipient, sender, and delivery options.  | validation: immutable
        - name: recipient | type: Recipient | description: Recipient information for email delivery.  | validation: immutable
           - name: email | type: string | description: Email address where the gift card will be sent.  | validation: format EMAIL, immutable
           - name: name | type: string | description: Display name shown in the gift card email.  | validation: maxLength 200, immutable
        - name: notificationDate | type: string | description: Scheduled date and time to send the gift card email notification. Leave empty to send the email immediately.  | validation: format date-time, immutable
        - name: personalizedMessage | type: string | description: Custom message to include in the gift card email. Personalizes the gift card for the recipient.  | validation: minLength 1, maxLength 500, immutable
        - name: sender | type: Sender | description: Sender information for email display.  | validation: immutable
           - name: email | type: string | description: Email address displayed in the gift card notification.  | validation: format EMAIL, immutable
           - name: name | type: string | description: Display name shown in the gift card email.  | validation: maxLength 200, immutable
     - name: source | type: Source | description: How the gift card was created.  | validation: immutable
         - enum:
         -     ORDER: Gift card was purchased through an order.
         -     MANUAL: Gift card was created manually via API.
     - name: codeSuffix | type: string | description: Last 4 characters of the gift card code for search and identification purposes.  | read-only: true | validation: minLength 4, maxLength 4
  - name: pagingMetadata | type: CursorPagingMetadata | description: Paging information for navigating through large result sets.  
     - name: count | type: integer | description: Number of items returned in the response.  | 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.  
  - name: aggregationData | type: AggregationData | description: Aggregation data providing insights about the search results.  
     - name: results | type: array<AggregationResults> | description: key = aggregation name (as derived from search request)  | validation: maxItems 10000
        - ONE-OF: 
           - name: values | type: ValueResults | description: Value aggregation results  
              - name: results | type: array<ValueAggregationResult> | description: List of value aggregations  | validation: maxItems 250
                 - name: value | type: string | description: Value of the field  | validation: maxLength 100
                 - name: count | type: integer | description: Count of entities with this value  
           - name: ranges | type: RangeResults | description: Range aggregation results  
              - name: results | type: array<RangeAggregationResult> | description: List of ranges returned in same order as requested  | validation: maxItems 50
                 - name: from | type: number | description: Inclusive lower bound of the range  | validation: format double
                 - name: to | type: number | description: Exclusive upper bound of the range  | validation: format double
                 - name: count | type: integer | description: Count of entities in this range  
           - name: scalar | type: ScalarResult | description: Scalar aggregation results  
              - name: type | type: ScalarType | description: Type of scalar aggregation  
                     - enum:
                     -     COUNT_DISTINCT: Count of distinct values
                     -     MIN: Minimum value
                     -     MAX: Maximum value
              - name: value | type: number | description: Value of the scalar aggregation  
           - name: groupedByValue | type: GroupByValueResults | description: Group by value aggregation results  
              - name: results | type: array<NestedValueAggregationResult> | description: List of value aggregations  | validation: maxItems 1000
                 - name: value | type: string | description: Value of the field  | validation: maxLength 1000
                 - name: nestedResults | type: NestedAggregationResults | description: Nested aggregations  
                    - ONE-OF: 
                       - name: values | type: ValueResults | description: Value aggregation results  
                       - name: ranges | type: RangeResults | description: Range aggregation results  
                       - name: scalar | type: ScalarResult | description: Scalar aggregation results  
                    - name: name | type: string | description: User-defined name of aggregation, matches the one provided in request  | validation: maxLength 100
                    - name: type | type: AggregationType | description: Type of aggregation that matches result  
                             - enum:
                             -     VALUE: An aggregation where result buckets are dynamically built - one per unique value
                             -     RANGE: An aggregation, where user can define set of ranges - each representing a bucket
                             -     SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg
                             -     DATE_HISTOGRAM: An aggregation, where result buckets are dynamically built - one per time interval (hour, day, week, etc.)
                             -     NESTED: Multi-level aggregation, where each next aggregation is nested within previous one
                    - name: fieldPath | type: string | description: Field to aggregate by, matches the one provided in request  | validation: maxLength 200
           - name: dateHistogram | type: DateHistogramResults | description: Date histogram aggregation results  
              - name: results | type: array<DateHistogramResult> | description: List of date histogram aggregations  | validation: maxItems 200
                 - name: value | type: string | description: Date in ISO 8601 format  | validation: maxLength 100
                 - name: count | type: integer | description: Count of documents in the bucket  
           - name: nested | type: NestedResults | description: Nested aggregation results  
              - name: results | type: array<Results> | description: List of nested aggregations  | validation: maxItems 1000
                 - name: results | type: Map<string,NestedResultValue> | description: List of nested aggregations  | validation: format map
                    - ONE-OF: 
                       - name: value | type: ValueResult | description: Value aggregation result  
                          - name: value | type: string | description: Value of the field  | validation: maxLength 1000
                          - name: count | type: integer | description: Count of entities with this value  | validation: format int32
                       - name: range | type: RangeResult | description: Range aggregation result  
                          - name: from | type: number | description: Inclusive lower bound of the range  | validation: format double
                          - name: to | type: number | description: Exclusive upper bound of the range  | validation: format double
                          - name: count | type: integer | description: Count of entities in this range  | validation: format int32
                       - name: scalar | type: ScalarResult | description: Scalar aggregation result  
                          - name: value | type: number | description: Value of the scalar aggregation  
                       - name: dateHistogram | type: ValueResult | description: Date histogram aggregation result  
        - name: name | type: string | description: User-defined name of aggregation as derived from search request  | validation: maxLength 100
        - name: type | type: AggregationType | description: Type of aggregation that must match provided kind as derived from search request  
        - name: fieldPath | type: string | description: Field to aggregate by as derived from search request  | validation: maxLength 200


```

### Examples

### Search Gift Cards
Searches for existing gift cards filtered by `expirationDate`, sorted by `createdDate` in descending order, with a limit of 2

```curl
curl -X POST \
  'https://www.wixapis.com/gift-cards/v1/gift-cards/search' \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  -d '{
    "search": {
      "filter": {
        "expirationDate": {
          "$gte": "2024-10-01T14:52:02.588Z"
        }
      },
      "sort": [
        {
          "fieldName": "createdDate",
          "order":"DESC"
        }
      ],
      "cursorPaging": {
        "limit": 2
      }
    }
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.giftVouchers.giftVouchers.searchGiftCards(search)
 Description: Retrieves a list of gift cards that match the provided search options, paging, and filtering.  Learn about working with [Search, Query and List Methods](https://dev.wix.com/docs/rest/articles/get-started/search-query-and-list-methods.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  search
 Method parameters: 
   param name: search | type: CursorSearch   | 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 the [filter section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-filter-section).  
        - name: sort | type: array<Sorting> | description: List of sort objects.  Learn more about the [sort section](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#the-sort-section).  | validation: maxItems 10
           - 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: aggregations | type: array<Aggregation> | description: Aggregations | Faceted search: refers to a way to explore large amounts of data by displaying summaries about various partitions of the data and later allowing to narrow the navigation to a specific partition.  | validation: maxItems 10
           - ONE-OF: 
              - name: value | type: ValueAggregation | description: Value aggregation  
                 - ONE-OF: 
                    - name: includeOptions | type: IncludeMissingValuesOptions | description: Options for including missing values  
                       - name: addToBucket | type: string | description: Can specify custom bucket name. Defaults are [string -> "N/A"], [int -> "0"], [bool -> "false"] ...  | validation: maxLength 20
                 - name: sortType | type: SortType | description: Should sort by number of matches or value of the field  
                         - enum:
                         -     COUNT: Should sort by number of matches
                         -     VALUE: Should sort by value of the field alphabetically
                 - name: sortDirection | type: SortDirection | description: Should sort in ascending or descending order  
                         - enum:
                         -     DESC: Should sort in descending order
                         -     ASC: Should sort in ascending order
                 - name: limit | type: integer | description: How many aggregations would you like to return? Can be between 1 and 250. 10 is the default.  | validation: format int32
                 - name: missingValues | type: MissingValues | description: Should missing values be included or excluded from the aggregation results. Default is EXCLUDE  
                         - enum:
                         -     EXCLUDE: Should missing values be excluded from the aggregation results
                         -     INCLUDE: Should missing values be included in the aggregation results
              - name: range | type: RangeAggregation | description: Range aggregation  
                 - name: buckets | type: array<RangeBucket> | description: List of range buckets, where during aggregation each entity will be placed in the first bucket where its value falls into based on provided range bounds  | validation: maxItems 50
                    - name: from | type: number | description: Inclusive lower bound of the range. Required if to is not given  
                    - name: to | type: number | description: Exclusive upper bound of the range. Required if from is not given  
              - name: scalar | type: ScalarAggregation | description: Scalar aggregation  
                 - name: type | type: ScalarType | description: Define the operator for the scalar aggregation  
                         - enum:
                         -     COUNT_DISTINCT: Count of distinct values
                         -     MIN: Minimum value
                         -     MAX: Maximum value
              - name: dateHistogram | type: DateHistogramAggregation | description: Date histogram aggregation  
                 - name: interval | type: Interval | description: Interval for date histogram aggregation  
                         - enum:
                         -     YEAR: Yearly interval
                         -     MONTH: Monthly interval
                         -     WEEK: Weekly interval
                         -     DAY: Daily interval
                         -     HOUR: Hourly interval
                         -     MINUTE: Minute interval
                         -     SECOND: Second interval
              - name: nested | type: NestedAggregation | description: Nested aggregation  
                 - name: nestedAggregations | type: array<NestedAggregationItem> | description: Flattened list of aggregations, where each next aggregation is nested within previous one  | validation: minItems 2, maxItems 3
                    - ONE-OF: 
                       - name: value | type: ValueAggregation | description: Value aggregation  
                       - name: range | type: RangeAggregation | description: Range aggregation  
                       - name: scalar | type: ScalarAggregation | description: Scalar aggregation  
                       - name: dateHistogram | type: DateHistogramAggregation | description: Date histogram aggregation  
                    - name: name | type: string | description: User-defined name of aggregation, should be unique, will appear in aggregation results  | validation: maxLength 100
                    - name: type | type: NestedAggregationType | description: Type of aggregation, client must provide matching aggregation field below  
                             - enum:
                             -     VALUE: An aggregation where result buckets are dynamically built - one per unique value
                             -     RANGE: An aggregation, where user can define set of ranges - each representing a bucket
                             -     SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg
                             -     DATE_HISTOGRAM: An aggregation, where result buckets are dynamically built - one per time interval (hour, day, week, etc.)
                    - name: fieldPath | type: string | description: Field to aggregate by, use dont notation to specify json path  | validation: maxLength 200
           - name: name | type: string | description: User-defined name of aggregation, should be unique, will appear in aggregation results  | validation: maxLength 100
           - name: type | type: AggregationType | description: Type of aggregation, client must provide matching aggregation field below  
                 - enum:
                 -     VALUE: An aggregation where result buckets are dynamically built - one per unique value
                 -     RANGE: An aggregation, where user can define set of ranges - each representing a bucket
                 -     SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg
                 -     DATE_HISTOGRAM: An aggregation, where result buckets are dynamically built - one per time interval (hour, day, week, etc.)
                 -     NESTED: Multi-level aggregation, where each next aggregation is nested within previous one
           - name: fieldPath | type: string | description: Field to aggregate by, use dot notation to specify json path  | validation: maxLength 200
        - name: search | type: SearchDetails | description: Free text to match in searchable fields.  
           - name: mode | type: Mode | description: Defines how separate search terms in `expression` are combined  
                 - enum:
                 -     OR: Any of the search terms must be present
                 -     AND: All search terms must be present
           - name: expression | type: string | description: Search term or expression  | validation: maxLength 100
           - name: fields | type: array<string> | description: Fields to search in. If empty - will search in all searchable fields. Use dot notation to specify json path  | validation: maxItems 20, maxLength 200
           - name: fuzzy | type: boolean | description: Flag if should use auto fuzzy search (allowing typos by a managed proximity algorithm)  
        - name: timeZone | type: string | description: UTC offset or IANA time zone. Valid values are ISO 8601 UTC offsets, such as +02:00 or -06:00, and IANA time zone GUIDs, such as Europe/Rome  Affects all filters and aggregations returned values. You may override this behavior in a specific filter by providing timestamps including time zone. e.g. `"2023-12-20T10:52:34.795Z"`  | validation: maxLength 50
 Searchable fields:
   - field: _createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: true | searchable: false
   - field: _id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: true | searchable: false
   - field: _updatedDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: true | searchable: false
   - field: balance | operators: $exists | sort: ASC, DESC | aggregatable: true | searchable: false
   - field: code | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: false | searchable: true
   - field: codeSuffix | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: true | searchable: true
   - field: expirationDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: true | searchable: false
   - field: initialValue | operators: $exists | sort: ASC, DESC | aggregatable: true | searchable: false
 Return type: PROMISE<SearchGiftCardsResponse>
  - name: giftCards | type: array<GiftCard> | description: Retrieved gift cards matching the search criteria.  
     - ONE-OF: 
        - name: orderInfo | type: OrderInfo | description: Order details when the gift card was purchased through an order.  | validation: immutable
           - name: orderId | type: string | description: Order GUID associated with the gift card purchase.  | validation: format GUID, immutable
           - name: orderNumber | type: string | description: Human-readable order number displayed to customers. For example, `"1001"`.  | validation: maxLength 100, format DECIMAL_VALUE, immutable, decimalValue {"gt":"0","maxScale":0}
     - name: _id | type: string | description: Gift card GUID.  | read-only: true | validation: format GUID
     - name: code | type: string | description: Gift card code used for redemption.  > **Notes:** > + The gift card code can be custom-provided or automatically generated by omitting the field. > + The `code` field contains the **obfuscated** gift card code, for example, `****-****-****-4444`. > + Only the returned code is obfuscated. You can still find a gift card by filtering `code` with the full code.  | validation: minLength 8, maxLength 20, immutable
     - name: initialValue | type: Amount | description: Initial monetary value assigned to the gift card when created.  | validation: immutable
        - name: amount | type: string | description: Monetary amount in the specified currency as a decimal string. For example, `"10.50"` for $10.50, or `"100"` for $100.00.  | validation: format DECIMAL_VALUE, decimalValue {"gte":"0","maxScale":2}
        - name: formattedAmount | type: string | description: Amount formatted with currency symbol for display purposes. For example: `"$10.50"` or `"€25.00"`.  | read-only: true | validation: maxLength 20
     - name: balance | type: Amount | description: Current available balance that can be spent.  Decreases when the gift card is used for purchases and increases with refunds.  | read-only: true 
     - name: currency | type: string | description: Three-letter currency code in [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) format. For example, `"USD"`, `"EUR"`.  | validation: format CURRENCY, immutable
     - name: expirationDate | type: Date | description: Date and time when the gift card expires and becomes unusable.  | validation: immutable
     - name: _createdDate | type: Date | description: Date and time the gift card was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the gift card was last updated.  | read-only: true 
     - name: disabledDate | type: Date | description: Date and time the gift card was disabled, if applicable.  | read-only: true 
     - name: notificationInfo | type: NotificationInfo | description: Email notification settings including recipient, sender, and delivery options.  | validation: immutable
        - name: recipient | type: Recipient | description: Recipient information for email delivery.  | validation: immutable
           - name: email | type: string | description: Email address where the gift card will be sent.  | validation: format EMAIL, immutable
           - name: name | type: string | description: Display name shown in the gift card email.  | validation: maxLength 200, immutable
        - name: notificationDate | type: Date | description: Scheduled date and time to send the gift card email notification. Leave empty to send the email immediately.  | validation: immutable
        - name: personalizedMessage | type: string | description: Custom message to include in the gift card email. Personalizes the gift card for the recipient.  | validation: minLength 1, maxLength 500, immutable
        - name: sender | type: Sender | description: Sender information for email display.  | validation: immutable
           - name: email | type: string | description: Email address displayed in the gift card notification.  | validation: format EMAIL, immutable
           - name: name | type: string | description: Display name shown in the gift card email.  | validation: maxLength 200, immutable
     - name: source | type: Source | description: How the gift card was created.  | validation: immutable
         - enum:
         -     ORDER: Gift card was purchased through an order.
         -     MANUAL: Gift card was created manually via API.
     - name: codeSuffix | type: string | description: Last 4 characters of the gift card code for search and identification purposes.  | read-only: true | validation: minLength 4, maxLength 4
  - name: pagingMetadata | type: CursorPagingMetadata | description: Paging information for navigating through large result sets.  
     - name: count | type: integer | description: Number of items returned in the response.  | 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.  
  - name: aggregationData | type: AggregationData | description: Aggregation data providing insights about the search results.  
     - name: results | type: array<AggregationResults> | description: key = aggregation name (as derived from search request)  | validation: maxItems 10000
        - ONE-OF: 
           - name: values | type: ValueResults | description: Value aggregation results  
              - name: results | type: array<ValueAggregationResult> | description: List of value aggregations  | validation: maxItems 250
                 - name: value | type: string | description: Value of the field  | validation: maxLength 100
                 - name: count | type: integer | description: Count of entities with this value  
           - name: ranges | type: RangeResults | description: Range aggregation results  
              - name: results | type: array<RangeAggregationResult> | description: List of ranges returned in same order as requested  | validation: maxItems 50
                 - name: from | type: number | description: Inclusive lower bound of the range  
                 - name: to | type: number | description: Exclusive upper bound of the range  
                 - name: count | type: integer | description: Count of entities in this range  
           - name: scalar | type: ScalarResult | description: Scalar aggregation results  
              - name: type | type: ScalarType | description: Type of scalar aggregation  
                     - enum:
                     -     COUNT_DISTINCT: Count of distinct values
                     -     MIN: Minimum value
                     -     MAX: Maximum value
              - name: value | type: number | description: Value of the scalar aggregation  
           - name: groupedByValue | type: GroupByValueResults | description: Group by value aggregation results  
              - name: results | type: array<NestedValueAggregationResult> | description: List of value aggregations  | validation: maxItems 1000
                 - name: value | type: string | description: Value of the field  | validation: maxLength 1000
                 - name: nestedResults | type: NestedAggregationResults | description: Nested aggregations  
                    - ONE-OF: 
                       - name: values | type: ValueResults | description: Value aggregation results  
                       - name: ranges | type: RangeResults | description: Range aggregation results  
                       - name: scalar | type: ScalarResult | description: Scalar aggregation results  
                    - name: name | type: string | description: User-defined name of aggregation, matches the one provided in request  | validation: maxLength 100
                    - name: type | type: AggregationType | description: Type of aggregation that matches result  
                             - enum:
                             -     VALUE: An aggregation where result buckets are dynamically built - one per unique value
                             -     RANGE: An aggregation, where user can define set of ranges - each representing a bucket
                             -     SCALAR: A single-value metric aggregation - e.g. min, max, sum, avg
                             -     DATE_HISTOGRAM: An aggregation, where result buckets are dynamically built - one per time interval (hour, day, week, etc.)
                             -     NESTED: Multi-level aggregation, where each next aggregation is nested within previous one
                    - name: fieldPath | type: string | description: Field to aggregate by, matches the one provided in request  | validation: maxLength 200
           - name: dateHistogram | type: DateHistogramResults | description: Date histogram aggregation results  
              - name: results | type: array<DateHistogramResult> | description: List of date histogram aggregations  | validation: maxItems 200
                 - name: value | type: string | description: Date in ISO 8601 format  | validation: maxLength 100
                 - name: count | type: integer | description: Count of documents in the bucket  
           - name: nested | type: NestedResults | description: Nested aggregation results  
              - name: results | type: array<Results> | description: List of nested aggregations  | validation: maxItems 1000
                 - name: results | type: Map<string,NestedResultValue> | description: List of nested aggregations  | validation: format map
                    - ONE-OF: 
                       - name: value | type: ValueResult | description: Value aggregation result  
                          - name: value | type: string | description: Value of the field  | validation: maxLength 1000
                          - name: count | type: integer | description: Count of entities with this value  | validation: format int32
                       - name: range | type: RangeResult | description: Range aggregation result  
                          - name: from | type: number | description: Inclusive lower bound of the range  
                          - name: to | type: number | description: Exclusive upper bound of the range  
                          - name: count | type: integer | description: Count of entities in this range  | validation: format int32
                       - name: scalar | type: ScalarResult | description: Scalar aggregation result  
                          - name: value | type: number | description: Value of the scalar aggregation  
                       - name: dateHistogram | type: ValueResult | description: Date histogram aggregation result  
        - name: name | type: string | description: User-defined name of aggregation as derived from search request  | validation: maxLength 100
        - name: type | type: AggregationType | description: Type of aggregation that must match provided kind as derived from search request  
        - name: fieldPath | type: string | description: Field to aggregate by as derived from search request  | validation: maxLength 200


```

### Examples

### Search gift cards by code
```javascript
import { giftVouchers } from "@wix/gift-vouchers";

const options = {
  search: { expression: "HAPPY" },
  cursorPaging: { limit: 10 },
};

async function searchGiftCards() {
  const response = await giftVouchers.searchGiftCards(options);
  return response;
}

/* Promise resolves to:
 * {
 *   giftCards: [
 *     {
 *       id: "1d752091-e722-4847-8e3d-9d3d88d34706",
 *       code: "************HDAY",
 *       initialValue: { amount: "100", formattedAmount: "$100.00" },
 *       balance: { amount: "100", formattedAmount: "$100.00" },
 *       currency: "USD",
 *       source: "MANUAL",
 *     },
 *   ],
 *   pagingMetadata: { count: 1, cursors: {}, hasNext: false },
 * }
 */

```

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

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


async function searchGiftCards(search) {
  const response = await myWixClient.giftVouchers.searchGiftCards(search);
};
```

---