---
schema_version: "1"
id: cc438490008ad211f85ef6373f21a72f4ba5579c24d68d9821fc279d1176ef7b
title: ModerationRule
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_moderationrule.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_moderationrule.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: cad615d35507eb8a04423da65002645c91ac502480f56181189bade029b3132c
description: Represents a rule used in your Experience Cloud site to moderate member-generated content. Each rule specifies the member-generated content the rule applies to, the criteria to enforce the rule on, and the moderation action to take. Moderation rules help protect your site from spammers, bots, and offensive or inappropriate content. This type extends the Metadata metadata type and inherits its fullName field.
---
# ModerationRule

Represents a rule used in your Experience Cloud site to moderate member-generated content. Each rule specifies the member-generated content the rule applies to, the criteria to enforce the rule on, and the moderation action to take. Moderation rules help protect your site from spammers, bots, and offensive or inappropriate content. This type extends the Metadata metadata type and inherits its fullName field.

![Important](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/images/icon_note_important.png)

#### Important

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

Moderation rules created with the Metadata API are more powerful than moderation rules set up in the Experience Management UI. For example, in the UI you could create a rule that moderates posts and comments. In the Metadata API you could create a rule that moderates only the Link Name of a Link feed type. Use the Metadata API to express complex moderation rules.

![Important](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/images/icon_note_important.png)

#### Important

Don’t update moderation rules you create using the Metadata API in the Experience Management UI. If you do, you overwrite relevant Metadata API fields or the fields are ignored.

Keep the following things in mind when creating moderation rules:

- Your org can have up to 30 rules. This limit is per org, not per site. This limit includes both content rules and rate rules.
- Each rule can have up to three keyword criteria.
- Rules that block content run first, followed by rules to review and approve content, then rules that replace content, and last by rules that flag content. If two or more rules perform the same action, the oldest rule runs first, based on the date the rule was created. Rules to replace content don’t run when the content also applies to a review rule—we want community managers to review the original content.

## File Suffix and Directory Location

ModerationRule components have the suffix .rule and are stored in the moderation directory of the corresponding package directory. The file name format follows site\_name.moderation\_rule\_developer\_name.rule.

## Version

ModerationRule components are available in API version 36.0 and later.

## Special Access Rules

To view, create, edit, and delete moderation rules, you need the Manage Experiences or Create and Set Up Experiences permission. As of Spring ’20 and later, only users with permission to edit moderation rules can access this object.

## Fields

