TransactionSecurityPolicy defines an event-driven security policy for Real-Time Event Monitoring. It connects a monitored event to condition logic and the actions to take when those conditions match, such as blocking an operation, requiring multi-factor authentication (MFA), or notifying an administrator. The policy is configuration, not the event data it evaluates.
Key Elements
| Element | What the Element Controls |
|---|---|
active |
Required. When true, enables the policy to monitor its selected event. Activation alone does not mean every occurrence is blocked. |
action |
Required. Contains enforcement settings and optional notifications for a matching policy. |
type |
Selects the condition mechanism: CustomApexPolicy or CustomConditionBuilderPolicy. The default is CustomApexPolicy. |
apexClass |
Required for Apex-based policies. Names the class implementing TxnSecurity.PolicyCondition or TxnSecurity.EventCondition. |
flowId / flow
|
Identifies the Condition Builder implementation. Salesforce documents flowId as a Flow object ID, required for CustomConditionBuilderPolicy. The exposed dependency representation instead uses flow targeting Flow; these representations are not interchangeable. |
eventName |
Selects the Real-Time Event Monitoring event that the policy monitors. Event coverage has exclusions described below. |
block |
Within action, requests that the operation be blocked when the policy matches. |
twoFactorAuthentication |
Within action, requests MFA for a higher level of access before the operation continues, where supported. Lightning Experience can turn this action into a block. |
notifications |
Within action, contains zero, one, or multiple notification entries. Each entry uses user for the recipient, inApp for in-app delivery, and sendEmail for email delivery. |
blockMessage |
Custom blocking text, up to 1000 characters. Available only for ApiEvent, ListViewEvent, BulkApiResultEventStore, and ReportEvent. Null when the UI's default-message option is selected. |
customEmailContent |
Custom notification email text, up to 1333 characters. It can be null even when Custom Email Content is selected, if no text was entered. |
developerName |
Org-unique policy name that distinguishes policies sharing a label. Naming and field-visibility restrictions apply. |
masterLabel |
Internal, non-translated display label. Multiple policies can share this label. |
Behavior and Constraints
Activation and condition selection
Read active, eventName, the condition implementation, and action together. An active policy monitors its selected event, but its actions depend on the condition logic matching. It does not necessarily block every occurrence of that event.
For CustomApexPolicy, apexClass names the Apex condition implementation. For CustomConditionBuilderPolicy, the condition logic is Flow-based and created with Condition Builder. The selected type determines which implementation is required; the existence of both reference options does not mean every policy needs both.
Changing the referenced Apex class or Flow can change when the policy's actions trigger without changing the policy's action settings.
Enforcement and notifications
block requests blocking. twoFactorAuthentication requests an MFA challenge for a higher level of access before the requested operation continues, where that action is supported.
Lightning Experience changes the MFA outcome: transaction security MFA actions for events such as ListViewEvent and ReportEvent are upgraded to Block rather than presenting an authentication challenge. The documented action restrictions do not form a consistent, exhaustive event/action compatibility matrix.
Notifications are separate from enforcement and activation. An active policy can have no notifications entries. Each entry identifies a recipient through user and can select in-app delivery with inApp, email delivery with sendEmail, or both.
Event selection and coverage
The allowed eventName values are AdminSetupEvent, ApiAnomalyEventStore, ApiEvent, BulkApiResultEventStore, CredentialStuffingEventStore, FileEventStore, GuestUserAnomalyEventStore, ListViewEvent, LoginAnomalyEventStore, LoginAsEvent, LoginEvent, PermissionSetEventStore, ReportAnomalyEventStore, ReportEvent, SessionHijackingEventStore, and UniversalAnomalyEventStore.
Several selections have boundaries that explain apparent failures to trigger:
-
ApiEventcaptures user-initiated, read-onlyquery(),queryMore(), andcount()calls through SOAP API and Bulk API for the Enterprise and Partner WSDLs. It does not capture Tooling API calls or calls originating from a Salesforce mobile app. -
BulkApiResultEventStoretracks downloads of Bulk API request results. It is not another name forApiEvent. -
ListViewEventcovers list-view access through Lightning Experience, Salesforce Classic, and the API. It excludes list views of Setup entities. -
LoginEventtracks user logins.LoginAsEventtracks administrators logging in as other users. -
FileEventStorecovers file downloads, previews, and uploads. -
CredentialStuffingEventStoretracks successful logins during an identified credential-stuffing attack, meaning an automated attack using stolen credentials. It does not represent every attempted login during that attack. -
ReportEventtracks report runs.PermissionSetEventStoretracks changes to permission sets and permission set groups. -
ApiAnomalyEventStoretracks anomalies in how users make API calls.GuestUserAnomalyEventStoretracks data-access anomalies caused by guest user permission misconfiguration. -
SessionHijackingEventStoretracks unauthorized ownership of a user's session through a stolen session identifier. Detection evaluates how significantly the current browser fingerprint differs from the previously known fingerprint.
A policy for one of these events does not establish coverage of activity that the event excludes.
Messages and administrative identity
blockMessage is available only for ApiEvent, ListViewEvent, BulkApiResultEventStore, and ReportEvent. Its maximum length is 1000 characters, and it is null when the UI's default-message option is selected. Custom text can identify the responsible administrator or business unit, but detailed policy logic can help a malicious user understand the control.
customEmailContent has a maximum length of 1333 characters. It can be null when Custom Email Content is selected in the UI but no content was entered. A null value therefore does not establish that email notification is disabled; the notification entry's sendEmail setting controls that selection. Neither custom blocking text nor custom email text is translatable.
developerName must be unique in the org, begin with a letter, and contain only alphanumeric characters and underscores. It cannot contain spaces, end with an underscore, or contain consecutive underscores.
Only users with View DeveloperName or View Setup and Configuration permission can view, group, sort, or filter developerName. This restriction concerns visibility of the field, not which users are subject to the policy. masterLabel is an internal, non-translated display label and need not be unique.
Deployment and Retrieval
Metadata API components use the .transactionSecurityPolicy suffix and reside in the transactionSecurityPolicies directory. The type extends Metadata and inherits fullName.
Use the exact type name TransactionSecurityPolicy in package.xml. A manifest can select a named member, such as MySecurityPolicy, or use * to select all members of this type for deployment or retrieval. For example, the type entry for a wildcard selection is <types><members>*</members><name>TransactionSecurityPolicy</name></types>. See the Metadata API reference.
A policy definition requires active and action, along with the condition implementation required by its type. For Apex-based policies, check the apexClass name and its implemented interface. For Condition Builder policies, account for the distinction between the documented flowId object ID and the exposed flow reference. Do not substitute a Flow developer name for a record ID or assume the two element names are interchangeable.
When diagnosing an "Unknown type" failure, check the spelling and capitalization of TransactionSecurityPolicy in the manifest's types entry. A community report identifies a typo as one possible cause, not an exhaustive explanation of that error.
Relationships
The policy points to the component that implements its condition logic. These are outgoing dependencies from the policy, not requirements for every policy to use both implementations. Notification recipients and monitored event names serve different purposes from these condition-component references.
References
-
ApexClass:apexClass. -
Flow:flowin the exposed dependency representation; Salesforce's field documentation instead specifiesflowIdcontaining the Flow object ID.
Documentation Inconsistencies
-
Condition Builder reference name and value: Salesforce's field documentation specifies
flowId, required forCustomConditionBuilderPolicy, and defines its value as a Flow object ID. The exposed element schema and dependency mapping instead useflowtargetingFlow. These differ in representation; they do not establish that a record ID and a Flow developer name, or the two element names, are interchangeable. -
Action applicability: the descriptions of
blockandtwoFactorAuthenticationstate narrower event restrictions than the real-time example that blocksReportEventand the documented Lightning Experience behavior that upgrades MFA actions to Block. Those field descriptions do not provide a consistent, exhaustive real-time action/event compatibility matrix.
Reported Issues
-
An "Unknown type" error can warrant a manifest-spelling check. In a 2018 discussion about updating transaction security policies, a respondent reported encountering that error when the
package.xmltypesentry contained a typo. This is a reported diagnostic possibility, not proof that every such error has that cause. Manifest typo report. -
Apex queries may provide a way to inspect policy records. A 2021 community inventory listed the
TransactionSecurityPolicyobject among objects available in theSchemanamespace and queryable in Apex. This report concerns object read access, not metadata deployment or REST update support. Apex queryability report.
Common Questions
How do I deploy or retrieve TransactionSecurityPolicy metadata?
Use TransactionSecurityPolicy as the manifest type name, with a named member or *. Metadata API files reside in transactionSecurityPolicies and use the .transactionSecurityPolicy suffix. The definition requires active, action, and the condition implementation required by its type.
Why does an active transaction security policy not trigger?
active=true enables monitoring; it does not make every occurrence match. The selected eventName must cover the activity, and the Apex or Condition Builder logic must match. For example, ApiEvent excludes Tooling API and Salesforce mobile app calls, and ListViewEvent excludes Setup entity list views.
Why does an MFA transaction security policy block users in Lightning Experience?
Transaction security MFA actions for events such as ListViewEvent and ReportEvent are upgraded to Block in Lightning Experience rather than presenting an authentication challenge.
Does null customEmailContent mean email notifications are disabled?
No. customEmailContent can be null when Custom Email Content is selected but no text was entered. Check sendEmail in the relevant notifications entry to determine whether email delivery is selected.
Does a Condition Builder policy use a Flow ID or a Flow developer name?
Salesforce documents flowId as the Flow object ID required for CustomConditionBuilderPolicy. The exposed dependency representation instead uses flow targeting Flow. Do not treat the record ID as a developer name or assume those element names are interchangeable.