> 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: feedbackModeration

# Namespace: ModerationRules

# Method link: https://dev.wix.com/docs/api-reference/crm/community/feedback-moderation/moderation-rules/query-rules.md

## Permission Scopes:
Manage Moderation Rules: SCOPE.MODERATION.MANAGE-MODERATION-RULES

## Introduction

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

- `createdDate` is sorted in `ASC` order
- `paging.limit` is `100`
- `paging.offset` is `0`

Up to 1,000 rules can be returned per request.

To learn about working with *Query* endpoints, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md).

---

## REST API

### Schema

```
 Method: queryRules
 Description: Retrieves a list of rules, given the provided paging, filtering, and sorting.  - `createdDate` is sorted in `ASC` order - `paging.limit` is `100` - `paging.offset` is `0`  Up to 1,000 rules can be returned per request.  To learn about working with *Query* endpoints, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md).
 URL: https://www.wixapis.com/moderation/v1/rules/query
 Method: POST
 Method parameters:
   param name: query | type: CursorQuery    
     - 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.  | 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.  | validation: maxLength 3000
        - name: filter | type: object | description: Filter object in the following format: `"filter" : { "fieldName1": "value1", "fieldName2":{"$operator":"value2"} }` Example of operators: `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`  
        - name: sort | type: array<Sorting> | description: Sort object in the following format: `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]`  | validation: maxItems 100
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 100
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
 Query fields:
   - field: id | operators: $eq, $ne, $in | sort: none | 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
   - field: namespace | operators: $eq, $ne, $in | sort: none | aggregatable: undefined | searchable: undefined
   - field: enabled | operators: $eq, $ne | sort: none | aggregatable: undefined | searchable: undefined
 Return type: QueryRulesResponse
  - name: rules | type: array<Rule> | description: List of rules.  | validation: maxItems 100
     - name: id | type: string | description: Rule GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which 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 int64
     - name: createdDate | type: string | description: Date and time when the rule was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time when the rule was updated.  | read-only: true | validation: format date-time
     - name: namespace | type: string | description: The app name and entity which the rule belongs to. Currently, moderation rules support [Comments](https://dev.wix.com/docs/rest/crm/community/comments/comments/introduction.md) and [Reviews](https://dev.wix.com/docs/rest/crm/community/reviews/reviews/introduction.md):  + When the `namespace` is `comments` the format is `comments/{APP_ID}`. For example, for moderating content on Wix Blog the `namespace` is `"comments/14bcded7-0066-7c35-14d7-466cb3f09103"`. + When the `namespace` is `reviews` the format is `reviews/{APP_NAME}`. For example, for moderating content on Wix Reviews the `namespace` is `"reviews/stores"`.  To retrieve the GUID for a Wix app, see [Apps Created By Wix](https://dev.wix.com/docs/rest/articles/get-started/apps-created-by-wix.md).  | validation: minLength 1, maxLength 120
     - name: name | type: string | description: Rule name.  | validation: maxLength 120
     - name: audience | type: Audience | description: Audience to which the rule applies.  
        - ONE-OF: 
           - name: newMembersOptions | type: NewMembersOptions | description: Options for new members.  **Note:** This object is relevant only when `type` is `NEW_MEMBERS`.  
              - name: durationInHours | type: integer | description: For how many hours the member is new.  | validation: format int32
        - name: type | type: Type | description: Audience type.  
             - enum: VISITORS, MEMBERS, MEMBERS_AND_VISITORS, NEW_MEMBERS
     - name: trigger | type: Trigger | description: A condition that triggers the rule.  **Note:** If you need to have several triggers for the same `namespace`, create separate rules.  
        - ONE-OF: 
           - name: patternsOptions | type: Patterns | description: Options for the patterns trigger.  
              - name: words | type: array<string> | description: List of words that can trigger a rule. The `*` wildcard can be used to match a partial word. For example: - `spam`: Matches only "spam". - `spam*`: Matches "spam", "spammer", "spammy". - `*spam`: Matches "antispam", "multispam". - `sp*m`: Matches "spim", "spam", "spum".  | validation: maxItems 1000, maxLength 50
              - name: expressions | type: array<string> | description: [Regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions).  | validation: maxItems 10, maxLength 300
           - name: contentFeaturesOptions | type: ContentFeatures | description: Options for the content features trigger.  
              - name: videos | type: boolean | description: Whether the content contains videos.  
              - name: images | type: boolean | description: Whether the content contains images.  
              - name: links | type: boolean | description: Whether the content contains links.  
              - name: attachments | type: boolean | description: Whether the content contains attachments or files.  
           - name: attributeOptions | type: Attribute | description: Options for the attributes trigger. You can only have 1 attribute per rule.  
              - name: name | type: string | description: Attribute name.  | validation: maxLength 20
              - name: values | type: array<string> | description: Attribute values.  | validation: maxItems 20, maxLength 20
        - name: type | type: Type | description: Trigger type.  
             - enum:
             -     PATTERNS: The trigger is a specific word or phrase. You can specify additional options in the `patternsOptions` object.
             -     CONTENT_FEATURES: The rule is triggered when non-textual features, such as videos, images, links, and attachments, exist in the content. You can specify additional options in the `contentFeaturesOptions` object.
             -     ATTRIBUTE: A custom trigger based on an attribute and its value. For example, if you'd like to check all reviews with a low rating, then `name` would be `rating`, and `values` would be `[1, 2]`. You can specify additional options in the `patternsOptions` object.
             -     ALWAYS: There is no specific trigger. The rule is triggered whenever new content is created or existing content is updated, with no other conditions required.
     - name: exemptions | type: Exemptions | description: List of site members or groups to whom the rule doesn't apply.  
        - name: memberGroups | type: array<string> | description: List of member groups.  | validation: maxItems 50, format GUID
        - name: memberIds | type: array<string> | description: List of member GUIDs.  | validation: maxItems 50, format GUID
     - name: action | type: Action | description: What action should be taken after the rule is triggered.  
        - name: type | type: Type | description: Action type.  
             - enum:
             -     UNKNOWN_TYPE: 
             -     REJECT: Reject the content without any further review.
             -     NEEDS_MANUAL_APPROVAL: Send the content for manual review.
     - name: enabled | type: boolean | description: Whether the rule is enabled.  
     - name: extendedFields | type: ExtendedFields | description: Custom field data for the rule object.  **Note:** You must configure extended fields using schema plugin extensions in your app's dashboard before you can access the extended fields with API calls.  
        - 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: 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.  | validation: maxLength 3000
        - name: prev | type: string | description: Cursor pointing to previous page in the list of results.  | validation: maxLength 3000
     - 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 by cursor
```curl
curl -X POST https://www.wixapis.com/moderation/v1/rules/query  \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Authorization: <AUTH>' \
    -d '{
          "query": {
            "cursorPaging": {
              "limit": 1,
              "cursor": "79902130cbb60b4db8ae6b7f0020c04e411ee19b.IiQ1MDBlYTYyYy01ZjRjLTRhNTEtYjgxMy0wYmQ3ZjIzOWM2ZGQ"
            }
          }
        }'
