Platform Events
What platform events are: defining, publishing and subscribing, retention and replay ID, errors, and when to choose them over Change Data Capture.
How does one system learn that something happened in another, without calling it directly and without asking it every few minutes? In Salesforce, one answer is Platform Events.
What they are
An event-driven architecture decouples whoever produces an event from whoever consumes it.
A platform event is a message with data that a publisher publishes and its subscribers receive in real time. Several subscribers can listen to the same event and each do something different.
Messages travel through the event bus, where Salesforce stores them temporarily. A message cannot be updated or deleted. Nor is it visible in the user interface or queryable with SOQL (Salesforce Object Query Language).
Platform Events is available in Enterprise, Performance, Unlimited and Developer Editions, not in Professional or Group.
Defining an event
A custom event is defined in Setup, on the Platform Events page, like a custom object: a name and some fields. Salesforce appends the __e suffix to its API (application programming interface) name. Defining events requires the Customize Application and API Enabled permissions.
Publish Behavior. It decides when the message is published within a transaction:
- Publish Immediately publishes when the call executes, even if the transaction later fails. It is the default and the recommended option. The subscriber can receive the message before the data is saved.
- Publish After Commit publishes only if the transaction commits. It is for subscribers that need the data already saved.
It does not apply to Pub/Sub API, Salesforce’s interface for publishing events and subscribing to them, based on gRPC, a remote procedure call system.
Volume. A high-volume event is the current type: every new event has been high-volume since API version 45.0. A standard-volume event is the old type. The eventType field in the event’s metadata tells which one it is.
Salesforce retires standard-volume events on 15 December 2026. They are migrated with the migration button on the Platform Events page or with the PlatformEventMigration metadata type. The migration requires stopping publishing first. While it runs, for up to 24 hours, nothing can be published.
Publishing and subscribing
Apex is Salesforce’s object-oriented programming language. A flow is an automated process built in Flow Builder.
Publishers:
- Apex, with the
EventBus.publishmethod. - Flows, with a Create Records element that picks the event instead of an object.
- External systems, with Pub/Sub API or with REST API (Representational State Transfer), SOAP API (Simple Object Access Protocol) or Bulk API 2.0, the API for large data sets. These three also consume daily API requests.
Publishing is asynchronous. A successful response from Apex or the other APIs means the request was queued. Pub/Sub API, by contrast, returns the final result.
Subscribers:
- Apex triggers
after inserton the event. - Platform event–triggered flows (Platform Event Triggered Flow), which read the message in the
$Recordvariable. - Lightning components, the building blocks of the Salesforce interface, with the
empApicomponent. - External clients, with Pub/Sub API or with CometD. CometD implements the Bayeux protocol in Streaming API, the older API that sends events to clients (push). Salesforce recommends Pub/Sub API.
Triggers and flows run in a transaction separate from the publishing one, with a possible delay.
Retention, replay ID and order
The bus keeps high-volume messages 72 hours and standard-volume ones 24. Salesforce does not guarantee keeping them longer.
Each received message carries a replay ID: an opaque identifier of its position in the event stream. An external subscriber stores the last one it processed. When it reconnects, it uses it to receive the missed messages within that period.
The replay ID does not identify a message: it can repeat after an org migration. That is what the EventUuid field is for, a universally unique identifier (UUID).
Messages arrive in replay ID order. Order is only guaranteed within a single publish call.
Allocations and limits
The limits are called allocations. The two main ones:
- Publishing: messages published per hour, by any route.
- Delivery: messages delivered in the last 24 hours to Pub/Sub API and CometD clients, to components with
empApiand to event relays, which forward events to Amazon EventBridge, an Amazon Web Services (AWS) service. Triggers and flows do not count. A message delivered to two clients counts twice.
Default values on 2026-10-09:
| Allocation | Performance and Unlimited | Enterprise | Developer |
|---|---|---|---|
| Event definitions | 100 | 50 | 5 |
| Messages published per hour | 250,000 | 250,000 | 50,000 |
| Messages delivered in 24 hours | 50,000 | 25,000 | 10,000 |
| Concurrent CometD clients | 2,000 | 1,000 | 20 |
| Maximum message size | 1 MB (megabyte) | 1 MB | 1 MB |
The allocations are rolling: they count the last hour and the last 24 hours. Change Data Capture, which publishes record changes, shares the delivery allocation.
If publishing is exceeded, the call fails with LIMIT_EXCEEDED and the messages are not published. If delivery is exceeded, the subscription is disconnected; the subscriber later retrieves the messages with its replay ID.
Usage shows in Setup, in the Event Allocations section of the Platform Events page.
Errors and retries
Duplicates. Publishing follows the at-least-once model. In rare cases, a message is published twice, with the same EventUuid. The guide recommends discarding them in the subscriber, for example by their EventUuid. Also in rare cases, a queued message never reaches the bus and is lost.
Triggers. By default, a trigger runs as Automated Process, a system user, with batches of up to 2,000 messages. PlatformEventSubscriberConfig lets you change the user and the batch size.
On a transient error, the trigger can throw EventBus.RetryableException. Salesforce rolls back the writes and resends the batch after an increasing delay. There are 9 retries, and the guide recommends staying below that. After that, the trigger enters the error state and stops receiving messages.
Flows. A flow receives batches of up to 200 messages. If a message fails, the flow does not start and no flow error email is sent.
Security
Publishing requires the Create permission on the event; subscribing, the Read permission. Field-level security does not apply: the message carries all its fields.
Shield Platform Encryption encrypts data at rest. With Shield, messages can be encrypted in the bus; otherwise they are stored in clear text.
Other Salesforce events
Standard events. Salesforce publishes events with predefined fields, such as BatchApexErrorEvent. Each supports its own subscribers.
Change Data Capture. It publishes change events when a record is created, updated, deleted or undeleted, for example AccountChangeEvent. Its fields are the object’s, not ones the team defines. It shares the 72-hour retention and Pub/Sub API with Platform Events.
Core banking integration explains how to combine the two.
Example: a payment received from the core banking system
A bank wants Salesforce to record each payment that enters its core banking system, the central accounts system. The example is invented.
- Definition. The Pago Recibido event (
Pago_Recibido__e) carries the payment identifier (Id_Pago__c), the account, the amount and the value date. - Permissions. The core’s integration user gets Create on the event.
- Publishing. The core publishes one message per payment with Pub/Sub API and retries the failed ones, based on the final result. It consumes the publishing allocation, not daily API requests.
- Subscription. A platform event–triggered flow starts with each message, in its own transaction.
- Duplicates. A Get Records element looks for a Pago (custom object) with the same
Id_Pago__c. A Decision element, an “if, then”, ends the flow if one exists. - Record. If none exists, a Create Records element creates the Pago with the values from
$Record.
As the subscriber is a flow, the delivery allocation is not consumed. If the core later resends a payment already recorded, step 5 prevents a second record.
Step 5 is not enough if two copies of the same payment arrive in the same batch. Salesforce groups the lookups of a flow’s runs (bulkification), and this page infers that neither copy will see the other. So Id_Pago__c is marked Unique (no repeated values) on the Pago object. The database then rejects the second Pago.
When to use Platform Events
The criterion is two questions. Does the sender need the other system’s response to continue? Is what is communicated a change to a Salesforce record? The table is an inference by this page, not a rule from the guide.
Outbound messages. They send SOAP messages with field values to an external server when a record changes. They are actions of approval processes and of Workflow Rules, the legacy automation of conditions and actions on records, unsupported since 31 December 2025. A message not delivered within 24 hours is dropped, and it can arrive repeated or out of order.
| Situation | Option |
|---|---|
| Salesforce needs an external system’s response to continue | An Apex callout, which sends the request and receives the response |
| An external system must learn about changes to Salesforce records | Change Data Capture |
| A business fact with its own data, between systems or processes that do not know each other | Platform Events |
| A new integration that would once have used outbound messages | Platform Events, which keep the message 72 hours and recover it with the replay ID |
Before production
- Confirm the edition (see “What they are”).
- Choose the publish behavior (see “Defining an event”).
- Migrate events whose
eventTypeisStandardVolumebefore 15 December 2026 (see “Defining an event”). - Give Create to whoever publishes and Read to whoever subscribes (see “Security”).
- Estimate volume against the allocations and watch usage in Event Allocations (see “Allocations and limits”).
- Store the last replay ID in each external subscriber (see “Retention, replay ID and order”).
- Discard duplicates in the subscriber, including within a batch (see “Errors and retries” and the example).
- Limit each trigger’s retries to fewer than 9 (see “Errors and retries”).
Official sources
- Platform Events Developer Guide — Salesforce Developers (opens in a new tab)
- Delivering Custom Notifications with Platform Events — Platform Events Developer Guide (opens in a new tab)
- Enterprise Messaging Platform Events — Platform Events Developer Guide (opens in a new tab)
- Defining Your Custom Platform Event — Platform Events Developer Guide (opens in a new tab)
- Platform Event Fields — Platform Events Developer Guide (opens in a new tab)
- Considerations for Defining and Publishing Platform Events — Platform Events Developer Guide (opens in a new tab)
- Decoupled Publishing and Subscription — Platform Events Developer Guide (opens in a new tab)
- Publishing Platform Events — Platform Events Developer Guide (opens in a new tab)
- Publish Event Messages with Apex — Platform Events Developer Guide (opens in a new tab)
- Publish Event Messages with Flows — Platform Events Developer Guide (opens in a new tab)
- Publish Event Messages with Salesforce APIs — Platform Events Developer Guide (opens in a new tab)
- Publish Event Messages with Pub/Sub API — Platform Events Developer Guide (opens in a new tab)
- Subscribing to Platform Events — Platform Events Developer Guide (opens in a new tab)
- Subscribe to Platform Event Notifications with Apex Triggers — Platform Events Developer Guide (opens in a new tab)
- Subscribe to Platform Event Messages with Flows — Platform Events Developer Guide (opens in a new tab)
- Subscribe to Platform Event Notifications in a Lightning Component — Platform Events Developer Guide (opens in a new tab)
- Subscribe to Platform Event Notifications with CometD — Platform Events Developer Guide (opens in a new tab)
- Subscribe to Platform Event Notifications with Pub/Sub API — Platform Events Developer Guide (opens in a new tab)
- Configure the User and Batch Size for Your Platform Event Trigger with PlatformEventSubscriberConfig — Platform Events Developer Guide (opens in a new tab)
- Retry Event Triggers with EventBus.RetryableException — Platform Events Developer Guide (opens in a new tab)
- Comparing setResumeCheckpoint() and EventBus.RetryableException — Platform Events Developer Guide (opens in a new tab)
- Email Notifications for Triggers in Error State — Platform Events Developer Guide (opens in a new tab)
- Common Platform Event Allocations — Platform Events Developer Guide (opens in a new tab)
- Default Platform Event Allocations for Event Publishing and Delivery — Platform Events Developer Guide (opens in a new tab)
- Increase Your Event Delivery and Publishing Allocations with a Platform Event Add-On License — Platform Events Developer Guide (opens in a new tab)
- Monitor Event Usage Against Your Allocations — Platform Events Developer Guide (opens in a new tab)
- Encrypting Platform Event Messages at Rest in the Event Bus — Platform Events Developer Guide (opens in a new tab)
- What’s the Difference Between the Salesforce Events? — Platform Events Developer Guide (opens in a new tab)
- Change Data Capture Events — Platform Events Developer Guide (opens in a new tab)
- Change Data Capture — Change Data Capture Developer Guide (opens in a new tab)
- Event Message Durability — Pub/Sub API Developer Guide (opens in a new tab)
- Get Started — Pub/Sub API Developer Guide (opens in a new tab)
- Getting Started with Streaming API — Streaming API Developer Guide (opens in a new tab)
- Outbound Messaging — SOAP API Developer Guide (opens in a new tab)
- Considerations for Outbound Messages — Salesforce Help (opens in a new tab)
- Workflow Rules — Salesforce Help (opens in a new tab)
- Process Builder — Salesforce Help (opens in a new tab)
- Invoking Callouts Using Apex — Apex Developer Guide (opens in a new tab)
- What is Apex? — Apex Developer Guide (opens in a new tab)
- Define and Manage Platform Events — Salesforce Help (opens in a new tab)
- Flow Terminology — Salesforce Help (opens in a new tab)
- Flow Types — Salesforce Help (opens in a new tab)
- Flow Elements — Salesforce Help (opens in a new tab)
- Strengthen Your Data's Security with Shield Platform Encryption — Salesforce Help (opens in a new tab)
- Event Relay — Salesforce Help (opens in a new tab)
- Standard-Volume Platform Events Retirement — Salesforce Help (opens in a new tab)
- CustomObject — Metadata API Developer Guide (opens in a new tab)
- Introduction to Bulk API 2.0 and Bulk API — Bulk API 2.0 and Bulk API Developer Guide (opens in a new tab)
- Flow Bulkification in Transactions — Salesforce Help (opens in a new tab)
- Custom Field Attributes — Salesforce Help (opens in a new tab)