Salesforce Pub/Sub API: Complete Guide for Enterprise Integrations

Modern enterprise applications exchange millions of events every day. Customer orders, payment confirmations, inventory updates, support requests, and CRM changes often need to be shared across multiple systems almost instantly.

Salesforce is frequently at the center of this ecosystem, integrating with ERP platforms, customer portals, analytics solutions, AI services, and cloud applications. As organizations grow, continuously polling APIs for updates becomes increasingly inefficient, generating unnecessary requests, increasing infrastructure costs, and introducing synchronization delays.

The Salesforce Pub/Sub API addresses these challenges by providing a modern event streaming interface built on gRPC. Instead of repeatedly asking Salesforce whether data has changed, applications maintain a persistent connection and receive events as they happen through the Salesforce Event Bus.

If you’re building modern Salesforce integrations, we also recommend reading our previous guides:

These articles explain the event types that are delivered through the Salesforce Pub/Sub API.

In this guide, you’ll learn what Salesforce Pub/Sub API is, why Salesforce introduced it, how it works, how it compares with Streaming API and REST API, and the best practices for designing scalable enterprise integrations.

Salesforce Pub/Sub API: Best Practices for Enterprise Events

What Is Salesforce Pub/Sub API?

Salesforce Pub/Sub API is Salesforce’s modern event streaming API that enables external applications to publish and subscribe to events through a single, high-performance interface.

Unlike REST APIs, which follow a request-response model, Pub/Sub API maintains a persistent connection between Salesforce and subscriber applications. Events are delivered continuously as they occur instead of requiring repeated API requests.

The API is built on gRPC (Google Remote Procedure Call), an open-source communication framework optimized for low latency, bidirectional streaming, and high-performance distributed systems.

Salesforce Pub/Sub API currently supports three primary event types:

Rather than interacting with each technology separately, Pub/Sub API provides one consistent interface for consuming and publishing supported Salesforce events.

In simple terms:

Applications subscribe to Salesforce events instead of continuously polling Salesforce for updates.

For a technical overview, see the official Salesforce documentation.


Why Salesforce Introduced Pub/Sub API

Before Pub/Sub API was introduced, Salesforce developers primarily relied on the Streaming API, which uses the CometD/Bayeux protocol for event delivery.

Although Streaming API remains fully supported, it was designed before modern cloud-native and microservices architectures became widespread.

As enterprise integrations evolved, Salesforce needed an API capable of handling higher event volumes while providing lower latency and a simpler programming model.

Salesforce introduced Pub/Sub API to provide:

The differences are summarized below.

Legacy Streaming APISalesforce Pub/Sub API
CometD / BayeuxgRPC
HTTP-based communicationPersistent streaming
Higher protocol overheadLower latency
Older architectureModern cloud-native design
Separate publishing modelsUnified publish/subscribe interface

For organizations processing thousands—or even millions—of business events every day, these improvements significantly simplify enterprise integration architecture.


Why Choose Pub/Sub API Over Traditional API Polling?

Many legacy integrations rely on scheduled API polling.

In this model, external systems continuously send requests asking Salesforce whether records or business events have changed. Even when nothing has changed, these requests still consume API resources and increase infrastructure overhead.

Salesforce Pub/Sub API replaces this inefficient approach with continuous event streaming.

Instead of asking for updates, applications receive them automatically whenever an event is published.

Traditional API PollingSalesforce Pub/Sub API
Scheduled API requestsContinuous event streaming
Higher API usageLower API consumption
Delayed synchronizationNear real-time updates
Additional scheduling logicNative Salesforce event delivery
Periodic synchronizationContinuous synchronization

For organizations integrating Salesforce with ERP systems, analytics platforms, customer portals, and AI services, this event-driven approach provides better scalability while reducing unnecessary API traffic.


Salesforce Event Bus Architecture

One of the most common misconceptions is that Pub/Sub API replaces Platform Events or Change Data Capture.

It does not.

Instead, Salesforce Pub/Sub API is the communication layer that allows applications to interact with the Salesforce Event Bus.

The overall architecture looks like this:

Business Applications
        │
────────┼────────
│               │
Platform Events  Change Data Capture
        │
────────┴────────
      Salesforce
      Event Bus
           │
     Salesforce
      Pub/Sub API
           │
──────────────────────────────────────────────
│          │            │             │
ERP     Analytics   Data Lake     AI Services

The Salesforce Event Bus acts as the central messaging layer inside Salesforce.

Whenever an event is published—either manually through Platform Events or automatically through Change Data Capture—it becomes available to subscribers connected through the Pub/Sub API.

