> 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

# GetRule

# Package: feedbackModeration

# Namespace: ModerationRules

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

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

## Introduction

Retrieves a rule by ID.

---

## REST API

### Schema

```
 Method: getRule
 Description: Retrieves a rule by GUID.
 URL: https://www.wixapis.com/moderation/v1/rules/{ruleId}
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  ruleId
 Method parameters: 
   param name: ruleId | type:   none | required: true 
 Return type: GetRuleResponse
  - name: rule | type: Rule | description: Requested rule.  
     - name: id | type: string | description: Rule GUID.  | 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.  | validation: format int64
     - name: createdDate | type: string | description: Date and time when the rule was created.  | validation: format date-time
     - name: updatedDate | type: string | description: Date and time when the rule was updated.  | 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


```

### Examples

### Get a rule
```curl
curl -X GET https://www.wixapis.com/moderation/v1/rules/500ea62c-5f4c-4a51-b813-0bd7f239c6dd  \
    -H 'Content-Type: application/json;charset=UTF-8' \
    -H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.feedbackModeration.ModerationRules.getRule(ruleId)
 Description: Retrieves a rule by GUID.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  ruleId
 Method parameters: 
   param name: ruleId | type: string | description: Rule GUID. | required: true | validation: format GUID
 Return type: PROMISE<Rule>
  - name: _id | type: string | description: Rule GUID.  | 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.  | validation: format int64
  - 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).  | 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


```

### Examples

### getRule
```javascript
import { moderationRules } from '@wix/moderation-rules';

async function getRule(ruleId) {
  const response = await moderationRules.getRule(ruleId);
};
```

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

async function myGetRuleMethod(ruleId) {
  const elevatedGetRule = auth.elevate(moderationRules.getRule);
  const response = await elevatedGetRule(ruleId);
}
```

### getRule (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 getRule(ruleId) {
  const response = await myWixClient.moderationRules.getRule(ruleId);
};
```

---