Before you can add a filter, create a channel. Use PlatformEventChannel in Tooling API, and specify API version 56.0 or later.
Before You Begin
User Permissions Needed
To create or update PlatformEventChannel and PlatformEventChannelMember objects:
Customize Application
To use REST API:
API Enabled
You can use your preferred REST API tool to perform these steps. We recommend using Postman with the Salesforce Platform APIs collection, which contains handy templates for Salesforce API calls. To set up Postman, see Quick Start: Connect Postman to Salesforce in Trailhead.
To create a channel, send a POST request to this URI.
Add a channel member that specifies the custom platform event and filter expression. This example references the custom platform event, Order_Event__e. Send a POST request to this URI.
To update a filter expression, perform a PATCH request to /services/data/v68.0/tooling/sobjects/PlatformEventChannelMember/<ChannelMemberID>, and pass in the entire request body with the new filter expression. You can update only the filterExpression field of a channel member. All other fields aren’t updateable.
If your Salesforce org has a namespace, prepend the namespace prefix to each field used in filterExpression and the selectedEntity value in the PlatformEventChannelMember request body. For example, if the namespace is ns, the request body in this example becomes:
1{2 "FullName": "MyChannel_chn_Order_Event_e",3 "Metadata": {4 "eventChannel": "MyChannel__chn",5 "filterExpression": "(ns__City__c LIKE 'S%' OR ns__City__c='New York') AND ns__Amount__c>10.50",6 "selectedEntity": "ns__Order_Event__e"7 }8}