Platform Events are Salesforce’s built-in publish/subscribe messaging system. You define an event type as a custom object (with __e suffix), publish event records from Apex/Flow/REST, and any subscriber — Apex trigger, Flow, Lightning component, external system — receives the message within seconds.
Think Kafka, but inside Salesforce, with no infrastructure to manage.
What an event looks like
In Setup, create a Platform Event called Order_Placed__e with fields:
Order_Id__c(Text)Customer_Email__c(Email)Total__c(Currency)
Now you can publish from anywhere:
Order_Placed__e evt = new Order_Placed__e(
Order_Id__c = order.Id,
Customer_Email__c = order.Customer__r.Email,
Total__c = order.Total__c
);
Database.SaveResult sr = EventBus.publish(evt);
And subscribe with a trigger:
trigger OrderPlacedTrigger on Order_Placed__e (after insert) {
for (Order_Placed__e evt : Trigger.new) {
// Send confirmation email, sync to ERP, etc.
}
}
Why use them instead of regular triggers or callouts
| Pattern | Direct callout from trigger | Platform Event |
|---|---|---|
| Decouples publisher from subscriber | No | Yes |
| Survives subscriber downtime | No | Yes (24-hour retention) |
| Multiple subscribers | Hard | Trivial |
| External systems can subscribe | Have to push to them | They listen via CometD/gRPC |
| Stays in transaction | Yes (blocking) | No (publishes after commit) |
Two delivery models
- Publish Immediately — event is sent right when
EventBus.publish()runs, before the transaction commits. Use for diagnostics and high-volume publishing. If the transaction rolls back, the event still went out. - Publish After Commit — event is sent only if the transaction succeeds. Set
EventBus.PublishBehavior.PublishAfterCommiton the event definition. This is what you want for business logic — no orphan events from rolled-back transactions.
External systems subscribing
This is the killer feature for integration. Your Node.js / Python / Java service connects to Salesforce’s Pub/Sub API (gRPC, the modern replacement for the older CometD streaming API), subscribes to /event/Order_Placed__e, and receives every order placed in real-time. No polling, no webhooks to maintain on the Salesforce side.
Limits to remember
- Publish: 250,000 events per 24 hours (or per the org’s event allocation)
- Event size: 1 MB
- Standard Volume vs High-Volume: Use High-Volume for anything serious — 24-hour retention, higher delivery limits
- Replay: subscribers can request events by Replay ID up to 72 hours back (High-Volume) or 24 hours (Standard)
Common interview follow-ups
- Platform Events vs Change Data Capture? — CDC is automatic (any record change), schema-defined. Platform Events are custom, with your own shape and timing.
- What’s the order of execution? — Publisher transaction commits, then the event fires. Subscribers run in a separate transaction with their own governor limits.
- Can a Platform Event trigger fail? — Yes. Use
EventBus.RetryableExceptionto ask the platform to redeliver, with a max of 9 retries.
Verified against: Platform Events Developer Guide. Last reviewed 2026-05-17 for Spring ‘26 release.