```

### Query rules by stores reviews
```curl
curl -X POST https://www.wixapis.com/moderation/v1/rules/query  \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Authorization: <AUTH>' \
    -d '{
          "query": {
            "sort": [],
            "filter": {
              "namespace": "reviews/stores"
            },
            "cursorPaging": {
              "limit": 1
            }
          }
        }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.moderationRules.moderationRules.queryRules(query)
 Description: Retrieves a list of rules, given the provided paging, filtering, and sorting.  - `createdDate` is sorted in `ASC` order - `paging.limit` is `100` - `paging.offset` is `0`  Up to 1,000 rules can be returned per request.  To learn about working with *Query* endpoints, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md).
 # 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.  | 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.  | validation: maxLength 3000
        - name: filter | type: object | description: Filter object in the following format: `"filter" : { "fieldName1": "value1", "fieldName2":{"$operator":"value2"} }` Example of operators: `$eq`, `$ne`, `$lt`, `$lte`, `$gt`, `$gte`, `$in`, `$hasSome`, `$hasAll`, `$startsWith`, `$contains`  
        - name: sort | type: array<Sorting> | description: Sort object in the following format: `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]`  | validation: maxItems 100
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 100
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
 Query fields:
   - field: _id | operators: $eq, $ne, $in | sort: none | 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
   - field: namespace | operators: $eq, $ne, $in | sort: none | aggregatable: undefined | searchable: undefined
   - field: enabled | operators: $eq, $ne | sort: none | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryRulesResponse>
  - name: rules | type: array<Rule> | description: List of rules.  | validation: maxItems 100
     - name: _id | type: string | description: Rule GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which 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 int64
     - name: _createdDate | type: Date | description: Date and time when the rule was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time when the rule was updated.  | read-only: true 
     - name: namespace | type: string | description: The app name and entity which the rule belongs to. Currently, moderation rules support [Comments](https://dev.wix.com/docs/rest/crm/community/comments/comments/introduction.md) and [Reviews](https://dev.wix.com/docs/rest/crm/community/reviews/reviews/introduction.md):  + When the `namespace` is `comments` the format is `comments/{APP_ID}`. For example, for moderating content on Wix Blog the `namespace` is `"comments/14bcded7-0066-7c35-14d7-466cb3f09103"`. + When the `namespace` is `reviews` the format is `reviews/{APP_NAME}`. For example, for moderating content on Wix Reviews the `namespace` is `"reviews/stores"`.  To retrieve the GUID for a Wix app, see [Apps Created By Wix](https://dev.wix.com/docs/rest/articles/get-started/apps-created-by-wix.md).  | validation: minLength 1, maxLength 120
     - name: name | type: string | description: Rule name.  | validation: maxLength 120
     - name: audience | type: Audience | description: Audience to which the rule applies.  
        - ONE-OF: 
           - name: newMembersOptions | type: NewMembersOptions | description: Options for new members.  **Note:** This object is relevant only when `type` is `NEW_MEMBERS`.  
              - name: durationInHours | type: integer | description: For how many hours the member is new.  | validation: format int32
        - name: type | type: Type | description: Audience type.  
             - enum: VISITORS, MEMBERS, MEMBERS_AND_VISITORS, NEW_MEMBERS
     - name: trigger | type: Trigger | description: A condition that triggers the rule.  **Note:** If you need to have several triggers for the same `namespace`, create separate rules.  
        - ONE-OF: 
           - name: patternsOptions | type: Patterns | description: Options for the patterns trigger.  
              - name: words | type: array<string> | description: List of words that can trigger a rule. The `*` wildcard can be used to match a partial word. For example: - `spam`: Matches only "spam". - `spam*`: Matches "spam", "spammer", "spammy". - `*spam`: Matches "antispam", "multispam". - `sp*m`: Matches "spim", "spam", "spum".  | validation: maxItems 1000, maxLength 50
              - name: expressions | type: array<string> | description: [Regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions).  | validation: maxItems 10, maxLength 300
           - name: contentFeaturesOptions | type: ContentFeatures | description: Options for the content features trigger.  
              - name: videos | type: boolean | description: Whether the content contains videos.  
              - name: images | type: boolean | description: Whether the content contains images.  
              - name: links | type: boolean | description: Whether the content contains links.  
              - name: attachments | type: boolean | description: Whether the content contains attachments or files.  
           - name: attributeOptions | type: Attribute | description: Options for the attributes trigger. You can only have 1 attribute per rule.  
              - name: name | type: string | description: Attribute name.  | validation: maxLength 20
              - name: values | type: array<string> | description: Attribute values.  | validation: maxItems 20, maxLength 20
        - name: type | type: Type | description: Trigger type.  
             - enum:
             -     PATTERNS: The trigger is a specific word or phrase. You can specify additional options in the `patternsOptions` object.
             -     CONTENT_FEATURES: The rule is triggered when non-textual features, such as videos, images, links, and attachments, exist in the content. You can specify additional options in the `contentFeaturesOptions` object.
             -     ATTRIBUTE: A custom trigger based on an attribute and its value. For example, if you'd like to check all reviews with a low rating, then `name` would be `rating`, and `values` would be `[1, 2]`. You can specify additional options in the `patternsOptions` object.
             -     ALWAYS: There is no specific trigger. The rule is triggered whenever new content is created or existing content is updated, with no other conditions required.
     - name: exemptions | type: Exemptions | description: List of site members or groups to whom the rule doesn't apply.  
        - name: memberGroups | type: array<string> | description: List of member groups.  | validation: maxItems 50, format GUID
        - name: memberIds | type: array<string> | description: List of member GUIDs.  | validation: maxItems 50, format GUID
     - name: action | type: Action | description: What action should be taken after the rule is triggered.  
        - name: type | type: Type | description: Action type.  
             - enum:
             -     UNKNOWN_TYPE: 
             -     REJECT: Reject the content without any further review.
             -     NEEDS_MANUAL_APPROVAL: Send the content for manual review.
     - name: enabled | type: boolean | description: Whether the rule is enabled.  
     - name: extendedFields | type: ExtendedFields | description: Custom field data for the rule object.  **Note:** You must configure extended fields using schema plugin extensions in your app's dashboard before you can access the extended fields with API calls.  
        - 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: 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.  | validation: maxLength 3000
        - name: prev | type: string | description: Cursor pointing to previous page in the list of results.  | validation: maxLength 3000
     - 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
import { moderationRules } from '@wix/moderation-rules';

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

### queryRules (with elevated permissions)
```javascript
import { moderationRules } from '@wix/moderation-rules';
import { auth } from '@wix/essentials';

async function myQueryRulesMethod(query) {
  const elevatedQueryRules = auth.elevate(moderationRules.queryRules);
  const response = await elevatedQueryRules(query);
}
```

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

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


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

---