> 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 # Package: feedbackModeration # Namespace: moderationRules # Webhook link: https://dev.wix.com/docs/api-reference/crm/community/feedback-moderation/moderation-rules/rule-updated.md ## Introduction Triggered when a rule is updated. --- ## REST API ### Schema ``` Webhook: Rule Updated Description: Triggered when a rule is updated. Event body: - name: id | type: string | description: Unique event ID. Allows clients to ignore duplicate events. - name: entityFqdn | type: string | description: Fully qualified domain name of the entity associated with the event. - name: slug | type: string | description: Event name. - name: entityId | type: string | description: ID of the entity associated with the event. - name: eventTime | type: string (date-time) | description: Event timestamp. - name: triggeredByAnonymizeRequest | type: boolean | description: Whether the event was triggered as a result of a privacy regulation application such as GDPR. - name: originatedFrom | type: string | description: If present, indicates the action that triggered the event. - name: updatedEvent | type: object | description: Updated event details. - name: currentEntity | type: Rule | description: The entity after the update. - 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). ``` ### Examples ```curl { "id": "8aa23cf1-92e1-4d0a-a34c-96bc013d229f", "entityFqdn": "wix.moderation.v1.rule", "slug": "updated", "entityId": "e3acb53a-cfed-41bc-9de5-e4060426c13a", "updatedEvent": { "currentEntity": { "id": "e3acb53a-cfed-41bc-9de5-e4060426c13a", "revision": "3", "createdDate": "2023-10-06T13:57:20.564Z", "updatedDate": "2023-10-06T13:59:36.455Z", "namespace": "comments/14bcded7-0066-7c35-14d7-466cb3f09103", "name": "Forbid to comment with link and images", "audience": { "type": "MEMBERS" }, "trigger": { "contentFeatures": { "videos": true, "images": false, "links": true } }, "exemptions": { "memberGroups": ["1149dbee-acc1-49ac-bedf-43176155e84a"], "memberIds": ["05565bc9-3d16-4fc8-ab8e-20b13a0730d8"] }, "action": { "type": "REJECT" }, "enabled": true } }, "eventTime": "2023-10-06T13:59:36.455060Z", "triggeredByAnonymizeRequest": false, "entityEventSequence": "2" } ``` --- ## JavaScript SDK ### Schema ``` Webhook: onRuleUpdated Description: Triggered when a rule is updated. Payload: RuleUpdatedEnvelope - name: entity | type: Rule | description: none - 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: metadata | type: EventMetadata | description: none - name: instanceId | type: string | description: App instance GUID. - name: eventType | type: string | description: Event type. - name: identity | type: IdentificationData | description: The identification type and identity data. - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site. - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site. - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.). - name: appId | type: string | description: GUID of an app. - name: identityType | type: WebhookIdentityType | description: - enum: UNKNOWN, ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP - name: accountInfo | type: AccountInfo | description: Details related to the account - name: accountId | type: string | description: GUID of the Wix account associated with the event. - name: parentAccountId | type: string | description: GUID of the parent Wix account. Only included when accountId belongs to a child account. - name: siteId | type: string | description: GUID of the Wix site associated with the event. Only included when the event is tied to a specific site. - name: _id | type: string | description: Event GUID. With this GUID you can easily spot duplicated events and ignore them. - name: entityFqdn | type: string | description: Fully Qualified Domain Name of an entity. This is a unique identifier assigned to the API main business entities. For example, `wix.stores.catalog.product`, `wix.bookings.session`, `wix.payments.transaction`. - name: slug | type: string | description: Event action name, placed at the top level to make it easier for users to dispatch messages. For example: `created`/`updated`/`deleted`/`started`/`completed`/`email_opened`. - name: entityId | type: string | description: GUID of the entity associated with the event. - name: eventTime | type: Date | description: Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example, `2020-04-26T13:57:50.699Z`. - name: triggeredByAnonymizeRequest | type: boolean | description: Whether the event was triggered as a result of a privacy regulation application (for example, GDPR). - name: originatedFrom | type: string | description: If present, indicates the action that triggered the event. - name: entityEventSequence | type: string | description: A sequence number that indicates the order of updates to an entity. For example, if an entity was updated at 16:00 and then again at 16:01, the second update will always have a higher sequence number. You can use this number to make sure you're handling updates in the right order. Just save the latest sequence number on your end and compare it to the one in each new message. If the new message has an older (lower) number, you can safely ignore it. ``` ### Examples ```javascript import { moderationRules } from '@wix/moderation-rules'; moderationRules.onRuleUpdated((event) => { // handle your event here }); ``` ```javascript import { createClient, AppStrategy } from '@wix/sdk'; import { moderationRules } from '@wix/moderation-rules'; const wixClient = createClient({ auth: AppStrategy({ appId: 'MY-APP-ID', publicKey: 'YOUR_APP_PUBLIC_KEY', }), modules: { moderationRules, }, }); wixClient.moderationRules.onRuleUpdated((event) => { // handle your event here }); ``` ---