This architecture provides several advantages:

Understanding this separation between event generation and event delivery is essential when designing event-driven Salesforce architectures.


How Salesforce Pub/Sub API Works

Salesforce Pub/Sub API follows the classic publish-subscribe communication model.

Events flow continuously from publishers to subscribers through the Salesforce Event Bus.

The architecture can be represented as follows:

Publisher
      │
Platform Event
      │
Salesforce Event Bus
      │
Salesforce Pub/Sub API
      │
────────────────────────────
│          │            │
Subscriber 1  Subscriber 2  Subscriber 3

The workflow consists of five simple steps:

  1. A business process publishes an event or Salesforce automatically generates a Change Event.
  2. The event is stored in the Salesforce Event Bus.
  3. Subscriber applications maintain a persistent connection through the Pub/Sub API.
  4. Salesforce streams events to connected subscribers.
  5. Each subscriber independently processes the event.

Unlike traditional REST APIs, subscribers do not repeatedly request updates.

Instead, Salesforce continuously streams events as they become available.


Why gRPC Makes a Difference

One of the biggest architectural improvements introduced by Pub/Sub API is its use of gRPC.

Unlike REST APIs, which create a new HTTP request for every operation, gRPC maintains a persistent bidirectional connection between Salesforce and subscriber applications.

A simplified architecture looks like this:

Application
      │
gRPC Connection
      │
Salesforce Pub/Sub API
      │
Salesforce Event Bus

This persistent communication model offers several advantages:

These characteristics make Pub/Sub API particularly well suited for organizations processing large volumes of real-time events.


Publish vs Subscribe Operations

The name Pub/Sub stands for Publish and Subscribe—the two fundamental operations supported by the API.

Although closely related, they perform different roles.

Publishing Events

Publishing means sending an event into the Salesforce Event Bus.

Typical Platform Events include:

The publisher simply creates the event.

It does not need to know which applications will eventually consume it.


Subscribing to Events

Subscribing means listening for published events.

For example, an ERP application may subscribe to:

Whenever Salesforce publishes one of these events, the subscriber immediately receives it and executes the required business logic.

PublishSubscribe
Sends eventsReceives events
ProducerConsumer
Creates event streamProcesses event stream
Starts communicationReacts to communication

This loose coupling allows multiple independent systems to process the same event simultaneously without affecting one another.


Supported Event Types

Salesforce Pub/Sub API supports several categories of enterprise events.

Event TypeSupported
Platform Events
Change Data Capture
Real-Time Event Monitoring✅ (where licensed)

Each event type serves a different purpose.

Event TypeGenerated By
Platform EventsDeveloper or Application
Change Data CaptureSalesforce Platform
Event Monitoring EventsSalesforce Platform

Platform Events represent custom business processes.

Change Data Capture automatically publishes record changes.

Real-Time Event Monitoring provides operational and security events generated by Salesforce itself.

Because all of these events are delivered through the same API, organizations can standardize on a single integration model regardless of the underlying event type.


Replay IDs and Reliable Event Delivery

Enterprise integrations must remain reliable even when temporary network interruptions occur.

To support this, Salesforce assigns every published event a unique Replay ID.

Replay IDs allow subscriber applications to reconnect and continue consuming events from the last successfully processed position instead of starting over.

A simplified workflow looks like this:

Subscriber Connected
        │
Receive Events
        │
Connection Lost
        │
Reconnect
        │
Replay ID
        │
Continue Processing

Imagine an ERP application temporarily loses its connection to Salesforce.

Without Replay IDs, events published during that outage could be missed.

By reconnecting with the last successfully processed Replay ID, the subscriber resumes processing without losing important business events.

Replay IDs do not permanently store events. Instead, they provide a mechanism for subscribers to continue processing events within Salesforce’s event retention window after temporary interruptions.


Salesforce Pub/Sub API vs Streaming API vs REST API

Selecting the right integration technology depends on your business requirements.

Although all three APIs exchange information with Salesforce, they are designed for different purposes.

FeaturePub/Sub APIStreaming APIREST API
ProtocolgRPCCometDHTTP
Real-Time CommunicationYesYesNo
Publish EventsYesLimitedNo
Subscribe to EventsYesYesNo
Bidirectional StreamingYesNoNo
Enterprise ScalabilityExcellentGoodModerate
Best Use CaseEvent-driven integrationsLegacy streamingCRUD operations

As a general recommendation:

For additional guidance on designing secure Salesforce integrations, see our Salesforce API Best Practices guide.

