---
schema_version: "1"
id: aea80a4a20355831000841b226faf76e4c625575f8a9b7753dbaa919d2b691d3
title: ManagedEventSubscription (Beta)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_managedeventsubscription.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_managedeventsubscription.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: c978d261c59c54d1b15703e9af6e85fbdd14abc6b9e4da2c1ba8d6ec7c607443
description: Represents a managed event subscription in Pub/Sub API. Use a managed event subscription to track the events that a subscriber client consumed and resume a subscription where it left off. This type extends the metadata type and inherits its fullName field.
---
# ManagedEventSubscription (Beta)

Represents a managed event subscription in Pub/Sub API. Use a managed event subscription to track the events that a subscriber client consumed and resume a subscription where it left off. This type extends the metadata type and inherits its fullName field.

![Note](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/images/icon_note.png)

#### Note

This feature is a Beta Service. Customer may opt to try such Beta Service in its sole discretion. Any use of the Beta Service is subject to the applicable Beta Services Terms provided at Agreements and Terms.

## File Suffix and Directory Location

ManagedEventSubscription components have the suffix .managedEventSubscription and are stored in the managedEventSubscriptions folder.

## Version

ManagedEventSubscription components are available in API version 60.0 and later.

## Special Access Rules

You must have the Customize Application permission to deploy and retrieve this type.

## Fields

