
Managing Managed Event Subscription
- 831 installs
- 787 repo stars
- Updated August 5, 2026
- forcedotcom/sf-skills
managing-managed-event-subscription is a Claude Code skill that generates, reads, updates, and deletes ManagedEventSubscription metadata files for Salesforce platform event subscriptions for developers who configure even
About
managing-managed-event-subscription is a Salesforce sf-skills entry for creating, reading, updating, and deleting ManagedEventSubscription metadata. The skill handles managed event subscriptions, platform event subscriptions, event channel subscribers, and `.managedEventSubscription-meta.xml` files including replay preset configuration, activation, and deactivation. Developers reach for this skill when subscribing to platform events, setting up event replay, or managing subscription lifecycle—but skip it when creating the platform event channel itself (use generating-platform-event instead). Triggers include requests to subscribe to platform events or update replay presets.
- Generates and modifies .managedEventSubscription-meta.xml files
- Supports create, read, update, and delete operations on managed event subscriptions
- Handles platform event subscriptions with managed replay tracking
- Only generates one file per invocation — the ManagedEventSubscription metadata
- TRIGGER when user asks to subscribe to a platform event, configure replay, or manage subscriptions
Managing Managed Event Subscription by the numbers
- 831 all-time installs (skills.sh)
- +1 installs in the week ending Jul 29, 2026 (Skillselion tracking)
- Ranked #480 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/forcedotcom/sf-skills --skill managing-managed-event-subscriptionAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 831 |
|---|---|
| repo stars | ★ 787 |
| Last updated | August 5, 2026 |
| Repository | forcedotcom/sf-skills ↗ |
How do you manage Salesforce platform event subscriptions?
Generate, read, update, and delete ManagedEventSubscription metadata files when working with Salesforce platform events.
Who is it for?
Salesforce developers working with platform events who need CRUD operations on ManagedEventSubscription metadata and event replay configuration.
Skip if: Tasks requiring creation of the platform event channel itself, which needs the generating-platform-event skill instead.
When should I use this skill?
The user asks to subscribe to a platform event, create a managed subscription, configure event replay, activate or deactivate a subscription, or edit ManagedEventSubscription metadata.
What you get
ManagedEventSubscription metadata files, configured event channel subscribers, and activated or deactivated replay presets.
- ManagedEventSubscription metadata XML
- configured event subscriptions
- replay preset settings
By the numbers
- Manages `.managedEventSubscription-meta.xml` Salesforce metadata files
- Covers platform event subscriptions, event channel subscribers, and replay presets
Files
Managing ManagedEventSubscription
Create, read, update, and delete ManagedEventSubscription metadata — the Salesforce construct for durably subscribing to platform event channels with managed replay tracking.
Scope
- In scope: Generating and modifying
.managedEventSubscription-meta.xmlfiles for create, read, update, and delete operations - Out of scope: Creating the underlying platform event (
__e) channel itself; Flow-based or Apex-based event subscriptions; deploying metadata to an org - Only generate one file — the
.managedEventSubscription-meta.xmlfile. Do NOT generate the referenced platform event object or any other metadata type.
---
Clarifying Questions
Before generating, confirm if not already clear:
- What is the topic name? (see format table in
references/topic-name-formats.md) - What is the developer name? (required for Create — alphanumeric and underscores only, no spaces; optional for Read/Update/Delete if
Idis known) - What is the label (human-readable name)?
- What default replay preset —
LATEST(default) orEARLIEST? - What error recovery replay preset —
LATEST(default) orEARLIEST? - What should the initial state be —
RUN(active) orSTOP(inactive)? (default:RUN)
---
Required Inputs
Gather or infer before proceeding:
- Operation: create, read, update, or delete
- DeveloperName: required for Create (becomes the filename); optional for Read/Update/Delete if
Idis provided instead - Id: Tooling API record Id — can be used to identify the subscription for Read/Update/Delete instead of DeveloperName
- label: human-readable label (can include spaces)
- topicName: event channel path — read
references/topic-name-formats.mdfor valid formats (platform events, change events, custom channels) - defaultReplay:
LATESTorEARLIEST(default:LATEST) - errorRecoveryReplay:
LATESTorEARLIEST(default:LATEST) - state:
RUNorSTOP(default:RUN) —PAUSEis reserved for internal platform use and will be rejected withINVALID_INPUT - version: Metadata API version (default: match org API version, e.g.
67.0)
---
Workflow
Create
1. Gather inputs — confirm DeveloperName, label, topicName, defaultReplay, errorRecoveryReplay, state, version. Apply defaults for any omitted fields. If DeveloperName is not provided, ask the user — do not derive it from the label. 2. Confirm the topic exists — ask the user to confirm the event channel already exists in the org before proceeding. Do NOT generate the platform event object yourself — that is out of scope for this skill. If the user says it doesn't exist yet, stop and direct them to create it first using the generating-platform-event skill, then return here. 3. Read the template — load assets/managed-event-subscription-template.xml as the starting structure. 4. Generate the file — produce managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml filled with user-provided values. 5. Verify — run the checklist below before presenting output. 6. Guide the user on subscribing — after deployment, the subscription can be identified for Pub/Sub API ManagedSubscribe RPC calls using either the DeveloperName or the record Id. To retrieve the Id, run: SELECT Id, DeveloperName FROM ManagedEventSubscription WHERE DeveloperName='<DeveloperName>' via the Tooling API.
Read
1. Identify the subscription — accept either Id or DeveloperName; prefer Id if provided. 2. Show the file path — managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml (if DeveloperName known). 3. Retrieve and display — read and present the current XML content.
Update
1. Identify the subscription — accept either Id or DeveloperName; prefer Id if provided. 2. Read the existing file — load current content before modifying. 3. Apply changes — update only the specified fields; preserve all others. 4. Read `references/update-constraints.md` for fields that cannot be changed after creation. 5. Verify — run the checklist below before presenting output.
Delete
1. Identify the subscription — accept either Id or DeveloperName; confirm with the user before proceeding. 2. Warn — deleting a ManagedEventSubscription permanently removes replay tracking state. 3. Produce deletion instructions — explain how to remove the file and deploy the destructive change using destructiveChanges.xml. 4. Read `references/delete-guide.md` for the destructive deployment procedure.
---
Rules / Constraints
| Constraint | Rationale |
|---|---|
<topicName> must use a valid path prefix | Platform events use /event/Name__e; change events use /data/Name; see references/topic-name-formats.md for all formats |
<defaultReplay> and <errorRecoveryReplay> must be LATEST or EARLIEST | These are the only valid enum values; any other value fails metadata validation |
<state> must be RUN or STOP | PAUSE is reserved for internal platform use — the API rejects it with INVALID_INPUT: You can create a managed event subscription state field only to RUN or STOP |
| All six required elements must be present | topicName, defaultReplay, errorRecoveryReplay, label, state, version are all required; omitting any causes a deploy error |
| DeveloperName must be unique within the org | Duplicate names cause DUPLICATE_DEVELOPER_NAME errors |
Do not include <namespacePrefix>, <id>, or <createdDate> | Read-only platform fields; including them causes deployment failures in unpackaged orgs |
---
Gotchas
| Issue | Resolution |
|---|---|
The topicName field is invalid on deploy | Wrong format or the event doesn't exist in the org — read references/topic-name-formats.md for correct path |
| Replay state lost after delete + recreate | Deleting discards stored replay position; recreating starts from defaultReplay — avoid reusing the same DeveloperName after delete |
INVALID_TYPE on SOQL query | ManagedEventSubscription is only queryable via Tooling API, not standard SOQL |
EARLIEST replay on high-volume channels | Can trigger up to 72 hours of backlog replay on activation; always confirm with the user |
| Metadata not supported in older orgs | ManagedEventSubscription requires API v60.0+; check org API version |
eventChannel or isActive in generated XML | These are wrong field names — use topicName and state (RUN/STOP) instead |
PAUSE state in generated XML | PAUSE is reserved for internal platform use and will be rejected with INVALID_INPUT — only use RUN or STOP |
| User unsure how to identify subscription for Pub/Sub API | Both DeveloperName and record Id can be used with ManagedSubscribe RPC — retrieve the Id via Tooling API if needed: SELECT Id FROM ManagedEventSubscription WHERE DeveloperName='<name>' |
| Changes not reflected immediately in Pub/Sub API | After create/update/delete, the Pub/Sub API can take up to ~2 minutes to reflect the new config; if ManagedSubscribe returns NOT_FOUND, wait and retry |
---
Verification Checklist
Before presenting any generated XML:
- [ ] Does
<topicName>follow a valid path format perreferences/topic-name-formats.md? (/event/Name__e,/data/NameChangeEvent,/data/ChangeEvents,/event/Name__chn,/data/Name__chn) - [ ] Is
<defaultReplay>exactlyLATESTorEARLIEST? - [ ] Is
<errorRecoveryReplay>exactlyLATESTorEARLIEST? - [ ] Is
<state>exactlyRUNorSTOP? (PAUSEis invalid for user-created subscriptions) - [ ] Is
<label>populated? - [ ] Is
<version>present (e.g.67.0)? - [ ] Are read-only fields (
<id>,<createdDate>,<namespacePrefix>) absent? - [ ] Does the filename match the DeveloperName exactly?
---
Output Expectations
- Create / Update:
managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml— this is the only file to generate - Delete: instructions to remove the file and deploy via
destructiveChanges.xml - Read: display of existing file contents
---
Cross-Skill Integration
| Need | Delegate to |
|---|---|
Create the platform event channel (__e) being subscribed to | generating-platform-event skill |
| Subscribe via Flow (Process Automation) | generating-flow skill |
| Deploy metadata to org | deploying-metadata skill |
---
Reference File Index
| File | When to read |
|---|---|
assets/managed-event-subscription-template.xml | Before generating any new subscription — use as starting structure |
references/topic-name-formats.md | When setting <topicName> — covers platform events, change events, and custom channels |
references/update-constraints.md | During Update workflow — to check which fields are immutable post-creation |
references/delete-guide.md | During Delete workflow — for destructive change deployment procedure |
<?xml version="1.0" encoding="UTF-8"?>
<ManagedEventSubscription xmlns="http://soap.sforce.com/2006/04/metadata">
<!-- Required: EARLIEST or LATEST — replay position on normal startup -->
<defaultReplay>{DEFAULT_REPLAY}</defaultReplay>
<!-- Required: EARLIEST or LATEST — replay position after an error recovery -->
<errorRecoveryReplay>{ERROR_RECOVERY_REPLAY}</errorRecoveryReplay>
<!-- Required: Human-readable label -->
<label>{LABEL}</label>
<!-- Required: RUN (active) or STOP (inactive) — PAUSE is reserved for internal use and will be rejected -->
<state>{STATE}</state>
<!-- Required: Event channel path — see references/topic-name-formats.md for valid formats
Platform event: /event/Name__e
Custom PE channel: /event/Name__chn
All-objects change events: /data/ChangeEvents
Single-object change event:/data/ObjectNameChangeEvent
Custom change channel: /data/Name__chn -->
<topicName>{TOPIC_NAME}</topicName>
<!-- Required: Metadata API version (e.g. 67.0) -->
<version>{VERSION}</version>
</ManagedEventSubscription>
Deleting a ManagedEventSubscription
Warning
Deleting a ManagedEventSubscription permanently destroys its stored replay position. If you recreate the subscription, it will start from its <defaultReplay> — it will not resume from where it left off.
DELETE is safe to call regardless of the subscription's current state — it atomically stops any running subscription, clears the committed Replay ID, and removes the record. No prior STOP transition is required.
After deletion, avoid reusing the same DeveloperName immediately — the Pub/Sub API service can take up to ~2 minutes to reflect the deletion. Create a new record with a different name if immediate re-creation is needed.
Procedure
Step 1 — Remove the metadata file
Delete the file from your project:
managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xmlStep 2 — Create a destructiveChanges.xml
In your deployment package root, create destructiveChanges.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members><DeveloperName></members>
<name>ManagedEventSubscription</name>
</types>
<version>67.0</version>
</Package>Replace <DeveloperName> with the exact developer name of the subscription to delete.
Step 3 — Create an empty package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<version>67.0</version>
</Package>Step 4 — Deploy
sf project deploy start --manifest package.xml --post-destructive-changes destructiveChanges.xml --target-org <alias>Common Errors
| Error | Cause | Fix |
|---|---|---|
INVALID_CROSS_REFERENCE_KEY | DeveloperName not found | Confirm the exact name with sf api request rest "/services/data/v67.0/tooling/query/?q=SELECT+DeveloperName+FROM+ManagedEventSubscription" |
| Subscription reappears or Pub/Sub returns NOT_FOUND after delete | ~2 minute propagation delay in Pub/Sub API service | Wait 2 minutes before attempting any operation on the same topic |
topicName Formats for ManagedEventSubscription
The <topicName> field requires a full channel path, not just an API name. The correct format depends on the type of event channel.
Valid Formats
| Channel type | Format | Example |
|---|---|---|
| Platform event | /event/<Name>__e | /event/Order_Fulfillment__e |
| Custom platform event channel | /event/<Name>__chn | /event/MyChannel__chn |
| All-objects change event channel | /data/ChangeEvents | /data/ChangeEvents |
| Single-object change event | /data/<Object>ChangeEvent | /data/AccountChangeEvent |
| Custom change event channel | /data/<Name>__chn | /data/MyChangeChannel__chn |
Rules
- The path prefix (
/event/or/data/) is required — omitting it causes"The topicName field is invalid"deploy error - The referenced event or channel must exist in the org before deploying the subscription
topicNameis immutable after creation — to change it, delete and recreate the subscription
Common Errors
| Error | Cause | Fix |
|---|---|---|
The topicName field is invalid | Missing /event/ or /data/ prefix, or wrong suffix | Use the full path format from the table above |
The topicName field is invalid | Referenced event/channel does not exist in the org | Create the platform event or channel first |
Update Constraints for ManagedEventSubscription
Fields That Can Be Updated
| Field | Notes |
|---|---|
<label> | Can be changed at any time |
<state> | Toggle between RUN and STOP — PAUSE is reserved for internal use and will be rejected |
<defaultReplay> | Can be changed, but see warning below |
<errorRecoveryReplay> | Can be changed at any time |
Fields That Cannot Be Changed After Creation
| Field | Why |
|---|---|
<topicName> | Changing the channel requires delete + recreate; the platform ties replay state to the original channel |
| DeveloperName (filename) | Renaming requires delete + recreate; rename-in-place is not supported by the Metadata API |
defaultReplay Change Warning
Changing <defaultReplay> from LATEST to EARLIEST on an existing subscription will cause it to re-replay all available events from the earliest retained position on the next activation. On high-volume event channels this can create a large backlog. Always confirm intent with the user before making this change.
Procedure for Immutable Field Changes
If the user needs to change <topicName> or DeveloperName:
1. Export current subscription config 2. Delete the existing subscription (see references/delete-guide.md) 3. Create a new subscription with the desired values 4. Note: replay tracking state from the old subscription is lost
Related skills
How it compares
Use managing-managed-event-subscription for subscription and replay metadata after the platform event channel exists via generating-platform-event.
FAQ
What metadata files does managing-managed-event-subscription edit?
managing-managed-event-subscription creates, reads, updates, and deletes ManagedEventSubscription metadata in `.managedEventSubscription-meta.xml` files. The skill covers event channel subscribers, replay presets, and subscription activation or deactivation on Salesforce platform
When should managing-managed-event-subscription be skipped?
managing-managed-event-subscription should be skipped when the user needs to create the platform event channel itself. For channel creation, use the generating-platform-event skill instead of ManagedEventSubscription metadata management.