Salesforce Pub/Sub API Enterprise Use Cases

The Salesforce Pub/Sub API is designed for organizations that need secure, scalable, and reliable event streaming between Salesforce and external systems.

Rather than continuously polling Salesforce for updates, applications subscribe to events as they occur, allowing data to flow across enterprise systems in near real time.

A typical architecture looks like this:

                 Salesforce
                      │
      Platform Events / CDC Events
                      │
             Salesforce Event Bus
                      │
             Salesforce Pub/Sub API
                      │
────────────────────────────────────────────────────
│              │               │                │
 ERP      Data Warehouse    AI Platform    Customer Portal

Because every subscriber receives only the events it needs, organizations can continue expanding their integration landscape without significantly increasing architectural complexity.

Below are several common enterprise use cases.


ERP Synchronization

Many organizations synchronize Salesforce with ERP systems such as SAP, Oracle, or Microsoft Dynamics.

Whenever customer information, opportunities, products, pricing, or inventory changes inside Salesforce, corresponding events are streamed through the Pub/Sub API.

This enables ERP systems to update their own records immediately without relying on scheduled synchronization jobs.

The result is:


Change Data Capture Consumers

One of the most common use cases for Salesforce Pub/Sub API is consuming Change Data Capture (CDC) events.

Whenever Salesforce records are created, updated, deleted, or restored, Salesforce automatically generates Change Events that become available through the Event Bus.

Subscriber applications receive these events almost immediately, allowing external systems to remain synchronized without polling Salesforce.

For a detailed explanation of Change Data Capture, read our guide:

Salesforce Change Data Capture: Complete Guide to Real-Time Data Synchronization


Platform Event Processing

Organizations often publish custom business events such as:

Subscriber applications consume these Platform Events independently.

Because publishers never communicate directly with subscribers, new systems can be added without modifying existing integrations.


Data Warehouses and Analytics

Business intelligence platforms require continuously updated Salesforce information.

Instead of importing complete datasets every hour, analytics platforms subscribe to incremental business events.

This enables:


AI and Machine Learning

Modern AI applications depend on current CRM information.

By subscribing to Salesforce events through the Pub/Sub API, AI platforms immediately receive customer interactions, sales updates, and service activities.

This allows predictive models to work with current business data instead of outdated snapshots.


Multi-Org Salesforce Architectures

Large enterprises frequently operate multiple Salesforce organizations.

Rather than building complex point-to-point integrations, organizations can stream events between environments using the Pub/Sub API, simplifying synchronization across distributed Salesforce implementations.


Microservices Architecture

Many organizations have adopted microservices instead of monolithic applications.

In these environments, each service subscribes only to the events relevant to its responsibilities.

This architecture improves scalability while reducing dependencies between applications.


IoT and Connected Devices

Manufacturing, logistics, and healthcare organizations increasingly integrate Salesforce with connected devices.

Sensors and IoT platforms can publish operational events that trigger Salesforce business processes, while Salesforce-generated events can be streamed back to operational systems for automated responses.

This event-driven communication reduces latency and enables near real-time operational visibility.


Salesforce Pub/Sub API Best Practices

Successfully implementing Salesforce Pub/Sub API requires more than simply connecting a client.

The following recommendations help organizations build reliable and scalable event-driven integrations.


Design Idempotent Subscribers

Distributed systems occasionally receive duplicate events.

Subscriber applications should therefore be idempotent, meaning that processing the same event multiple times always produces the same business outcome.


Always Store Replay IDs

Replay IDs are essential for reliable event processing.

Persist the most recently processed Replay ID so subscribers can recover gracefully after temporary outages or network interruptions.


Authenticate Securely

Use secure OAuth authentication and follow Salesforce security recommendations.

If your Salesforce integrations call external services, our Salesforce Named Credentials guide explains how to simplify authentication management while improving security.


Keep Subscriber Processing Lightweight

Subscribers should validate and route events quickly.

Resource-intensive operations should be delegated to asynchronous workers, queues, or downstream processing services.

This prevents subscriber bottlenecks while improving overall throughput.


Design for Horizontal Scaling

Enterprise integrations often process thousands of events every minute.

Subscriber applications should support horizontal scaling so multiple instances can process event streams simultaneously without becoming a performance bottleneck.


Monitor Event Throughput

Production integrations should continuously monitor:

Monitoring allows teams to detect synchronization problems before they affect business operations.


Handle Reconnects Automatically

Temporary network interruptions are inevitable.

Subscriber applications should automatically reconnect and resume processing from the latest Replay ID without manual intervention.


Subscribe Only to Required Events

