> 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`). > - 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. - 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 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 | description: Sort object in the following format: `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]` - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: QueryRulesResponse - name: rules | type: array | description: List of rules. - name: id | type: string | description: Rule 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. - name: createdDate | type: string | description: Date and time when the rule was created. - name: updatedDate | type: string | description: Date and time when the rule was updated. - 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). - name: name | type: string | description: Rule name. - 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. - 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 | 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". - name: expressions | type: array | description: [Regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions). - 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. - name: values | type: array | description: Attribute values. - 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 | description: List of member groups. - name: memberIds | type: array | description: List of member GUIDs. - 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). - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata. - name: count | type: integer | description: Number of items returned in the response. - 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 by cursor ```curl curl -X POST https://www.wixapis.com/moderation/v1/rules/query \ -H 'Content-Type: application/json;charset=UTF-8' \ -H 'Authorization: ' \ -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: ' \ -d '{ "query": { "sort": [], "filter": { "namespace": "reviews/stores" }, "cursorPaging": { "limit": 1 } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.feedbackModeration.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. - 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 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 | description: Sort object in the following format: `[{"fieldName":"sortField1","order":"ASC"},{"fieldName":"sortField2","order":"DESC"}]` - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: PROMISE - name: rules | type: array | description: List of rules. - name: _id | type: string | description: Rule 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. - name: _createdDate | type: Date | description: Date and time when the rule was created. - name: _updatedDate | type: Date | description: Date and time when the rule was updated. - 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). - name: name | type: string | description: Rule name. - 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. - 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 | 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". - name: expressions | type: array | description: [Regular expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions). - 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. - name: values | type: array | description: Attribute values. - 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 | description: List of member groups. - name: memberIds | type: array | description: List of member GUIDs. - 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). - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata. - name: count | type: integer | description: Number of items returned in the response. - 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 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-hosted) Self-hosted 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); }; ``` ---