> 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

# QueryRules

# Package: serviceFees

# Namespace: ServiceFeesRules

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/online-orders/service-fees/rules/query-rules.md

## Permission Scopes:
Manage Restaurants - all permissions: SCOPE.RESTAURANTS.MEGA-SCOPES

## Introduction

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

Query Rules runs with these defaults, which you can override:
- `cursorPaging.limit` is `50`

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: queryRules
 Description: Retrieves a list of rules, given the provided paging, filtering, and sorting.  Query Rules runs with these defaults, which you can override: - `cursorPaging.limit` is `50`  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/service-fees/v1/rules/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: CursorQuery   | 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: Number of items to load. <br /> Default: `50`  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  You can get the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  
        - name: filter | type: object | description: Filter object. See [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language) for more information.  
        - name: sort | type: array<Sorting> | description: Sort object.  
           - 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: id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: locationId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: appId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryRulesResponse
  - name: rules | type: array<Rule> | description: The retrieved rules.  
     - ONE-OF: 
     - ONE-OF: 
        - name: fixedFee | type: Money | description: Fixed fee. Must hold a positive value.  
           - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative.  | validation: format DECIMAL_VALUE
           - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD).  | validation: format CURRENCY
           - name: formattedValue | type: string | description: Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative.  
        - name: percentageFee | type: string | description: Percentage fee. For example, `5` represents a 5% fee applied to the order's total.  | validation: decimalValue {"maxScale":2,"gte":"0","lte":"100"}
     - ONE-OF: 
     - ONE-OF: 
        - name: conditionOptions | type: Condition | description: Single condition that must be met for the rule to be applied to an order.  
           - ONE-OF: 
              - name: number | type: Number | description: Contains a numeric value and an operation.  Required if `expectedFieldType` is `NUMBER`.  
                 - name: value | type: number | description: Numeric value to compare with the value of the specified field.  
                 - name: operation | type: Operation | description: Operation to use.  
                         - enum:
                         -     EQ: Equal to.
                         -     LT: Strictly less than.
                         -     LE: Less than or equal to.
                         -     GT: Strictly greater than.
                         -     GE: Greater than or equal to.
              - name: list | type: List | description: Contains an array of strings to compare with the value of the specified field. If the value of the field matches a string in the array, the condition is considered met.  Required if `expectedFieldType` is `LIST`.  
                 - name: values | type: array<string> | description: Array of string values to compare with the value of the field. If the value of the fields matches a string in the array, the condition is considered met.  | validation: minItems 1, maxItems 100, minLength 1, maxLength 100
           - name: orderFieldPath | type: string | description: Path of the field in the order entity that this condition will evaluate. For example, `priceSummary.subtotal`.  | validation: maxLength 1000
           - name: expectedFieldType | type: ExpectedFieldType | description: Type of the field specified in `orderFieldPath`. For example, the type of `priceSummary.subtotal` is `"NUMBER"`).  
                 - enum:
                 -     UNKNOWN_EXPECTED_FIELD_TYPE: Unknown expected field type
                 -     NUMBER: Represents a number value.
                 -     STRING: Represents a string value.
        - name: conditionTreeOptions | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.  
           - ONE-OF: 
              - name: leftCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order.  
              - name: leftConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.  
           - ONE-OF: 
              - name: rightCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order.  
              - name: rightConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.  
           - name: operator | type: Operator | description: Specifies the logical operator to use when combining the evaluation of the left and right conditions.  
                 - enum:
                 -     AND: The condition is true if both the left and right sides are true.
                 -     OR: The condition is true if either the left or right side is true.
     - ONE-OF: 
        - name: customTaxRate | type: string | description: Percentage value to apply as a custom tax rate. Range: [0-100].  
        - name: taxGroupId | type: string | description: Tax group GUID. Internal only.  | validation: format GUID
     - name: id | type: string | description: Rule GUID.  | read-only: true 
     - name: locationId | type: string | description: Business location GUID ([SDK](https://dev.wix.com/docs/sdk/backend-modules/restaurants/wix-restaurants-new/about-business-locations.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/restaurants/wix-restaurants-new/about-business-locations.md)) of the rule.  | validation: format GUID
     - name: name | type: string | description: Rule name.  | validation: minLength 1, maxLength 50
     - name: createdDate | type: string | description: Date and time the rule was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the rule was updated.  | read-only: true | validation: format date-time
     - name: conditionType | type: ConditionType | description: Specifies the type of condition.  
         - enum:
         -     UNDEFINED_CONDITION_TYPE: Indicates that the Rule has no conditions specified.
         -     CONDITION: Indicates that the Rule has a single Condition.
         -     CONDITION_TREE: Indicates that the Rule has a complex condition specified as a ConditionTree.
     - name: enabled | type: boolean | description: Whether the rule is enabled. If `true`, the rule is evaluated when service fees are calculated. If `false`, the rule will not be evaluated when service fees are calculated.  
     - name: revision | type: string | description: Revision number. Increments by 1 each time the rule is updated. To prevent conflicting changes, the existing `revision` must be used when updating a rule.  | read-only: true | validation: format uint64
     - name: appId | type: string | description: Defines the app that the rule is connected to.  | validation: format GUID
     - name: roundingStrategy | type: RoundingStrategy | description: Rounding strategy to apply to fee and tax calculation.  
         - enum:
         -     HALF_UP: Rounds up any number exactly halfway between two integers. For example, `2.5` rounds to `3`, and `3.5` and rounds to `4`.
         -     HALF_EVEN: Rounds such numbers to the nearest even integer. For example, `2.5` rounds to `2`, but `3.5` rounds to `4`.
     - name: extendedFields | type: ExtendedFields | description: Data Extensions  
        - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
     - name: tags | type: Tags | description: Tags ([SDK](https://dev.wix.com/docs/sdk/backend-modules/tags/tags/introduction.md) | [REST](https://dev.wix.com/docs/rest/business-management/tags/introduction.md)) used to classify and sort different types of rules.  
        - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.  
           - name: tagIds | type: array<string> | description: List of tag GUIDs  | validation: maxItems 100, maxLength 5
        - name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
  - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: cursors | type: Cursors | description: Offset that was requested.  
        - name: next | type: string | description: Cursor pointing to next page in the list of results.  
        - name: prev | type: string | description: Cursor pointing to previous page in the list of results.  
     - name: hasNext | type: boolean | description: Indicates if there are more results after the current page. If `true`, another page of results can be retrieved. If `false`, this is the last page.  


```

### Examples

### Query rules with filter and sort
```curl
curl -X POST https://www.wixapis.com/service-fees/v1/rules/query \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
--data-raw '{
    "query": {
        "sort": [
            {
                "fieldName": "id",
                "order": "ASC"
            }
        ],
        "filter": {
            "locationId": "d84423ab-f73d-44a9-9ffb-f36fb163dc6b"
        }
    }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.restaurants.serviceFees.queryRules(query)
 Description: Retrieves a list of rules, given the provided paging, filtering, and sorting.  Query Rules runs with these defaults, which you can override: - `cursorPaging.limit` is `50`  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: RuleQuery   | 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: Number of items to load. <br /> Default: `50`  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  You can get the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  
        - name: filter | type: object | description: Filter object. See [API Query Language](https://dev.wix.com/api/rest/getting-started/api-query-language) for more information.  
        - name: sort | type: array<Sorting> | description: Sort object.  
           - 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: _id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: locationId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: appId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryRulesResponse>
  - name: rules | type: array<Rule> | description: The retrieved rules.  
     - ONE-OF: 
     - ONE-OF: 
        - name: fixedFee | type: Money | description: Fixed fee. Must hold a positive value.  
           - name: value | type: string | description: Monetary amount. Decimal string with a period as a decimal separator (e.g., 3.99). Optionally, a single (-), to indicate that the amount is negative.  | validation: format DECIMAL_VALUE
           - name: currency | type: string | description: Currency code. Must be valid ISO 4217 currency code (e.g., USD).  | validation: format CURRENCY
           - name: formattedValue | type: string | description: Monetary amount. Decimal string in local format (e.g., 1 000,30). Optionally, a single (-), to indicate that the amount is negative.  
        - name: percentageFee | type: string | description: Percentage fee. For example, `5` represents a 5% fee applied to the order's total.  | validation: decimalValue {"maxScale":2,"gte":"0","lte":"100"}
     - ONE-OF: 
     - ONE-OF: 
        - name: conditionOptions | type: Condition | description: Single condition that must be met for the rule to be applied to an order.  
           - ONE-OF: 
              - name: number | type: Number | description: Contains a numeric value and an operation.  Required if `expectedFieldType` is `NUMBER`.  
                 - name: value | type: number | description: Numeric value to compare with the value of the specified field.  
                 - name: operation | type: Operation | description: Operation to use.  
                         - enum:
                         -     EQ: Equal to.
                         -     LT: Strictly less than.
                         -     LE: Less than or equal to.
                         -     GT: Strictly greater than.
                         -     GE: Greater than or equal to.
              - name: list | type: List | description: Contains an array of strings to compare with the value of the specified field. If the value of the field matches a string in the array, the condition is considered met.  Required if `expectedFieldType` is `LIST`.  
                 - name: values | type: array<string> | description: Array of string values to compare with the value of the field. If the value of the fields matches a string in the array, the condition is considered met.  | validation: minItems 1, maxItems 100, minLength 1, maxLength 100
           - name: orderFieldPath | type: string | description: Path of the field in the order entity that this condition will evaluate. For example, `priceSummary.subtotal`.  | validation: maxLength 1000
           - name: expectedFieldType | type: ExpectedFieldType | description: Type of the field specified in `orderFieldPath`. For example, the type of `priceSummary.subtotal` is `"NUMBER"`).  
                 - enum:
                 -     UNKNOWN_EXPECTED_FIELD_TYPE: Unknown expected field type
                 -     NUMBER: Represents a number value.
                 -     STRING: Represents a string value.
        - name: conditionTreeOptions | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.  
           - ONE-OF: 
              - name: leftCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order.  
              - name: leftConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.  
           - ONE-OF: 
              - name: rightCondition | type: Condition | description: Single condition that must be met for the rule to be applied to an order.  
              - name: rightConditionsTree | type: ConditionTree | description: Binary tree of conditions. Use the operator to indicate whether only one or both conditions must be met in order for a service fee rule to be applied to an order.  
           - name: operator | type: Operator | description: Specifies the logical operator to use when combining the evaluation of the left and right conditions.  
                 - enum:
                 -     AND: The condition is true if both the left and right sides are true.
                 -     OR: The condition is true if either the left or right side is true.
     - ONE-OF: 
        - name: customTaxRate | type: string | description: Percentage value to apply as a custom tax rate. Range: [0-100].  
        - name: taxGroupId | type: string | description: Tax group GUID. Internal only.  | validation: format GUID
     - name: _id | type: string | description: Rule GUID.  | read-only: true 
     - name: locationId | type: string | description: Business location GUID ([SDK](https://dev.wix.com/docs/sdk/backend-modules/restaurants/wix-restaurants-new/about-business-locations.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/restaurants/wix-restaurants-new/about-business-locations.md)) of the rule.  | validation: format GUID
     - name: name | type: string | description: Rule name.  | validation: minLength 1, maxLength 50
     - name: _createdDate | type: Date | description: Date and time the rule was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the rule was updated.  | read-only: true 
     - name: conditionType | type: ConditionType | description: Specifies the type of condition.  
         - enum:
         -     UNDEFINED_CONDITION_TYPE: Indicates that the Rule has no conditions specified.
         -     CONDITION: Indicates that the Rule has a single Condition.
         -     CONDITION_TREE: Indicates that the Rule has a complex condition specified as a ConditionTree.
     - name: enabled | type: boolean | description: Whether the rule is enabled. If `true`, the rule is evaluated when service fees are calculated. If `false`, the rule will not be evaluated when service fees are calculated.  
     - name: revision | type: string | description: Revision number. Increments by 1 each time the rule is updated. To prevent conflicting changes, the existing `revision` must be used when updating a rule.  | read-only: true | validation: format uint64
     - name: appId | type: string | description: Defines the app that the rule is connected to.  | validation: format GUID
     - name: roundingStrategy | type: RoundingStrategy | description: Rounding strategy to apply to fee and tax calculation.  
         - enum:
         -     HALF_UP: Rounds up any number exactly halfway between two integers. For example, `2.5` rounds to `3`, and `3.5` and rounds to `4`.
         -     HALF_EVEN: Rounds such numbers to the nearest even integer. For example, `2.5` rounds to `2`, but `3.5` rounds to `4`.
     - name: extendedFields | type: ExtendedFields | description: Data Extensions  
        - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
     - name: tags | type: Tags | description: Tags ([SDK](https://dev.wix.com/docs/sdk/backend-modules/tags/tags/introduction.md) | [REST](https://dev.wix.com/docs/rest/business-management/tags/introduction.md)) used to classify and sort different types of rules.  
        - name: privateTags | type: TagList | description: Tags that require an additional permission in order to access them, normally not given to site members or visitors.  
           - name: tagIds | type: array<string> | description: List of tag GUIDs  | validation: maxItems 100, maxLength 5
        - name: tags | type: TagList | description: Tags that are exposed to anyone who has access to the labeled entity itself, including site members and visitors.  
  - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata.  
     - name: count | type: integer | description: Number of items returned in the response.  | validation: format int32
     - name: cursors | type: Cursors | description: Offset that was requested.  
        - name: next | type: string | description: Cursor pointing to next page in the list of results.  
        - name: prev | type: string | description: Cursor pointing to previous page in the list of results.  
     - name: hasNext | type: boolean | description: Indicates if there are more results after the current page. If `true`, another page of results can be retrieved. If `false`, this is the last page.  


```

### Examples

### queryRules
```javascript
// @title Query Service Fee Rules
import { serviceFees } from "@wix/restaurants";

async function queryRules() {
  const response = await serviceFees
    .queryRules()
    .find();
  return response;
}

```

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

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


async function queryRules(query) {
  const response = await myWixClient.serviceFees.queryRules(query);
};
```

---