<table class="featureTable sort_table" summary="">



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d651254e100">Field Name</th>

              <th class="featureTableHeader  " id="d651254e103">Field Type</th>

              <th class="featureTableHeader  " id="d651254e106">Description</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d651254e100" data-title="Field Name"><span class="keyword parmname">defaultReplay</span></td>

              <td class="entry" headers="d651254e103" data-title="Field Type">EventSubscriptionReplayPreset (enumeration of type
                string)</td>

              <td class="entry" headers="d651254e106" data-title="Description">The position in the stream where the subscription starts when the
                client initiates the subscription for the first time or if the
                client doesn’t commit a Replay ID. Possible values are:<ul class="ul bulletList">
                  <li class="li">
                    <samp class="codeph nolang">LATEST</samp>—(Default)
                    The subscription starts from the latest events received.
                    This option skips sending events that were published when
                    the client was disconnected.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">EARLIEST</samp>—The
                    subscription starts from the earliest events stored in the
                    event bus. This option sends new events and any other events
                    less than 72 hours old. You can reprocess all stored events
                    and catch up on missed events. Use this option sparingly.
                    Subscribing with the <samp class="codeph nolang">EARLIEST</samp> option when a large number of event
                    messages are stored can slow performance and exhaust the
                    event delivery allocation.
                  </li>

                </ul>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d651254e100" data-title="Field Name"><span class="keyword parmname">errorRecoveryReplay</span></td>

              <td class="entry" headers="d651254e103" data-title="Field Type">EventSubscriptionReplayPreset (enumeration of type
                string)</td>

              <td class="entry" headers="d651254e106" data-title="Description">The position in the stream where the subscription restarts if the
                committed Replay ID is invalid. The Replay ID can be invalid if it’s
                older than the event retention window. Possible values are:<ul class="ul bulletList">
                  <li class="li">
                    <samp class="codeph nolang">LATEST</samp>—(Default)
                    The subscription restarts from the latest events received.
                    This option skips sending events that were published when
                    the client was disconnected.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">EARLIEST</samp>—The
                    subscription restarts from the earliest events stored in the
                    event bus. This option sends new events and any other events
                    less than 72 hours old. You can reprocess all stored events
                    and catch up on missed events. Use this option sparingly.
                    Subscribing with the <samp class="codeph nolang">EARLIEST</samp> option when a large number of event
                    messages are stored can slow performance and exhaust the
                    event delivery allocation.
                  </li>

                </ul>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d651254e100" data-title="Field Name"><span class="keyword parmname">label</span></td>

              <td class="entry" headers="d651254e103" data-title="Field Type">string</td>

              <td class="entry" headers="d651254e106" data-title="Description">The label for the managed subscription.</td>

            </tr>

            <tr>
              <td class="entry" headers="d651254e100" data-title="Field Name"><span class="keyword parmname">state</span></td>

              <td class="entry" headers="d651254e103" data-title="Field Type">EventSubscriptionAdminState (enumeration of type string)</td>

              <td class="entry" headers="d651254e106" data-title="Description">The execution state that the <samp class="codeph nolang">ManagedSubscribe</samp> RPC call consumes. If
                <span class="keyword parmname">state</span> is set to <samp class="codeph nolang">RUN</samp>, the subscription starts when the <samp class="codeph nolang">ManagedSubscribe</samp> RPC call is made.
                Otherwise, the subscription doesn't start. If an administrator later
                changes <span class="keyword parmname">state</span> from <samp class="codeph nolang">RUN</samp> to <samp class="codeph nolang">STOP</samp>, the
                system notifies the Pub/Sub API client of the new
                <span class="keyword parmname">state</span> value and the subscription
                disconnects. Also, the stored Replay ID value that was committed
                previously is deleted. The next time the <samp class="codeph nolang">ManagedSubscribe</samp> RPC call is made after
                <span class="keyword parmname">state</span> is changed from <samp class="codeph nolang">STOP</samp> to <samp class="codeph nolang">RUN</samp>, the subscription starts from the
                <span class="keyword parmname">defaultReplay</span> value. You must wait at least
                5 minutes after changing the <span class="keyword parmname">state</span> to
                <samp class="codeph nolang">STOP</samp> before changing it back to
                <samp class="codeph nolang">RUN</samp>.
                <p class="p">The possible values
                  for <span class="keyword parmname">state</span> are:</p>
                <ul class="ul bulletList">
                  <li class="li">
                    <samp class="codeph nolang">RUN</samp>—(Default)
                    The subscription is running and delivering new events to the
                    Pub/Sub API client.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">STOP</samp>—The
                    subscription is stopped. No events are delivered to the
                    Pub/Sub API client during this state and the previously
                    committed Replay ID is deleted.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">PAUSE</samp>—Reserved
                    for internal use.
                  </li>

                </ul>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d651254e100" data-title="Field Name"><span class="keyword parmname">topicName</span></td>

              <td class="entry" headers="d651254e103" data-title="Field Type">string</td>

              <td class="entry" headers="d651254e106" data-title="Description">The topic name of the platform event or change event or the
                channel name of a custom platform event channel or custom or
                standard change data capture channel. The topic name can be one of
                the following values.<ul class="ul bulletList">
                  <li class="li">For a platform event—<samp class="codeph nolang">/event/EventName__e</samp>
                  </li>

                  <li class="li">For a custom platform event channel—<samp class="codeph nolang">/event/CustomPEChannel__chn</samp>
                  </li>

                  <li class="li">For the standard change event channel—<samp class="codeph nolang">/data/ChangeEvents</samp>
                  </li>

                  <li class="li">For a change event (replace <samp class="codeph nolang">Object</samp> with the object name)—<samp class="codeph nolang">/data/ObjectChangeEvent</samp>.
                    For example, for Account, it’s <samp class="codeph nolang">/data/AccountChangeEvent</samp>.</li>

                  <li class="li">For a custom change event channel—<samp class="codeph nolang">/data/CustomChangeChannel__chn</samp>
                  </li>

                </ul>
              </td>

            </tr>

            <tr>
              <td class="entry" headers="d651254e100" data-title="Field Name"><span class="keyword parmname">version</span></td>

              <td class="entry" headers="d651254e103" data-title="Field Type">string</td>

              <td class="entry" headers="d651254e106" data-title="Description">Reserved for internal use.</td>

            </tr>

          </tbody>

        </table>

## Declarative Metadata Sample Definition

The following is an example of a ManagedEventSubscription component with the file name My\_Managed\_Subscription.managedSubscription.

<?xml version="1.0" encoding="UTF-8"?>
<ManagedEventSubscription xmlns="http://soap.sforce.com/2006/04/metadata">
    <defaultReplay\>LATEST</defaultReplay\>
    <errorRecoveryReplay\>LATEST</errorRecoveryReplay\>
    <label\>My Managed Subscription</label\>
    <state\>RUN</state\>
    <topicName\>/event/Order\_Event\_\_e</topicName\>
</ManagedEventSubscription\>

The following is an example package.xml that references the previous definition.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types\>
        <members\>My\_Managed\_Subscription</members\>
        <name\>ManagedEventSubscription</name\>
    </types\>
    <version\>68.0</version\>
</Package\>

## Wildcard Support in the Manifest File

This metadata type supports the wildcard character \* (asterisk) in the package.xml manifest file. For information about using the manifest file, see [Deploying and Retrieving Metadata with the Zip File](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/file_based_zip_file.htm "The deploy() and retrieve() calls are used to deploy and retrieve a .zip file. Within the .zip file is a project manifest (package.xml) that lists what to retrieve or deploy, and one or more XML components that are organized into folders.").