$npx -y skills add forcedotcom/sf-skills --skill integration-eventing-subscription-configureCreate, read, update, and delete ManagedEventSubscription metadata in Salesforce. Use this skill for any work involving managed event subscriptions, platform event subscriptions, event channel subscribers, or .managedEventSubscription-meta.xml files. TRIGGER when: user asks to su
| 1 | # Managing ManagedEventSubscription |
| 2 | |
| 3 | Create, read, update, and delete `ManagedEventSubscription` metadata — the Salesforce construct for durably subscribing to platform event channels with managed replay tracking. |
| 4 | |
| 5 | ## Scope |
| 6 | |
| 7 | - **In scope**: Generating and modifying `.managedEventSubscription-meta.xml` files for create, read, update, and delete operations |
| 8 | - **Out of scope**: Creating the underlying platform event (`__e`) channel itself; Flow-based or Apex-based event subscriptions; deploying metadata to an org |
| 9 | - **Only generate one file** — the `.managedEventSubscription-meta.xml` file. Do NOT generate the referenced platform event object or any other metadata type. |
| 10 | |
| 11 | --- |
| 12 | |
| 13 | ## Clarifying Questions |
| 14 | |
| 15 | Before generating, confirm if not already clear: |
| 16 | |
| 17 | - What is the **topic name**? (see format table in `references/topic-name-formats.md`) |
| 18 | - What is the **developer name**? (required for Create — alphanumeric and underscores only, no spaces; optional for Read/Update/Delete if `Id` is known) |
| 19 | - What is the **label** (human-readable name)? |
| 20 | - What **default replay** preset — `LATEST` (default) or `EARLIEST`? |
| 21 | - What **error recovery replay** preset — `LATEST` (default) or `EARLIEST`? |
| 22 | - What should the initial **state** be — `RUN` (active) or `STOP` (inactive)? (default: `RUN`) |
| 23 | |
| 24 | --- |
| 25 | |
| 26 | ## Required Inputs |
| 27 | |
| 28 | Gather or infer before proceeding: |
| 29 | |
| 30 | - **Operation**: create, read, update, or delete |
| 31 | - **DeveloperName**: required for Create (becomes the filename); optional for Read/Update/Delete if `Id` is provided instead |
| 32 | - **Id**: Tooling API record Id — can be used to identify the subscription for Read/Update/Delete instead of DeveloperName |
| 33 | - **label**: human-readable label (can include spaces) |
| 34 | - **topicName**: event channel path — read `references/topic-name-formats.md` for valid formats (platform events, change events, custom channels) |
| 35 | - **defaultReplay**: `LATEST` or `EARLIEST` (default: `LATEST`) |
| 36 | - **errorRecoveryReplay**: `LATEST` or `EARLIEST` (default: `LATEST`) |
| 37 | - **state**: `RUN` or `STOP` (default: `RUN`) — `PAUSE` is reserved for internal platform use and will be rejected with `INVALID_INPUT` |
| 38 | - **version**: Metadata API version (default: match org API version, e.g. `67.0`) |
| 39 | |
| 40 | --- |
| 41 | |
| 42 | ## Workflow |
| 43 | |
| 44 | ### Create |
| 45 | |
| 46 | 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. |
| 47 | 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 `platform-custom-object-generate` skill, then return here. |
| 48 | 3. **Read the template** — load `assets/managed-event-subscription-template.xml` as the starting structure. |
| 49 | 4. **Generate the file** — produce `managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml` filled with user-provided values. |
| 50 | 5. **Verify** — run the checklist below before presenting output. |
| 51 | 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. |
| 52 | |
| 53 | ### Read |
| 54 | |
| 55 | 1. **Identify the subscription** — accept either `Id` or `DeveloperName`; prefer `Id` if provided. |
| 56 | 2. **Show the file path** — `managedEventSubscriptions/<DeveloperName>.managedEventSubscription-meta.xml` (if DeveloperName known). |
| 57 | 3. **Retrieve and display** — read and present the current XML content. |
| 58 | |
| 59 | ### Update |
| 60 | |
| 61 | 1. **Identify the subscription** — accept either `Id` or `DeveloperName`; prefer `Id` if provided. |
| 62 | 2. **Read the existing file** — load current content before modifying. |
| 63 | 3. **Apply changes** — update only the specified fields; preserve all others. |
| 64 | 4. **Read `references/update-constraints.md`** for fields that cannot be changed after creation. |
| 65 | 5. **Verify** — run the checklist b |