Avoid subscribing to every available event.

Each application should consume only the event types required for its business responsibilities.

This reduces processing overhead while simplifying application logic.


Document Event Schemas

As the number of publishers and subscribers grows, maintaining clear documentation becomes increasingly important.

Document:

Good documentation makes future maintenance significantly easier.


Common Salesforce Pub/Sub API Mistakes

Even experienced Salesforce teams make similar implementation mistakes.

Common MistakeBetter Approach
Using REST API for continuous streamingUse Pub/Sub API
Ignoring Replay IDsResume processing after reconnect
Heavy subscriber processingProcess asynchronously
No monitoringContinuously monitor subscribers
Subscribing to unnecessary eventsSubscribe selectively
Treating Pub/Sub API as a CRUD APIUse REST API for CRUD operations
Assuming Pub/Sub API replaces Platform EventsPub/Sub API delivers Platform Events and CDC events

Avoiding these mistakes leads to more reliable, scalable, and maintainable integrations.


Salesforce Pub/Sub API Limitations

Although Salesforce Pub/Sub API is a powerful technology, architects should understand its limitations before implementation.

Key considerations include:

Understanding these limitations helps organizations choose the appropriate integration technology for each business scenario.

For complete implementation details, refer to the official Salesforce documentation.


When Should You Use Salesforce Pub/Sub API?

The following table summarizes when Pub/Sub API is the appropriate choice.

ScenarioRecommended
Platform Events
Change Data Capture
Event-driven enterprise integrations
Real-time streaming
CRUD operations
One-time API requests

As a general guideline:


How Success Craft Can Help

Designing a successful event-driven architecture requires selecting the right technologies, defining clear event contracts, and ensuring reliable communication between distributed systems.

At Success Craft, we help organizations build secure and scalable Salesforce integration solutions using Salesforce Pub/Sub API, Platform Events, Change Data Capture, Named Credentials, and other enterprise integration technologies.

Whether you’re modernizing legacy integrations or designing a cloud-native architecture, our team can help build solutions that remain reliable, maintainable, and ready to scale as your business grows.

Learn more about our Salesforce services.


Conclusion

Salesforce Pub/Sub API represents Salesforce’s modern approach to event-driven integration.

Built on gRPC and tightly integrated with the Salesforce Event Bus, it provides a unified interface for publishing and consuming Platform Events, Change Data Capture, and other supported event types.

Compared with legacy Streaming API implementations, Pub/Sub API delivers lower latency, improved scalability, and a simpler programming model for enterprise applications.

As Salesforce continues investing in event-driven architecture, Salesforce Pub/Sub API is becoming the recommended foundation for organizations building secure, scalable, and reliable real-time integrations. When combined with technologies such as Platform Events, Change Data Capture, and Named Credentials, it enables enterprise systems to exchange business events efficiently while reducing infrastructure complexity and long-term maintenance costs.

What is Salesforce Pub/Sub API?

Salesforce Pub/Sub API is a modern event streaming API built on gRPC that allows external applications to publish and subscribe to Salesforce events through the Salesforce Event Bus. It supports Platform Events, Change Data Capture, and Real-Time Event Monitoring events.

How does Salesforce Pub/Sub API work?

Applications connect to the Salesforce Event Bus using a persistent gRPC connection. Publishers send events to the Event Bus, while subscribers receive events in near real time without repeatedly polling Salesforce APIs.

What is the difference between Pub/Sub API and Streaming API?

Pub/Sub API uses gRPC for bidirectional streaming and improved performance, while Streaming API is based on the older CometD/Bayeux protocol. Pub/Sub API provides better scalability, lower latency, and a unified interface for modern event-driven integrations.

Does Salesforce Pub/Sub API support Change Data Capture?

Yes. Salesforce Pub/Sub API supports Change Data Capture (CDC) events, allowing external systems to receive automatic notifications whenever supported Salesforce records are created, updated, deleted, or restored.

Can Salesforce Pub/Sub API publish Platform Events?

Yes. In addition to subscribing to events, Pub/Sub API can publish Platform Events, enabling external applications to trigger business processes inside Salesforce.

What are Replay IDs in Salesforce Pub/Sub API?

Replay IDs are unique identifiers assigned to published events. They allow subscriber applications to reconnect after temporary interruptions and continue processing events from the last successfully received position.

When should I use Salesforce Pub/Sub API instead of REST API?

Use Salesforce Pub/Sub API for real-time, event-driven communication and continuous event streaming. REST API is better suited for synchronous CRUD operations, record queries, and request-response integrations.