Salesforce Platform Events: Complete Guide

Quick Summary:

Platform Events enable event-driven architecture in Salesforce -- publish a custom event once, and any number of subscribers (internal or external) can react to it independently, in near real time.

What Are Platform Events?

Platform Events are a custom-defined event type that decouples the action that triggers something from everything that needs to react to it. Instead of one process directly calling every downstream system that cares about a change, that process publishes an event once, and any number of subscribers -- internal Apex triggers, external systems via streaming API -- can independently listen and react.

How to Set One Up

  1. Go to Setup → Platform Events and click New Platform Event.

  2. Define the event's custom fields, representing the data that subscribers will need.

  3. Publish events from Apex, Flow, or an external system via API.

  4. Build subscribers -- an Apex trigger for internal reactions, or an external application using CometD/Pub-Sub API for outside systems.

A Real-World Example

An order fulfillment system needs to know the instant an Opportunity closes, without Salesforce needing to know anything about that external system's specific API. A Platform Event, published when the Opportunity's stage changes to Closed Won, lets the fulfillment system (and potentially other systems, like an analytics pipeline) each independently subscribe and react, with no direct coupling between Salesforce and any specific downstream system.

💡 Pro Tip

Design event payloads around what subscribers actually need, not simply mirroring the source record's every field -- a focused, well-designed event schema ages better as your integration landscape grows and changes.

Frequently Asked Questions

What\'s the difference between Platform Events and Change Data Capture?

Platform Events are custom-defined events you design and publish explicitly; Change Data Capture automatically publishes events when standard or custom object records change, without custom event design.

Can Platform Events be published from Flow?

Yes, Flow can publish a Platform Event directly as an action, making it accessible to declarative automation, not just Apex.

How do external systems subscribe to Platform Events?

Via CometD (a Bearer-token-based streaming protocol) or the Pub/Sub API, allowing external applications to receive events in near real time.

Is there a limit to how many Platform Events can be published per day?

Yes, daily publishing limits vary by Salesforce edition and license -- high-volume event architectures should review these limits during design.

What\'s the retention period for Platform Events?

Standard-volume Platform Events are retained for 24 hours; High-Volume Platform Events (built on a different underlying architecture) have different retention characteristics.

Can Platform Events trigger Apex automatically?

Yes, Apex triggers can be defined on Platform Events, letting server-side logic respond automatically whenever a matching event is published.

Do Platform Events guarantee delivery order?

Standard-volume Platform Events generally preserve publish order within a single publisher; High-Volume Platform Events prioritize throughput and may have different ordering guarantees.

Can Platform Events be used for real-time dashboards?

Yes, combined with Lightning Web Components subscribing to the event, you can build UI that updates in real time as events are published, without polling.

What\'s a use case for Platform Events versus a simple Flow?

Platform Events are ideal for decoupled, one-to-many communication -- one publisher, potentially many subscribers reacting independently -- whereas a Flow directly performs one specific set of actions.

Can I test Platform Event publishing without a real external subscriber?

Yes, the Event Monitor in Setup, or a simple Apex trigger logging received events, lets you validate publishing behavior during development.