Platform Event Fields
Migrate Platform Event Definitions with Metadata API
Encrypting Platform Event Messages at Rest in the Event Bus
Previous Versions
Platform events contain standard fields. Add custom fields for your custom data.
To define a platform event in Salesforce Classic or Lightning Experience:
From Setup, enter Platform Events in the Quick Find box, then select Platform Events.
On the Platform Events page, click New Platform Event.
Complete the standard fields, and optionally add a description.
For Publish Behavior, choose when the event message is published in a transaction.
The publish behavior doesn’t apply to event messages published with Pub/Sub API.
Note
Click Save.
To add a field, in the Custom Fields & Relationships related list, click New.
To set up the field properties, follow the custom field wizard.
Note
Platform events include standard fields. These fields appear on the New Platform Event page.
| Field | Description |
|---|---|
Label | Name used to refer to your platform event in a user interface page. |
Plural Label | Plural name of the platform event. |
Starts with a vowel sound | If it’s appropriate for your org’s default language, indicate whether the label is preceded by “an” instead of “a.” |
Object Name | Unique name used to refer to the platform event when using the API. In managed packages, this name prevents naming conflicts with package installations. Use only alphanumeric characters and underscores. The name must begin with a letter and have no spaces. It can’t end with an underscore or have two consecutive underscores. |
Description | Optional description of the object. A meaningful description helps you remember the differences between your events when you view them in a list. |
Deployment Status | Indicates whether the platform event is visible to other users. |
In addition to the standard fields, you can add custom fields to your custom event. Platform event custom fields support only these field types.
The maximum number of fields that you can add to a platform event is the same as for a custom object. See Salesforce Features and Edition Allocations.
Each event message is assigned an opaque ID contained in the ReplayId field. The ReplayId field value, which is populated by the system when the event is delivered to subscribers, refers to the position of the event in the event stream. Replay ID values aren’t guaranteed to be contiguous for consecutive events. A subscriber can store a replay ID value and use it on resubscription to retrieve events that are within the retention window. For example, a subscriber can retrieve missed events after a connection failure. Subscribers must not compute new replay IDs based on a stored replay ID to refer to other events in the stream.
To learn more about how to use the ReplayId field when resubscribing to the stream, see Replaying an Event Stream in the Pub/Sub API Reference.
To uniquely identify a platform event message, use the EventUuid system field and not the ReplayId field. The ReplayId field isn’t guaranteed to be unique when Salesforce maintenance activities occur, such as an org migration. The EventUuid field is always unique.
A universally unique identifier (UUID) that identifies a platform event message. The system populates the EventUuid field, and you can’t overwrite its value. This field is available in API version 52.0 and later. The API version corresponds to the version that an Apex trigger is saved with or the version specified in a CometD subscriber endpoint.
When you create a platform event, the system appends the __e suffix to create the API name of the event. For example, if you create an event with the object name Low Ink, the API name is Low_Ink__e. The API name is used whenever you refer to the event programmatically, for example, in Apex. API names of standard platform events, such as AssetTokenEvent, don’t include a suffix.
See Also