With the Moderation Rules API you can maintain a safe and compliant online environment by automating content moderation through customizable rules. Also, you can integrate this API to moderate content within your own products, such as a comments app or review collection system.
The Moderation Rules API allows you to:
The following example describes the Moderation Rules API flow for a comment submitted in the Wix Blog app:
PENDING
status.It’s important to note the following points before starting to code:
comments/{BLOG_APP_ID}
or comments/{FORUM_APP_ID}
can be defined to separate the rules.This article presents possible use cases and corresponding sample flows that your app can support. It provides a useful starting point as you plan your app's implementation.
To prevent the publication of spam content on your blog, which often includes links to advertised products or services, phishing sites, or fraudulent schemes, you can implement a moderation rule that applies only to site visitors, excluding members. Once this rule is defined, any comment containing links will be rejected.
To check comments for rule violations:
Create a rule to define conditions on which the content will be rejected. For example:
{
"rule": {
"namespace": "comments/14bcded7-0066-7c35-14d7-466cb3f09103",
"name": "Restrict links in comments",
"audience": {
"type": "VISITORS"
},
"trigger": {
"contentFeatures": {
"videos": false,
"images": false,
"links": true
}
},
"action": {
"type": "REJECT"
}
}
}
After a site visitor submits the comment, call Check Content to verify that the comment does not break any rules.
If you have several eComm sites that use your app, you might need to sync moderation rules for product reviews across those sites. For example, you have a new rule, that from now on, all 1-star ratings must go through a manual review. This change also needs to be reflected on other sites.
To sync the rule across all sites:
Call Get Rule on the site where you created a new rule.
Extract the whole rule
object. Remove unnecessary fields, like createdDate
.
Call Create Rule for your other sites and pass the new rule to each.
The following table shows field support for filters and sorting for the rule object:
Field | Supported Filters | Sortable |
---|---|---|
id | $eq , $ne , $in | |
createdDate | $eq , $ne , $gt , $lt , $gte , $lte | Sortable |
updatedDate | $eq , $ne , $gt , $lt , $gte , $lte | Sortable |
namespace | $eq , $ne , $in | |
enabled | $eq , $ne |
Rule ID.
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.
Date and time when the rule was created.
Date and time when the rule was updated.
The app and entity which the rule belongs to. For example, comments/{BLOG_APP_ID}
.
Rule name.
Audience to which the rule applies.
A condition that triggers the rule.
Note: If you need to have several triggers for the same namespace, create separate rules.
List of site members or groups to whom the rule doesn't apply.
What action should be taken after the rule is triggered.
Whether the rule is enabled.
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.
{
"rule": {
"id": "e3acb53a-cfed-41bc-9de5-e4060426c13a",
"revision": "1",
"createdDate": "2023-10-06T13:57:20.564Z",
"updatedDate": "2023-10-06T13:57:20.564Z",
"namespace": "comments/14bcded7-0066-7c35-14d7-466cb3f09103",
"name": "Forbid to comment with link",
"audience": {
"type": "MEMBERS"
},
"trigger": {
"contentFeatures": {
"videos": false,
"images": false,
"links": true
}
},
"exemptions": {
"memberGroups": ["1149dbee-acc1-49ac-bedf-43176155e84a"],
"memberIds": ["05565bc9-3d16-4fc8-ab8e-20b13a0730d8"]
},
"action": {
"type": "REJECT"
},
"enabled": true
}
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Creates a rule. You can create up to 20 rules per namespace.
You can only call this method when authenticated as a Wix app or Wix user identity.
Rule info.
Created rule.
curl -X POST https://www.wixapis.com/moderation/v1/rules \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Authorization: <AUTH>' \
-d '{
"rule": {
"namespace": "reviews/f0f2e34e-a407-41bd-b8b0-d11a90b226de",
"name": "Check for Store Review Rating",
"audience": {
"type": "MEMBERS_AND_VISITORS"
},
"trigger": {
"attribute": {
"values": ["1", "2"],
"name": "rating"
}
},
"action": {
"type": "NEEDS_MANUAL_APPROVAL"
},
"enabled": true
}
}'
{
"rule": {
"id": "500ea62c-5f4c-4a51-b813-0bd7f239c6dd",
"revision": "1",
"createdDate": "2023-10-10T06:52:04.718Z",
"updatedDate": "2023-10-10T06:52:04.718Z",
"namespace": "reviews/f0f2e34e-a407-41bd-b8b0-d11a90b226de",
"name": "Check for Rating",
"audience": {
"type": "MEMBERS_AND_VISITORS"
},
"trigger": {
"attribute": {
"name": "rating",
"values": ["1", "2"]
}
},
"exemptions": {
"memberGroups": [],
"memberIds": []
},
"action": {
"type": "NEEDS_MANUAL_APPROVAL"
},
"enabled": true
}
}
There is 1 error with this status code:
See the entire list and learn more about Wix errors.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a rule by ID.
You can only call this method when authenticated as a Wix app or Wix user identity.
Rule ID.
Requested rule.
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>'
{
"rule": {
"id": "500ea62c-5f4c-4a51-b813-0bd7f239c6dd",
"revision": "1",
"createdDate": "2023-10-10T06:52:04.718Z",
"updatedDate": "2023-10-10T06:52:04.718Z",
"namespace": "reviews/f0f2e34e-a407-41bd-b8b0-d11a90b226de",
"name": "Check for Rating",
"audience": {
"type": "MEMBERS_AND_VISITORS"
},
"trigger": {
"attribute": {
"name": "rating",
"values": ["1", "2"]
}
},
"exemptions": {
"memberGroups": [],
"memberIds": []
},
"action": {
"type": "NEEDS_MANUAL_APPROVAL"
},
"enabled": true
}
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Permanently deletes a rule.
You can only call this method when authenticated as a Wix app or Wix user identity.
ID of the rule to delete.
curl -X DELETE https://www.wixapis.com/moderation/v1/rules/500ea62c-5f4c-4a51-b813-0bd7f239c6dd \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Authorization: <AUTH>'
{}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Updates a rule.
Each time the rule is updated, revision increments by 1. The existing revision must be included when updating the rule. This ensures you're working with the latest rule and prevents unintended overwrites.
You can only call this method when authenticated as a Wix app or Wix user identity.
Rule ID.
Rule to update.
Updated rule.
curl -X POST https://www.wixapis.com/moderation/v1/rules \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Authorization: <AUTH>' \
-d '{
"rule": {
"id": "500ea62c-5f4c-4a51-b813-0bd7f239c6dd",
"revision": "1"
"namespace": "reviews/stores",
"audience": {
"type": "VISITORS"
}
},
"fieldMask": {
"paths": ["audience.type"]
}
}'
{
"rule": {
"id": "500ea62c-5f4c-4a51-b813-0bd7f239c6dd",
"revision": "2",
"created_date": "2023-10-10T06:52:04.718Z",
"updated_date": "2023-10-10T06:58:01.595Z",
"namespace": "reviews/stores",
"name": "Check for Rating",
"audience": {
"type": "VISITOR"
},
"trigger": {
"attribute": {
"name": "rating",
"values": ["1", "2"]
}
},
"exemptions": {
"member_groups": [],
"member_ids": []
},
"action": {
"type": "NEEDS_MANUAL_APPROVAL"
},
"enabled": true
}
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a list of rules, given the provided paging, filtering, and sorting.
createdDate
is sorted in ASC
orderpaging.limit
is 100
paging.offset
is 0
Up to 1,000 rules can be returned per request.
For field support for filters and sorting, see Rules: Supported Filters and Sorting. To learn about working with Query endpoints, see API Query Language.
You can only call this method when authenticated as a Wix app or Wix user identity.
Query options. See API Query Language for more details.
List of rules.
Paging metadata.
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/f0f2e34e-a407-41bd-b8b0-d11a90b226de"
},
"cursorPaging": {
"limit": 1
}
}
}'
{
"rules": [
{
"id": "500ea62c-5f4c-4a51-b813-0bd7f239c6dd",
"revision": "1",
"createdDate": "2023-10-10T06:52:04.718Z",
"updatedDate": "2023-10-10T06:52:04.718Z",
"namespace": "reviews/f0f2e34e-a407-41bd-b8b0-d11a90b226de",
"name": "Check for Rating",
"audience": {
"type": "MEMBERS_AND_VISITORS"
},
"trigger": {
"attribute": {
"name": "rating",
"values": ["1", "2"]
}
},
"exemptions": {
"memberGroups": [],
"memberIds": []
},
"action": {
"type": "NEEDS_MANUAL_APPROVAL"
},
"enabled": true
}
],
"pagingMetadata": {
"count": 1,
"cursors": {
"next": "79902130cbb60b4db8ae6b7f0020c04e411ee19b.IiQ1MDBlYTYyYy01ZjRjLTRhNTEtYjgxMy0wYmQ3ZjIzOWM2ZGQ",
"prev": null
},
"hasNext": true
}
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Checks the submitted content for any conditions that might trigger a rule, and then returns actions to take if the rule is triggered.
You can only call this method when authenticated as a Wix app or Wix user identity.
Namespace value.
Content to check.
Rule violation details.
curl -X POST https://www.wixapis.com/moderation/v1/rules/check \
-H 'Content-Type: application/json;charset=UTF-8' \
-H 'Authorization: <AUTH>' \
-d ''{
"namespace": "reviews/f0f2e34e-a407-41bd-b8b0-d11a90b226de",
"content": {
"plainText": "Great product!",
"attributes": [
{ "name": "rating", "value": "2" }
]
}
}'
{
"violations": [
{
"ruleId": "5aad8c1c-916a-44d7-b655-0c3328dfb9b3",
"action": "NEEDS_MANUAL_APPROVAL"
}
]
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a rule is created.
Unique event ID. Allows clients to ignore duplicate webhooks.
Fully qualified domain name of the entity associated with the event. Expected wix.moderation.v1.rule
.
Event name. Expected created
.
ID of the entity associated with the event.
Event timestamp.
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).
If present, indicates the action that triggered the event.
Event information.
The data payload will include the following as an encoded JWT:
{
"data": {
"eventType": "wix.moderation.v1.rule_created",
"instanceId": "<app-instance-id>",
"data": "<stringified-JSON>",
// The identity field is sent as a stringified JSON
"identity": {
"identityType": "<identityType>", // ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP
"anonymousVisitorId": "<anonymousVisitorId>", // in case of ANONYMOUS_VISITOR
"memberId": "<memberId>", // in case of MEMBER
"wixUserId": "<wixUserId>", // in case of WIX_USER
"appId": "<appId>" // in case of APP
}
}
}
{
"id": "c5f445cd-59c8-41d5-9c0c-f7b1a804b2c5",
"entityFqdn": "wix.moderation.v1.rule",
"slug": "created",
"entityId": "e3acb53a-cfed-41bc-9de5-e4060426c13a",
"createdEvent": {
"entity": {
"id": "e3acb53a-cfed-41bc-9de5-e4060426c13a",
"revision": "1",
"createdDate": "2023-10-06T13:57:20.674Z",
"updatedDate": "2023-10-06T13:57:20.674Z",
"namespace": "comments/14bcded7-0066-7c35-14d7-466cb3f09103",
"name": "Forbid to comment with link",
"audience": {
"type": "MEMBERS"
},
"trigger": {
"contentFeatures": {
"videos": false,
"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:57:20.674553Z",
"triggeredByAnonymizeRequest": false,
"entityEventSequence": "1"
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a rule is updated.
Unique event ID. Allows clients to ignore duplicate webhooks.
Fully qualified domain name of the entity associated with the event. Expected wix.moderation.v1.rule
.
Event name. Expected updated
.
ID of the entity associated with the event.
Event timestamp.
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).
If present, indicates the action that triggered the event.
Event information.
The data payload will include the following as an encoded JWT:
{
"data": {
"eventType": "wix.moderation.v1.rule_updated",
"instanceId": "<app-instance-id>",
"data": "<stringified-JSON>",
// The identity field is sent as a stringified JSON
"identity": {
"identityType": "<identityType>", // ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP
"anonymousVisitorId": "<anonymousVisitorId>", // in case of ANONYMOUS_VISITOR
"memberId": "<memberId>", // in case of MEMBER
"wixUserId": "<wixUserId>", // in case of WIX_USER
"appId": "<appId>" // in case of APP
}
}
}
{
"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"
}
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Triggered when a rule is deleted.
Unique event ID. Allows clients to ignore duplicate webhooks.
Fully qualified domain name of the entity associated with the event. Expected wix.moderation.v1.rule
.
Event name. Expected deleted
.
ID of the entity associated with the event.
Event timestamp.
Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).
If present, indicates the action that triggered the event.
Event information.
The data payload will include the following as an encoded JWT:
{
"data": {
"eventType": "wix.moderation.v1.rule_deleted",
"instanceId": "<app-instance-id>",
"data": "<stringified-JSON>",
// The identity field is sent as a stringified JSON
"identity": {
"identityType": "<identityType>", // ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP
"anonymousVisitorId": "<anonymousVisitorId>", // in case of ANONYMOUS_VISITOR
"memberId": "<memberId>", // in case of MEMBER
"wixUserId": "<wixUserId>", // in case of WIX_USER
"appId": "<appId>" // in case of APP
}
}
}
{
"id": "84311148-97ce-489f-b568-84432fa8d156",
"entityFqdn": "wix.moderation.v1.rule",
"slug": "deleted",
"entityId": "e3acb53a-cfed-41bc-9de5-e4060426c13a",
"deletedEvent": {
"movedToTrash": true
},
"eventTime": "2023-10-06T14:00:13.693401Z",
"triggeredByAnonymizeRequest": false,
"entityEventSequence": "3"
}