PlatformEventChannel defines a custom subscription channel that groups Change Data Capture notifications or platform events into a stream. Change Data Capture notifications describe changes to Salesforce records. The channel defines the stream's identity and event category; it does not define the events included in the stream.
Membership is stored in separate PlatformEventChannelMember components. Deploying a channel definition alone does not reproduce its membership. Also, retrieving channel metadata retrieves configuration, not a history of events delivered through the channel.
Key Elements
The first four elements below belong to PlatformEventChannel. The last two belong to separate PlatformEventChannelMember components and determine which events the channel contains.
| Element | What the Element Controls |
|---|---|
fullName |
The channel's metadata name, inherited from the base metadata type. For example, the documented custom channel uses SalesEvents__chn. This is one of only two fields that can be updated on an existing channel. |
channelType |
Required. Use data for a Change Data Capture channel or event for a platform-event channel. It cannot be changed through an in-place update. |
eventType |
Optional event category. data is valid with channelType=data. custom and monitoring are valid with channelType=event, for custom platform events and Real-Time Event Monitoring events respectively. standard is reserved for internal use. This field cannot be changed through an in-place update. |
label |
Required. The channel's display label. Along with fullName, this field can be updated on an existing channel. |
eventChannel on PlatformEventChannelMember
|
References the channel to which the member belongs. It is not a field on the channel definition. |
selectedEntity on PlatformEventChannelMember
|
Identifies the event included by that member, such as AccountChangeEvent. Each member is maintained as a separate metadata component. |
Behavior and Constraints
Choose the event category when creating the channel. Only fullName and label can be updated on an existing PlatformEventChannel. Changing channelType or eventType is not a supported in-place update.
The eventType definition states that a channel can hold only one event category. For Change Data Capture, the supported explicit combination is channelType=data with eventType=data. For platform events, use channelType=event with either eventType=custom or eventType=monitoring. The documentation has conflicting wording about mixed-category channels, described below.
Deploying or retrieving this type requires the Customize Application permission. This is an administrative prerequisite for managing metadata; it does not establish a user's access to subscribe to the event stream.
The standard ChangeEvents channel corresponds to the entity selections on the Change Data Capture page in Setup. It is distinct from the custom channels managed with PlatformEventChannel.
Deployment and Retrieval
PlatformEventChannel components use the .platformEventChannel suffix and are stored in the platformEventChannels folder. In package.xml, use PlatformEventChannel as the metadata type and the channel's name, such as SalesEvents__chn, as the member. A * member selects all custom channels for deployment or retrieval.
Include both metadata types when moving a complete custom-channel configuration. The channel component contains its label and category settings. Its members are separate PlatformEventChannelMember components. For example, an Account member would use eventChannel=SalesEvents__chn and selectedEntity=AccountChangeEvent. Include the channel and its member components in the deployment manifest; the channel file alone does not contain those selections.
The Metadata API createMetadata() and deleteMetadata() calls are not supported for this type. This restriction is separate from support for deployment and retrieval through metadata packages.
-
Delete a custom channel with
destructiveChanges.xml. Deleting the channel also deletes all of itsPlatformEventChannelMembercomponents. -
Do not include the standard
ChangeEventschannel as aPlatformEventChannelcomponent. It cannot be deployed or retrieved as this type, and it cannot be deleted withdestructiveChanges.xml. -
Remove standard-channel members through their own metadata type. Members of
ChangeEventsremain separatePlatformEventChannelMembercomponents and can be deleted using that type indestructiveChanges.xml.
See the PlatformEventChannel metadata reference for the file format and manifest examples.
Relationships
Channel membership and relay use are separate relationships. A member associates an event with the channel through eventChannel and identifies that event through selectedEntity. A relay configuration also references the channel, but it is not a membership component. Relay configurations can therefore be affected by channel changes or removal independently of the channel's members.
Referenced By
-
EventRelayConfig:eventChannel. -
PlatformEventChannelMember:eventChannel.
Documentation Inconsistencies
The eventType field definition says a channel can hold only one event category. However, the usage text describes an example as containing both custom platform events and Real-Time Event Monitoring events and links to Group Platform Events into One Stream with a Custom Channel. Do not treat that example description as unambiguous confirmation that mixed-category channels are supported.
Reported Issues
-
The reported filtering approach requires member configuration, not a filter field on the channel. A November 2023 community answer describes creating a custom channel and a
PlatformEventChannelMemberwhosefilterExpressionfilters the event identified byselectedEntityand associated througheventChannel. This helps distinguish a channel-definition problem from a member-filter problem. The answer does not establish delivery-limit savings for a particular configuration. See the custom-channel filtering discussion. -
An HTTP request to a subscription channel is not a way to retrieve a flat change history. In a December 2019 discussion, attempts to request
/data/ChangeEventsas an HTTP resource failed. The accepted answer explained that Change Data Capture uses subscriptions, with replay capabilities for missed events, rather than an HTTP resource returning a flat list of historical changes. RetrievingPlatformEventChannelmetadata is therefore distinct from consuming the stream. See the change-event retrieval discussion.
Common Questions
Why didn't deploying PlatformEventChannel include my selected events?
The channel definition does not contain membership. Include the separate PlatformEventChannelMember components, using eventChannel to reference the channel and selectedEntity to identify each event.
Can I retrieve or deploy the standard ChangeEvents channel?
No. The standard ChangeEvents channel cannot be retrieved or deployed as PlatformEventChannel. It corresponds to the entity selections in Change Data Capture Setup, and its members are separate PlatformEventChannelMember components.
Can I change channelType or eventType on an existing channel?
No supported in-place update changes either field. Only fullName and label can be updated, so select the channel and event categories when creating the channel.
How do I delete a custom channel and its members?
Delete the custom PlatformEventChannel through destructiveChanges.xml. Its members are deleted with it. The Metadata API deleteMetadata() call is not supported, and the standard ChangeEvents channel cannot be deleted this way.
Where do I put a filter for a custom event channel?
The reported approach places filterExpression on PlatformEventChannelMember, not on PlatformEventChannel. The community report does not establish how much, if any, delivery-limit usage a particular filter configuration saves.