Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
Create a Custom Channel and Add Platform Events with Tooling API
| 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. See Quick Start: Connect Postman to Salesforce in Trailhead.
-
Create the channel using PlatformEventChannel, and set the channelType field to event. Send a POST request
to this URI.
1/services/data/v67.0/tooling/sobjects/PlatformEventChannelIf you're using Postman, expand , and then click Create channel.
-
Use this request body.
1{ 2 "FullName": "Order_Channel__chn", 3 "Metadata": { 4 "channelType": "event", 5 "label": "Custom Channel for Orders" 6 } 7}You receive a response similar to this response.1{ 2 "id": "0YLRM0000004CEI4A2", 3 "success": true, 4 "errors": [], 5 "warnings": [], 6 "infos": [] 7} -
Add the Order_NorthAmer__e platform event to the channel using PlatformEventChannelMember.
The channel member references the channel it’s part of (Order_Channel__chn) through the eventChannel field. Specify the platform event in the selectedEntity field. Send a POST request to this URI.
1/services/data/v67.0/tooling/sobjects/PlatformEventChannelMemberIf you're using Postman, expand , and then click Create channel member.
-
Use this request body.
1{ 2 "FullName": "Order_Channel_chn_Order_NorthAmer_e", 3 "Metadata": { 4 "eventChannel": "Order_Channel__chn", 5 "selectedEntity": "Order_NorthAmer__e" 6 } 7}You receive a response similar to this response.1{ 2 "id": "0v8RM0000000N6uYAE", 3 "success": true, 4 "errors": [], 5 "warnings": [], 6 "infos": [] 7} -
Add the second channel member that specifies the platform event, Order_EMEA__e. Send a POST
request to this URI.
1/services/data/v67.0/tooling/sobjects/PlatformEventChannelMemberIf you're using Postman, expand , and then click Create channel member.
-
Use this request body.
1{ 2 "FullName": "Order_Channel_chn_Order_EMEA_e", 3 "Metadata": { 4 "eventChannel": "Order_Channel__chn", 5 "selectedEntity": "Order_EMEA__e" 6 } 7}You receive a response similar to this response.1{ 2 "id": "0v8RM0000004VPJYA2", 3 "success": true, 4 "errors": [], 5 "warnings": [], 6 "infos": [] 7}