<table class="featureTable sort_table" summary="">



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d679372e129">Field Name</th>

              <th class="featureTableHeader  " id="d679372e132">Field Type</th>

              <th class="featureTableHeader  " id="d679372e135">Description</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d679372e129" data-title="Field Name"><span class="keyword parmname">action</span></td>

              <td class="entry" headers="d679372e132" data-title="Field Type">ModerationRuleAction (enumeration of type string)</td>

              <td class="entry" headers="d679372e135" data-title="Description">
                <span class="ph" id="action_desc"><a name="action_desc"><!-- --></a>Required. Indicates the moderation action that you want to
                  take. The valid values are:</span><a name="moderationruleaction_values"><!-- --></a>
                <ul class="ul bulletList" id="moderationruleaction_values">
                  <li class="li"><samp class="codeph nolang">Block</samp></li>

                  <li class="li"><samp class="codeph nolang">Review</samp></li>

                  <li class="li"><samp class="codeph nolang">Replace</samp></li>

                  <li class="li"><samp class="codeph nolang">Flag</samp></li>

                  <li class="li">
                    <samp class="codeph nolang">FreezeAndNotify</samp> (Reserved for future
                    use.)
                  </li>


                </ul>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d679372e129" data-title="Field Name"><span class="keyword parmname">actionLimit</span></td>

              <td class="entry" headers="d679372e132" data-title="Field Type">int</td>

              <td class="entry" headers="d679372e135" data-title="Description">
                <span class="ph" id="actionLimit_desc"><a name="actionLimit_desc"><!-- --></a>Indicates the moderation action limit.</span> Available
                in API 39.0 and later.
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d679372e129" data-title="Field Name"><span class="keyword parmname">active</span></td>

              <td class="entry" headers="d679372e132" data-title="Field Type">boolean</td>

              <td class="entry" headers="d679372e135" data-title="Description"><span class="ph" id="active_desc"><a name="active_desc"><!-- --></a>Required. Indicates whether the moderation rule is active
                  (<samp class="ph systemoutput">true</samp>) or inactive
                  (<samp class="ph systemoutput">false</samp>).</span></td>

            </tr>

            <tr>
              <td class="entry" headers="d679372e129" data-title="Field Name"><span class="keyword parmname">description</span></td>

              <td class="entry" headers="d679372e132" data-title="Field Type">string</td>

              <td class="entry" headers="d679372e135" data-title="Description"><span class="ph" id="description_desc"><a name="description_desc"><!-- --></a>A description of the moderation rule.</span></td>

            </tr>

            <tr>
              <td class="entry" headers="d679372e129" data-title="Field Name"><span class="keyword parmname">entitiesAndFields</span></td>

              <td class="entry" headers="d679372e132" data-title="Field Type">ModerateEntityField[]</td>

              <td class="entry" headers="d679372e135" data-title="Description"><span class="ph" id="entitiesfields_desc"><a name="entitiesfields_desc"><!-- --></a>Indicates the types of user-generated content this
                  moderation rule applies to.</span></td>

            </tr>

            <tr>
              <td class="entry" headers="d679372e129" data-title="Field Name"><span class="keyword parmname">masterLabel</span></td>

              <td class="entry" headers="d679372e132" data-title="Field Type">string</td>

              <td class="entry" headers="d679372e135" data-title="Description"><span class="ph" id="label_desc"><a name="label_desc"><!-- --></a>Required. Label for the moderation rule.</span></td>

            </tr>

            <tr>
              <td class="entry" headers="d679372e129" data-title="Field Name"><span class="keyword parmname">notifyLimit</span></td>

              <td class="entry" headers="d679372e132" data-title="Field Type">int</td>

              <td class="entry" headers="d679372e135" data-title="Description">
                <span class="ph" id="notifyLimit_desc"><a name="notifyLimit_desc"><!-- --></a>Indicates the notification limit of the moderation
                  rule.</span> Available in API 39.0 and later.
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d679372e129" data-title="Field Name"><span class="keyword parmname">userCriteria</span></td>

              <td class="entry" headers="d679372e132" data-title="Field Type">string</td>

              <td class="entry" headers="d679372e135" data-title="Description">
                <span class="ph" id="userCriteria_desc"><a name="userCriteria_desc"><!-- --></a>Represents the member criteria to use in moderation
                  rules.</span> Available in API 39.0 and later.
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d679372e129" data-title="Field Name"><span class="keyword parmname">userMessage</span></td>

              <td class="entry" headers="d679372e132" data-title="Field Type">string</td>

              <td class="entry" headers="d679372e135" data-title="Description"><span class="ph" id="usermessage_desc"><a name="usermessage_desc"><!-- --></a>The message you want your members to see when their
                  content is blocked. Use the <var class="keyword varname">%BLOCKED_KEYWORD%</var> variable to
                  display up to five blocked words in the user message. If you don’t specify a
                  message, the member sees the standard message: “You can’t use
                  <var class="keyword varname">%BLOCKED_KEYWORD%</var> or other inappropriate words in this site.
                  Review your content and try again.”</span></td>

            </tr>

          </tbody>

        </table>

## ModeratedEntityField

The fields and entities you want to moderate.

<table class="featureTable sort_table" summary="">



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d679372e334">Field Name</th>

              <th class="featureTableHeader  " id="d679372e337">Field Type</th>

              <th class="featureTableHeader  " id="d679372e340">Description</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d679372e334" data-title="Field Name"><span class="keyword parmname">entityName</span></td>

              <td class="entry" headers="d679372e337" data-title="Field Type">string</td>

              <td class="entry" headers="d679372e340" data-title="Description"><span class="ph" id="entityname_desc"><a name="entityname_desc"><!-- --></a>Required. Indicates the types of user-generated
                  content the moderation rule applies to. Post and comments only apply to content
                  created in groups and user profiles. All feed types, such as polls and links, are
                  supported.</span></td>

            </tr>

            <tr>
              <td class="entry" headers="d679372e334" data-title="Field Name"><span class="keyword parmname">fieldName</span></td>

              <td class="entry" headers="d679372e337" data-title="Field Type">string</td>

              <td class="entry" headers="d679372e340" data-title="Description">
                <span class="ph" id="fieldname_desc"><a name="fieldname_desc"><!-- --></a>Indicates the field the moderation rule applies
                  to.</span>
                <div class="box message info">
                  <div class="inner">
                    <div class="bd">
                      <div class="media">
                        <img class="img mtm" src="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/images/icon_note.png" alt="Note">
                        <div class="mediaBd">
                          <h4 class="mbs">Note</h4>
                          <p>To moderate feed posts, use <span class="keyword parmname">entityName</span>
                            <samp class="codeph nolang">FeedItem</samp> with <span class="keyword parmname">fieldName</span>
                            <samp class="codeph nolang">RawBody</samp>. To moderate feed comments, use
                            <span class="keyword parmname">entityName</span>
                            <samp class="codeph nolang">FeedComment</samp> with
                            <span class="keyword parmname">fieldName</span>
                            <samp class="codeph nolang">RawCommentBody</samp>. The <samp class="codeph nolang">RawBody</samp> and <samp class="codeph nolang">RawCommentBody</samp> fields aren’t available in any other
                            API.
                          </p>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d679372e334" data-title="Field Name"><span class="keyword parmname">keywordList</span></td>

              <td class="entry" headers="d679372e337" data-title="Field Type">KeywordList string</td>

              <td class="entry" headers="d679372e340" data-title="Description"><span class="ph" id="keywordlist_desc"><a name="keywordlist_desc"><!-- --></a>Indicates the keyword list that you want to moderate
                  against.</span></td>

            </tr>

          </tbody>

        </table>

