---
schema_version: "1"
id: caec5574d36edb7b863d740a4807cf48d755b84d362d54c90796310f95733005
title: TransactionSecurityPolicy
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_transactionsecurity.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_transactionsecurity.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 65b32267d53d6e9f9bc5fb0d4cf87ec76ed67e9cc0d166d4b3b6f8275a87ff11
description: Represents a transaction security policy definition. Transaction security policies give you a way to look through events in your organization and specify actions to take when certain combinations occur.
---
# TransactionSecurityPolicy

Represents a transaction security policy definition. Transaction security policies give you a way to look through events in your organization and specify actions to take when certain combinations occur.

![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.

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

TransactionSecurityPolicy components have the suffix .transactionSecurityPolicy and are stored in the transactionSecurityPolicies folder.

## Version

TransactionSecurityPolicy components are available in API version 35.0 and later.

## Fields

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



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

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

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

            </tr>

          </thead>

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

              <td class="entry" headers="d903664e107" data-title="Field Type"><a class="xref" href="#TxnSecAction_title">TransactionSecurityAction</a></td>

              <td class="entry" headers="d903664e110" data-title="Description">Required. Describes the action to take when the matching Transaction
                Security policy is triggered.</td>

            </tr>

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

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

              <td class="entry" headers="d903664e110" data-title="Description">Required. If <samp class="codeph nolang">true</samp>, the policy is enabled
                and actively monitors its event.</td>

            </tr>

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

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

              <td class="entry" headers="d903664e110" data-title="Description">Required for Apex-based policies, and optional for all other policies. The name
                of the class that implements the <samp class="codeph nolang">TxnSecurity.PolicyCondition</samp> or <samp class="codeph nolang">TxnSecurity.EventCondition</samp> interface for this policy. Available in API
                version 46.0 and later.</td>

            </tr>

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

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

              <td class="entry" headers="d903664e110" data-title="Description">The custom message sent to a user when a policy blocks their action. Used in
                Real-Time Event Monitoring only. Maximum of 1000 characters. This field is null when
                the default message option is selected in the UI. Available only when
                <span class="keyword parmname">eventName</span> is set to <samp class="codeph nolang">ApiEvent</samp>, <samp class="codeph nolang">ListViewEvent</samp>, <samp class="codeph nolang">BulkApiResultEventStore</samp>, or <samp class="codeph nolang">ReportEvent</samp>. Available in API version 49.0 and later.
                <p class="p">Include org- or policy-specific information in your custom message, such as the
                  name of the responsible administrator or the business unit. Be careful about what
                  you include. Too much information on how the policy was designed. can aid a
                  malicious user. </p>
                <p class="p">Two-factor authentication (2FA) isn’t supported in
                  Lightning Experience, so events like <samp class="codeph nolang">ListView</samp>
                  and <samp class="codeph nolang">ReportEvent</samp> are upgraded to Block in
                  Lightning.</p>
                <p class="p">Custom messages aren’t translatable.</p>
              </td>

            </tr>

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

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

              <td class="entry" headers="d903664e110" data-title="Description">The administrator-created custom email content sent when a policy is triggered.
                Used in Real-Time Event Monitoring only. Maximum of 1333 characters. This field is
                null when the Custom Email Content setting is selected in the UI but no message
                content is entered. Available in API version 54.0 and later.<p class="p">Custom messages
                  aren’t translatable.</p>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d903664e104" data-title="Field Name"><span class="keyword parmname"><span class="ph" id="field_description_name"><a name="field_description_name"><!-- --></a>description</span></span></td>

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

              <td class="entry" headers="d903664e110" data-title="Description"><span class="ph" id="field_description_descr"><a name="field_description_descr"><!-- --></a>A description of the policy.</span></td>

            </tr>

            <tr>
              <td class="entry" headers="d903664e104" data-title="Field Name"><span class="keyword parmname"><span class="ph" id="field_developerName_name"><a name="field_developerName_name"><!-- --></a>developerName</span></span></td>

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

              <td class="entry" headers="d903664e110" data-title="Description">
                <span class="ph" id="field_developerName_descr"><a name="field_developerName_descr"><!-- --></a>This unique name prevents conflicts with
                  other policies that have the same <span class="keyword parmname">masterLabel</span>.</span> This name
                can contain only underscores and alphanumeric characters, and must be unique in your
                org. It must begin with a letter, not include spaces, not end with an underscore,
                and not contain two consecutive underscores.
                <p class="p">Only users with View DeveloperName OR View Setup and Configuration permission
                  can view, group, sort, and filter this field.</p>
              </td>

            </tr>

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

              <td class="entry" headers="d903664e107" data-title="Field Type">TransactionSecurityEventName (<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="d903664e110" data-title="Description">Used in Real-Time Event Monitoring only. Indicates the name of the event the
                policy monitors. This field is available in API 45.0 and later. Valid values are:<ul class="ul bulletList">

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


                  <li class="li">
                    <samp class="codeph nolang">ApiAnomalyEventStore</samp>—Tracks
                    anomalies in how users make API calls. ApiAnomalyEventStore is an object that
                    stores the event data of ApiAnomalyEvent. This object is available in API
                    version 50.0 and later.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">ApiEvent</samp>—Tracks these
                    user-initiated read-only API calls: <samp class="codeph nolang">query()</samp>, <samp class="codeph nolang">queryMore()</samp>, and <samp class="codeph nolang">count()</samp>. Captures API requests through SOAP API
                    and Bulk API for the Enterprise and Partner WSDLs. Tooling API calls and API
                    calls originating from a Salesforce mobile app aren’t captured.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">BulkApiResultEventStore</samp>—Tracks
                    when a user downloads the results of a Bulk API request. BulkApiResultEventStore
                    is a big object that stores the event data of BulkApiResultEvent. This object is
                    available in API version 50.0 and later.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">CredentialStuffingEventStore</samp>—Tracks when a user successfully
                    logs into Salesforce during an identified credential stuffing attack. Credential
                    stuffing refers to large-scale automated login requests using stolen user
                    credentials.This value is available in API version 49.0 and later.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">FileEventStore</samp>
                    —Tracks when a user downloads, previews, or uploads a file.
                    FileEventStore is a big object that stores the event data of FileEvent. This
                    object is available in API version 57.0 and later.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">GuestUserAnomalyEventStore</samp>—Tracks data access anomalies
                    that are caused by guest user permission misconfiguration. This object is
                    available in API version 60.0 and later.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">ListViewEvent</samp>—Tracks when users
                    access data with list views using Lightning Experience, Salesforce Classic, or
                    the API. It doesn’t track list views of Setup entities.
                  </li>


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


                  <li class="li">
                    <samp class="codeph nolang">LoginAsEvent</samp>—Tracks the login
                    activity of admins who log in to Salesforce as other users. This object is
                    available in API version 46.0 and later.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">LoginEvent</samp>—LoginEvent tracks the
                    login activity of users who log in to Salesforce.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">PermissionSetEventStore</samp> —Tracks
                    changes to permission sets and permission set groups.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">ReportAnomalyEventStore</samp>— This
                    value is available in API version 49.0 and later.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">ReportEvent</samp>—Tracks when reports
                    are run in your org.
                  </li>


                  <li class="li">
                    <samp class="codeph nolang">SessionHijackingEventStore</samp>—Tracks
                    when unauthorized users gain ownership of a Salesforce user’s session with a
                    stolen session identifier. To detect such an event, Salesforce evaluates how
                    significantly a user’s current browser fingerprint diverges from the previously
                    known fingerprint using a probabilistically inferred significance of change.
                    Available in API version 49.0 and later.
                  </li>


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


                </ul>
              </td>

            </tr>

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

              <td class="entry" headers="d903664e107" data-title="Field Type">MonitoredEvents (<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="d903664e110" data-title="Description">Used in Legacy Transaction Security only. Required for Apex-based policies, and
                optional for all other policies. Indicates which type of event is being monitored.
                Valid values are:<ul class="ul bulletList">
                  <li class="li">
                    <samp class="codeph nolang">AccessResource</samp>—Notifies you when
                    the selected resource has been accessed.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">AuditTrail</samp>—Reserved for future
                    use.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">DataExport</samp>—Notifies you when the
                    selected object type has been exported using the Data Loader API client.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">Entity</samp>—Notifies you on use of an
                    object type such as an authentication provider or Chatter comment.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">Login</samp>—Notifies you when a user
                    logs in.
                  </li>

                </ul>

                <p class="p">As of Summer '20, Legacy Transaction Security is a retired feature in all
                  Salesforce orgs.</p>
              </td>

            </tr>

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

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

              <td class="entry" headers="d903664e110" data-title="Description">Used in Legacy Transaction Security only. The name or ID of an active user who
                is assigned the Modify All Data and View Setup user permissions.
                <p class="p">As of Summer '20, Legacy Transaction Security is a retired feature in all Salesforce
                  orgs.</p>
              </td>

            </tr>

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

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

              <td class="entry" headers="d903664e110" data-title="Description">Required only for policies of type <samp class="codeph nolang">CustomConditionBuilderPolicy</samp>. The ID of the Flow object that contains
                the logic the Condition Builder transaction security policy. Available in API
                version 46.0 and later.</td>

            </tr>

            <tr>
              <td class="entry" headers="d903664e104" data-title="Field Name"><span class="keyword parmname"><span class="ph" id="field_masterLabel_name"><a name="field_masterLabel_name"><!-- --></a>masterLabel</span></span></td>

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

              <td class="entry" headers="d903664e110" data-title="Description">
                <span class="ph" id="field_masterLabel_descr"><a name="field_masterLabel_descr"><!-- --></a>The label for this object. This display value
                  is the internal label that is’t translated.</span>
                <p class="p">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.</p>
              </td>

            </tr>

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

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

              <td class="entry" headers="d903664e110" data-title="Description">Used in Legacy Transaction Security only. Required for Apex-based policies, and
                optional for all other policies. A resource used to narrow down the conditions under
                which the policy triggers. For example, with a <samp class="codeph nolang">DataExport</samp> event, you can select a resource Lead to specifically monitor
                export activity occurring on your Lead entities. The resources available depend on
                the <span class="keyword parmname"><a class="xref" href="#txnsec_eventtype">Event Type</a></span> field. The following valid
                resources are grouped by event type. <ul class="ul bulletList">
                  <li class="li">AccessResource—ConnectedApplication, Reports</li>

                  <li class="li">DataExport—Account, Case, Contact, Lead, Opportunity</li>

                  <li class="li">Entity—AuthProvider, ChatterMessage, FeedComment, FeedItem, Idea,
                    Question</li>

                  <li class="li">Login—LoginHistory</li>

                </ul>

                <p class="p">As of Summer '20, Legacy Transaction Security is a retired feature in all
                  Salesforce orgs.</p>
              </td>

            </tr>

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

              <td class="entry" headers="d903664e107" data-title="Field Type">TxnSecurityPolicyType (<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="d903664e110" data-title="Description">The type of validation that the policy uses. The valid values are:<ul class="ul bulletList">
                  <li class="li">
                    <samp class="codeph nolang">CustomApexPolicy</samp>— Created with
                    Apex editor.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">CustomConditionBuilderPolicy</samp>—
                    Created with Condition Builder.
                  </li>

                </ul>
                The default value is <samp class="codeph nolang">CustomApexPolicy</samp>.</td>

            </tr>

          </tbody>

        </table>

## TransactionSecurityAction

Describes the action to take when the matching Transaction Security policy is triggered.

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



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

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

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

            </tr>

          </thead>

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

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

              <td class="entry" headers="d903664e575" data-title="Description">If <samp class="codeph nolang">true</samp>, the requested operation is
                blocked. This action only applies to Login and AccessResource events.</td>

            </tr>

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

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

              <td class="entry" headers="d903664e575" data-title="Description">Used in Legacy Transaction Security only. If <samp class="codeph nolang">true</samp>, a current session must be closed before a new session can be
                started. This action only applies to Login events.
                <p class="p">As of Summer '20, Legacy Transaction Security is a retired feature in all
                  Salesforce orgs.</p>
              </td>

            </tr>

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

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

              <td class="entry" headers="d903664e575" data-title="Description">Used in Legacy Transaction Security only. If <samp class="codeph nolang">true</samp>, the user that triggered the policy is frozen. This action only
                applies to Chatter resources for Entity events.
                <p class="p">As of Summer '20, Legacy Transaction Security is a retired feature in all
                  Salesforce orgs.</p>
              </td>

            </tr>

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

              <td class="entry" headers="d903664e572" data-title="Field Type">
                <a class="xref" href="#TxnSecNotification_title">TransactionSecurityNotification</a>[]
              </td>

              <td class="entry" headers="d903664e575" data-title="Description">Specifies how to notify the Salesforce administrator when the action is
                triggered. There can be none, one, or multiple notifications.</td>

            </tr>

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

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

              <td class="entry" headers="d903664e575" data-title="Description">If <samp class="codeph nolang">true</samp>, multi-factor authentication (MFA)
                is required for a higher level of access before the requested operation can
                continue. This action only applies to Login and AccessResource
                events.
                <p class="p">Multi-factor authentication was formerly called two-factor
                  authentication.</p>
              </td>

            </tr>

          </tbody>

        </table>

## TransactionSecurityNotification

Describes who to notify and how to notify them when the matching Transaction Security policy is triggered.

| Field Name | Field Type | Description |
| --- | --- | --- |
| inApp | boolean | True if an in-app notification is selected. |
| sendEmail | boolean | True if an email notification is selected. |
| user | string | The user to receive the notification. |

## Declarative Metadata Sample Definition

The following is an example of a Real-Time Event Monitoring TransactionSecurityPolicy component.

<?xml version="1.0" encoding="UTF-8"?>
<TransactionSecurityPolicy xmlns="http://soap.sforce.com/2006/04/metadata">
    <action\>
        <block\>true</block\>
        <notifications\>
            <inApp\>true</inApp\>
            <sendEmail\>true</sendEmail\>
            <user\>user@your.org</user\>
        </notifications\>
        <twoFactorAuthentication\>false</twoFactorAuthentication\>
    </action\>
    <active\>true</active\>
    <apexClass\>TxnSecMDApiPolicyEventCondition</apexClass\>
    <blockMessage\>You cannot view this report.</blockMessage\>
    <developerName\>TxnSecPolicyMDApi</developerName\>
    <eventName\>ReportEvent</eventName\>
    <masterLabel\>Txn Sec MD Api Policy</masterLabel\>
    <type\>CustomApexPolicy</type\>
</TransactionSecurityPolicy\>

The following is an example package manifest used to deploy or retrieve the transaction security metadata for an organization.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types\>
        <members\>MySecurityPolicy</members\>
        <name\>TransactionSecurityPolicy</name\>
    </types\>
    <version\>35.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.264.0.api_meta.meta/api_meta/file_based_zip_file.htm).