PlatformEventSubscriberConfig defines the running user, maximum event batch size, and internal parallel subscriptions for a platform event Apex trigger. It is separate from both the ApexTrigger code and the platform event definition.
The configuration's own fullName identifies the metadata component. The platformEventConsumer element identifies the subscribing Apex trigger by its full name. Matching the configuration name to the trigger name does not establish the association; the reference is explicit.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The configuration component's metadata identity, inherited from Metadata. This is distinct from the trigger named in platformEventConsumer. |
masterLabel |
Required. The label for the configuration component. |
platformEventConsumer |
Required. The full name of the platform event Apex trigger to configure. |
user |
The username of the trigger's running user, not a User record ID. Without an override, the trigger runs as Automated Process. |
batchSize |
The maximum number of event messages delivered in one trigger execution. Allowed values are 1 through 2,000; the default is 2,000. |
numPartitions |
The number of parallel subscriptions created internally for the trigger. Allowed values are 1 through 10; the default is 1. |
partitionKey |
The event field whose value is hashed to choose a partition. The default is EventUuid. A custom field must be required and use the format EventName__e.FieldName__c. |
isProtected |
Whether the component is protected: true or false. Protection controls package reference visibility and the publisher's ability to delete the component in a later package release. |
Behavior and Constraints
The running user is an operational identity, not just a logging preference. Records created or modified by the trigger are attributed to the configured user. The setting also affects OwnerId population on records that have that field, and trigger debug logs are generated under that user's identity. Specifying a running user enables sending email from the trigger, which is not supported with the default Automated Process user.
The choice of user can also affect credential access. Selecting a user who already has the necessary Named Credential permissions has resolved a reported access problem. The configuration selects that user; it does not assign permissions.
batchSize is a maximum, not a guarantee that every execution receives that many events. Salesforce discourages setting it to 1 merely to process one event at a time, because small batches can slow event processing.
batchSize and numPartitions control different dimensions of processing. The first controls messages per trigger execution; the second controls the number of internal parallel subscriptions. They are not interchangeable limits.
For parallel processing, Salesforce hashes the value of the field named by partitionKey to select a partition. Serialize the standard key as EventUuid, without an event-name prefix. A custom key must be a required custom field on the custom platform event to which the trigger subscribes, and must include the event name: EventName__e.FieldName__c. See Parallel Subscriptions for Apex Triggers for parallel-processing configuration details.
Deployment and Retrieval
In Metadata API format, components are stored in the PlatformEventSubscriberConfigs directory with the suffix .platformEventSubscriberConfig. For example, a component named OrderEventTriggerConfig uses OrderEventTriggerConfig.platformEventSubscriberConfig. In Salesforce source format, its filename is OrderEventTriggerConfig.platformEventSubscriberConfig-meta.xml.
In package.xml, use PlatformEventSubscriberConfig as the type name and the configuration's component name as the member. This type supports the wildcard member * to select all configurations for deployment or retrieval.
You can deploy the configuration independently when its dependencies already exist in the destination org. The referenced ApexTrigger must exist, and that trigger depends on the platform event represented by CustomObject. If the trigger and event are missing, include their definitions in the deployment; otherwise deployment fails.
Include relevant event field definitions when those dependencies are also missing. In particular, a custom partitionKey depends on its event field. This does not make every field on every related platform event an automatic deployment requirement.
Treat an environment-specific user value as a deployment input. A sandbox-to-sandbox deployment report found that Salesforce did not remap the username automatically and required the specified username to exist in the destination org. Do not assume that a sandbox suffix will be translated.
Package protection creates a separate commitment from execution identity. When isProtected is true, components created in a subscriber org cannot link to or reference the protected component, and the publisher can delete it in a future package release. Once an unprotected component has been released globally, the publisher cannot delete it. This setting does not select or protect the trigger's running user.
Relationships
The configuration directly references its Apex trigger and, when a custom partition key is used, an event field. The trigger in turn depends on the platform event represented by CustomObject. The configuration-to-trigger connection comes from platformEventConsumer, not a naming convention.
References
-
ApexTrigger:platformEventConsumer. -
CustomField:partitionKey, when the value names a custom event field.
Reported Issues
-
A changed running user can remain unapplied even when the stored configuration is correct. In 2023 reports, redeploying a changed
userleft the trigger executing as the previous user, although Tooling API queries showed the intended value. One respondent reported success after opening the platform event's Subscriptions management, selecting Manage for the trigger, and suspending and resuming the subscription. Other cases resolved after a delay. Suspend/resume is a reported remedy, not a required deployment step or guaranteed fix. Running-user changes not taking effect. -
Apex tests can show an identity mismatch that does not occur during live processing. A December 2022 discussion, updated in August 2025, reported that manual processing honored
user, while Apex tests ran the trigger as Automated Process, including attempts usingSystem.runAs. The author relayed that Salesforce Support identified this as a bug. This is a reported test-context issue, not a rule that normal execution ignores the configuration. Running-user override in Apex tests. -
Missing fields during Tooling API inspection can indicate a permission problem rather than an incomplete configuration. A January 2023 response relaying product-team guidance reported that Customize Application guards access to
PlatformEventConsumerId,UserId, andBatchSize. These are Tooling API field names, not Metadata API elements or replacements forplatformEventConsumer,user, andbatchSize. Tooling API field visibility. - Changing the running user can resolve credential-access failures when that user already has the required permissions. In January 2023, an administrator reported resolving a platform event trigger's Named Credential access problem by configuring a different running user instead of assigning permissions to Automated Process. The configuration itself did not grant credential access. Credential access through the running user.
-
A sandbox deployment can fail when the configured username does not exist in the target org. The same January 2023 report found that sandbox-to-sandbox deployment did not automatically adjust
userfor the destination. This makes username portability a separate concern from the portability of trigger and event metadata names. Destination username requirements. -
Incorrect file placement or suffixes can prevent deployment from finding the component. A 2021 discussion reported either a missing manifest-member error or a successful deployment of zero components. Replies identified the metadata-format suffix; a 2023 reply clarified the
PlatformEventSubscriberConfigsdirectory and the different metadata-format and source-format filenames. Deployment file and directory troubleshooting.
Common Questions
How do I change the running user of a platform event Apex trigger?
Set platformEventConsumer to the trigger's full name and user to the intended username, then deploy the configuration. Use a username that exists in the destination org, not a User record ID.
Can I deploy PlatformEventSubscriberConfig without deploying the trigger and event?
Yes, if the referenced trigger and its platform event already exist in the destination org. If they are missing, include their definitions, along with relevant missing event fields.
Does batchSize control parallel platform event processing?
No. batchSize limits messages in one trigger execution, while numPartitions controls internal parallel subscriptions. The defaults are 2,000 messages and one partition. Setting batchSize to 1 is discouraged because small batches can slow processing.
Why is my trigger still running as the old user after deployment?
Community reports describe a delay between the stored configuration changing and the runtime identity changing. Suspending and resuming the subscription applied the change in one reported case, while others resolved after a delay. Neither outcome is guaranteed.
Why does the configured user work manually but not in Apex tests?
A reported test-context bug caused platform event triggers to run as Automated Process during Apex tests even when manual processing honored user. The report also included unsuccessful attempts with System.runAs; it does not establish that live execution ignores the configuration.