---
schema_version: "1"
id: b9dcf2f3757f44d983886665d8952c6d44c0efb3fe2851e290cd15722ab04bc9
title: MatchingRule
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_matchingrule.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_matchingrule.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 672c1f0a767bb0a64d7e859919b5b2dbc515381e131b6e6fd2b53c12a496c3f3
description: Represents a matching rule that is used to identify duplicate records.
---
# MatchingRule

Represents a matching rule that is used to identify duplicate records.

This type extends the [Metadata](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/metadata.htm "The base class for all metadata types. You can’t edit this object. A component is an instance of a metadata type.") metadata type and inherits its fullName field.

## File Suffix and Directory Location

Matching rule components have the .matchingRule suffix and are stored in the matchingRules folder. The name of the component file is the standard or custom object name that is associated with the matching rule.

In API version 39.0 and later, MatchingRule supports the Person Account object.

- The component file name is PersonAccount.matchingRule.
- The component directory is matchingRules.

## Version

MatchingRule is available in API version 33.0 and later.

## Fields

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



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

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

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

            </tr>

          </thead>

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

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

              <td class="entry" headers="d656744e120" data-title="Description">Specifies filter logic conditions.</td>

            </tr>

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

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

              <td class="entry" headers="d656744e120" data-title="Description">The description of the matching rule.</td>

            </tr>

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

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

              <td class="entry" headers="d656744e120" data-title="Description">Required. The name of the matching rule.</td>

            </tr>

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

              <td class="entry" headers="d656744e117" data-title="Field Type"><a class="xref" href="#MatchingRuleItem">MatchingRuleItem</a></td>

              <td class="entry" headers="d656744e120" data-title="Description">The criteria that make up a matching rule.</td>

            </tr>

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

              <td class="entry" headers="d656744e117" data-title="Field Type">MatchingRuleStatus (<a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_objects_intro.htm#enumeration_title">enumeration</a> of type string)</td>

              <td class="entry" headers="d656744e120" data-title="Description">Required. The activation status of the matching rule. Values are:<ul class="ul bulletList">
                  <li class="li"><kbd class="ph userinput">Inactive</kbd></li>

                  <li class="li"><kbd class="ph userinput">Deactivating</kbd></li>

                  <li class="li"><kbd class="ph userinput">DeactivationFailed</kbd></li>

                  <li class="li"><kbd class="ph userinput">Active</kbd></li>

                  <li class="li"><kbd class="ph userinput">Activating</kbd></li>

                  <li class="li"><kbd class="ph userinput">ActivationFailed</kbd></li>

                </ul>
                <div class="box message confirm">
                  <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_important.png" alt="Important">
                        <div class="mediaBd">
                          <h4 class="mbs">Important</h4>
                          <p>The only valid values you can declare when deploying a package
                            are <kbd class="ph userinput">Active </kbd> and <kbd class="ph userinput"> Inactive</kbd>.</p>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </td>

            </tr>

          </tbody>

        </table>

## MatchingRuleItem

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



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

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

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

            </tr>

          </thead>

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

              <td class="entry" headers="d656744e261" data-title="Field Type">BlankValueBehavior (<a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_objects_intro.htm#enumeration_title">enumeration</a> of type string)</td>

              <td class="entry" headers="d656744e264" data-title="Description">Specifies how blank fields affect whether the fields being compared are considered
                matches. Valid values are: <ul class="ul bulletList">
                  <li class="li"><kbd class="ph userinput">MatchBlanks</kbd></li>

                  <li class="li">
                    <kbd class="ph userinput">NullNotAllowed</kbd> (default)
                  </li>

                </ul>

              </td>

            </tr>

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

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

              <td class="entry" headers="d656744e264" data-title="Description">Required. Indicates which field to compare when determining if a record is similar
                enough to an existing record to be considered a match.</td>

            </tr>

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

              <td class="entry" headers="d656744e261" data-title="Field Type">MatchingMethod (<a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_objects_intro.htm#enumeration_title">enumeration</a> of type string)</td>

              <td class="entry" headers="d656744e264" data-title="Description">Required. Defines how the fields are compared. Choose between the exact matching
                method and various fuzzy matching methods. Valid values are:<ul class="ul bulletList">
                  <li class="li"><kbd class="ph userinput">Exact</kbd></li>

                  <li class="li"><kbd class="ph userinput">FirstName</kbd></li>

                  <li class="li"><kbd class="ph userinput">LastName</kbd></li>

                  <li class="li"><kbd class="ph userinput">CompanyName</kbd></li>

                  <li class="li"><kbd class="ph userinput">Phone</kbd></li>

                  <li class="li"><kbd class="ph userinput">City</kbd></li>

                  <li class="li"><kbd class="ph userinput">Street</kbd></li>

                  <li class="li"><kbd class="ph userinput">Zip</kbd></li>

                  <li class="li"><kbd class="ph userinput">Title</kbd></li>

                </ul>
                For details on each matching method, see “Matching Methods Used with Matching Rules” in
                the Salesforce Help.</td>

            </tr>

          </tbody>

        </table>

## Declarative Metadata Sample Definition

The following is a sample XML definition of a matching rule. A matching rule can be associated with either a standard or a custom object.

<?xml version="1.0" encoding="UTF-8"?>
<MatchingRules xmlns="http://soap.sforce.com/2006/04/metadata">
<matchingRules\>
<fullName\>AccountMatchingRule</fullName\>
<label\>Matching rule for accounts</label\>
<description\>this is sample rule description</description\>
<matchingRuleItems\>
<blankValueBehavior\>NullNotAllowed</blankValueBehavior\>
<fieldName\>BillingCity</fieldName\>
<matchingMethod\>City</matchingMethod\>
</matchingRuleItems\>

<matchingRuleItems\>
<blankValueBehavior\>NullNotAllowed</blankValueBehavior\>
<fieldName\>Name</fieldName\>
<matchingMethod\>CompanyName</matchingMethod\>
</matchingRuleItems\>

<ruleStatus\>Inactive</ruleStatus\>
</matchingRules\>
</MatchingRules\>

The following package.xml shows how to reference a matching rule by name. It specifies the type name of MatchingRule.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types\>
<members\>Account.AccountMatchingRule</members\>
<name\>MatchingRule</name\>
</types\>
<version\>68.0</version\>
</Package\>

The following package.xml shows how to reference all matching rules by specifying the plural MatchingRules type name and using a wildcard to include all members.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types\>
<members\>\*</members\>
<name\>MatchingRules</name\>
</types\>
<version\>68.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.").