## ModerationRuleType

Required. Indicates the type of rule to run on user-generated content.

<table class="featureTable sort_table" summary="">



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d679372e449">Field Name</th>

              <th class="featureTableHeader  " id="d679372e452">Field Type</th>

              <th class="featureTableHeader  " id="d679372e455">Description</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d679372e449" data-title="Field Name"><span class="keyword parmname">type</span></td>

              <td class="entry" headers="d679372e452" data-title="Field Type"> (enumeration of type string)</td>

              <td class="entry" headers="d679372e455" data-title="Description">
                <span class="ph" id="moderationruletype_desc"><a name="moderationruletype_desc"><!-- --></a>Required. Indicates the type of rule to run on
                  user-generated content. </span> Valid values are:<ul class="ul bulletList">
                  <li class="li">Content</li>

                  <li class="li">Rate</li>

                </ul>
                Available in API 39.0 and later.
              </td>

            </tr>

          </tbody>

        </table>

## RateLimitTimePeriod

Required. Indicates the time period that is applied to the rate limit.

<table class="featureTable sort_table" summary="">



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d679372e513">Field Name</th>

              <th class="featureTableHeader  " id="d679372e516">Field Type</th>

              <th class="featureTableHeader  " id="d679372e519">Description</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d679372e513" data-title="Field Name"><span class="keyword parmname">timePeriod</span></td>

              <td class="entry" headers="d679372e516" data-title="Field Type"> (enumeration of type string)</td>

              <td class="entry" headers="d679372e519" data-title="Description">
                <span class="ph" id="ratelimittimeperiod_desc"><a name="ratelimittimeperiod_desc"><!-- --></a>Required. Indicates the time period that is
                  applied to the rate limit.</span> Valid values are:<ul class="ul bulletList">
                  <li class="li">Short</li>

                  <li class="li">Medium</li>

                </ul>
                Available in API 39.0 and later.
              </td>

            </tr>

          </tbody>

        </table>

## Declarative Metadata Sample Definition

The following is an example of a ModerationRule component.

<?xml version="1.0" encoding="UTF-8"?>
<ModerationRule xmlns="http://soap.sforce.com/2006/04/metadata">
   <description\>Blocks Bad Word List in posts, comments, Link URLs, titles, and poll choices.</description\>
   <masterLabel\>Blocking Rule</masterLabel\>
   <action\>Block</action\>
   <active\>true</active\>
   <userMessage\>You can't use %BLOCKED\_KEYWORD% or other inappropriate words in this site. Review your content and try again.</userMessage\>
   <!-- Applies the rule to FeedComment.RawCommentBody (an internal only field), if it contains words from the keyword list specified -->
   <entitiesAndFields\>
     <entityName\>FeedComment</entityName\>
     <fieldName\>RawCommentBody</fieldName\>
     <keywordList\>site1.badword\_list</keywordList\>
   </entitiesAndFields\>
   <entitiesAndFields\>
     <entityName\>FeedItem</entityName\>
     <fieldName\>LinkUrl</fieldName\>
     <keywordList\>site1.badword\_list</keywordList\>
   </entitiesAndFields\>
   <!-- Applies the rule to FeedItem.RawBody (an internal only field), if it contains words from the keyword list specified -->
   <entitiesAndFields\>
     <entityName\>FeedItem</entityName\>
     <fieldName\>RawBody</fieldName\>
     <keywordList\>site1.badword\_list</keywordList\>
   </entitiesAndFields\>
   <entitiesAndFields\>
     <entityName\>FeedItem</entityName\>
     <fieldName\>Title</fieldName\>
     <keywordList\>site1.badword\_list</keywordList\>
   </entitiesAndFields\>
   <entitiesAndFields\>
     <entityName\>FeedPollChoice</entityName\>
     <fieldName\>ChoiceBody</fieldName\>
     <keywordList\>site1.badword\_list</keywordList\>
   </entitiesAndFields\>
</ModerationRule\>

The following is an example package.xml that references the previous definition.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
   <types\>
     <name\>ModerationRule</name\>
     <members\>site1.blocking\_rule</members\>
   </types\>
   <version\>36.0</version\>
</Package\>

## Wildcard Support in the Manifest File

This metadata type supports the wildcard character \* (asterisk) in the package.xml manifest file. For information about using the manifest file, see [Deploying and Retrieving Metadata with the Zip File](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/file_based_zip_file.htm "The deploy() and retrieve() calls are used to deploy and retrieve a .zip file. Within the .zip file is a project manifest (package.xml) that lists what to retrieve or deploy, and one or more XML components that are organized into folders.").