Configure the User and Batch Size for Your Platform Event Trigger with PlatformEventSubscriberConfig
Running the trigger as a specific user instead of the default Automated Process entity has these benefits.
- Records are created, modified, and deleted as this user.
- OwnerId fields of created records are populated to this user.
- Records are shared with the user when sharing is enabled. For example, when the trigger calls into an Apex class declared with the with sharing keywords.
- Debug logs for the trigger execution are created by this user.
- You can send email messages from the trigger, which isn’t supported with the default Automated Process user.
You can specify any active user in the Salesforce org. The trigger runs in system context with privileges to access all records regardless of the user’s object and field-level permissions. Record sharing is enforced for the running user when the trigger calls into an Apex class declared with the with sharing keywords.
In addition to setting a user, you can specify a custom batch size from 1 through 2,000. The batch size is the maximum number of event messages that can be sent to a trigger in one execution. For platform event triggers, the default batch size is 2,000. Setting a smaller batch size can help avoid hitting Apex governor limits.
This image shows the Subscriptions related list in Setup for a platform event with a custom batch size and user.

To configure a platform event trigger with Tooling API, see PlatformEventSubscriberConfig in the Tooling API Developer Guide. To add a configuration, perform a POST with the PlatformEventSubscriberConfig REST resource, and perform a GET call to retrieve a configuration by ID. Also, you can query the configurations by using Tooling API.
To configure a platform event trigger with Metadata API, see PlatformEventSubscriberConfig in the Metadata API Developer Guide. You can use Visual Studio Code with the Salesforce Extension pack to deploy and retrieve Metadata API. For more information about installing Visual Studio Code and the extension pack, see Salesforce Extensions for Visual Studio Code. For more information about deploying and retrieving metadata by using the CLI, see source Commands and mdapi Commands in the Salesforce CLI Command Reference.
To learn about packaging PlatformEventSubscriberConfig components, see Platform Event Subscriber Configuration in the First-Generation Managed Packaging Developer Guide.