> ## Documentation Index
> Fetch the complete documentation index at: https://launchdarkly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Subscribing to notifications

export const FlagGate = ({flag, match = true, fallbackValue = false, fallback = null, tocAnchors = [], children}) => {
  const [value, setValue] = useState(fallbackValue);
  useEffect(() => {
    let cancelled = false;
    const evaluate = () => {
      window.ldClient.waitUntilReady().then(() => {
        if (!cancelled) setValue(window.ldClient.variation(flag, fallbackValue));
      });
    };
    if (window.ldClient) {
      evaluate();
    } else {
      const onReady = () => evaluate();
      window.addEventListener('ld-ready', onReady);
      return () => {
        cancelled = true;
        window.removeEventListener('ld-ready', onReady);
      };
    }
    return () => {
      cancelled = true;
    };
  }, [flag, fallbackValue]);
  const shown = value === match;
  useEffect(() => {
    if (!tocAnchors.length) return;
    const entries = tocAnchors.map(anchor => document.querySelector(`#table-of-contents-content a[href$="#${anchor}"]`)).filter(Boolean).map(link => link.closest('li') || link);
    entries.forEach(entry => {
      entry.hidden = !shown;
    });
    return () => {
      entries.forEach(entry => {
        entry.hidden = false;
      });
    };
  }, [shown, tocAnchors.join(',')]);
  return shown ? children : fallback;
};

<View title="Developer" />

<View title="Federal docs" />

<View title="EU docs" />

<View title="Federal docs">
  <Danger>
    **This feature is not available on LaunchDarkly's federal instance**

    To learn more, read <a href="/docs/home/infrastructure/federal">LaunchDarkly in federal environments</a>.
  </Danger>
</View>

This topic explains how to subscribe to notifications in Slack channels. You can receive notifications when resources are created, updated, deleted, or are ready for removal.

It can be useful to let an entire channel know when a flag changes or is ready to remove. You can receive notifications when someone toggles a flag's targeting on or off, when someone creates new resources in a certain environment, and when flags are ready for removal from your codebase.

## Subscribe to notifications

You can subscribe to updates for [flags](/docs/home/flags/create), [metrics](/docs/home/metrics), [projects](/docs/home/account/project), or [environments](/docs/home/account/environment). When someone updates a resource or when an [alert](/docs/home/observability/alerts) is triggered, either directly in LaunchDarkly or through the Slack app, LaunchDarkly sends a notification to all channels subscribed to updates for that resource. Subscriptions must have a project, and can optionally include parameters like a specific environment, flag name, status, or tag that will filter the notifications you receive.

There are two ways to create a subscription to flag notifications: the Slack modal workflow or the `/launchdarkly subscribe` command. Subscriptions created through the modal must specify a project and environment.

### Subscribe using the modal

To subscribe using the modal:

1. Open the Slack channel you want notifications in.

* After you [set up the Slack app](/docs/integrations/slack/setting-up), you can subscribe to notifications in any public Slack channel.
* If you want notifications in a private Slack channel, you must add the Slack app to the channel explicitly. Click the **Integrations** tab in the private channel. Then select **Add app**.

2. Type `/launchdarkly subscribe` in your Slack client's text bar and press **Enter**. The "Create subscription" dialog appears.

<Frame caption="The create subscription dialog.">
  <img src="https://mintcdn.com/launchdarkly/6toei-i72Mf97ImT/images/__third_party/slack-project-select-modal.png?fit=max&auto=format&n=6toei-i72Mf97ImT&q=85&s=5ad0cbb3b57976d65c81c3791dfab033" alt="The create subscription dialog." width="1038" height="516" data-path="images/__third_party/slack-project-select-modal.png" />
</Frame>

3. Select the project and environment you'd like to receive notifications for.
4. (Optional) You can further refine your subscription defining specific flag, status, action, or tag. You can use `*` as a wildcard in your flag key. You'll only receive updates for flags that match these parameters.

<Frame caption="The modal to select subscription parameters.">
  <img src="https://mintcdn.com/launchdarkly/6toei-i72Mf97ImT/images/__third_party/slack-subscription-parameter-select-modal.png?fit=max&auto=format&n=6toei-i72Mf97ImT&q=85&s=877691288f12711ec66e05e595448091" alt="The modal to select subscription parameters." width="1026" height="1252" data-path="images/__third_party/slack-subscription-parameter-select-modal.png" />
</Frame>

4. Click **Preview** to view the list of flags that your parameters include.
5. Click **Create subscription** to subscribe the channel to flag notifications. A confirmation message appears in the channel after you close the dialog.

### Subscribe using the command

There are two ways to subscribe to updates using the command: with keyword arguments (recommended), or with positional arguments. To view more information and examples of the subscribe command, run `/launchdarkly help subscribe` in a channel that the LaunchDarkly bot is in.

#### Subscribe with keyword arguments

You can use keyword arguments to create a subscription with any combination of parameters. At least one parameter is required.

Here's how:

1. Open the Slack channel you want notifications in.

* After you [set up the Slack app](/docs/integrations/slack/setting-up), you can subscribe to notifications in any public Slack channel.
* If you want notifications in a private Slack channel, you must add the Slack app to the channel explicitly. Click the **Integrations** tab in the private channel. Then select **Add app**.

2. Run `/launchdarkly subscribe` and pass in any combination of the following arguments:
   * `-p` or `--project=`
   * `-e` or `--environment=`
   * `-f` or `--flag_key=`
   * `-s` or `--status=`
   * `-a` or `--action=`
   * `-t` or `--tag=`
3. Press **Enter**.

For example, the following command creates a subscription for all flags in the `qa` environment of the `chatbot` project, with status `active` and tag `production`:

<CodeGroup>
  ```bash title="Example subscription with keyword arguments" lines wrap theme={null}
  /launchdarkly subscribe -p chatbot -e qa -s active -t production
  ```
</CodeGroup>

### Subscribe with positional arguments

You can use positional arguments to create a subscription for a single flag. You must provide all three arguments.

Here's how:

1. Open the Slack channel you want notifications in.

* After you [set up the Slack app](/docs/integrations/slack/setting-up), you can subscribe to notifications in any public Slack channel.
* If you want notifications in a private Slack channel, you must add the Slack app to the channel explicitly. Click the **Integrations** tab in the private channel. Then select **Add app**.

2. Run `/launchdarkly subscribe` and provide in order the project, environment, and flag key of the flag you would like to subscribe to.
3. Press **Enter**.

For example, the following command creates a subscription for the `chat-response` flag in the `qa` environment of the `chatbot` project:

<CodeGroup>
  ```bash title="Example subscription with positional arguments" lines wrap theme={null}
  /launchdarkly subscribe chatbot qa chat-response
  ```
</CodeGroup>

## Manage subscriptions

You can view and remove subscriptions in a Slack channel using the `/launchdarkly list` command:

1. Open the Slack channel where you would like to remove notifications.
2. Type `/launchdarkly list` and press **Enter**. A list of subscriptions for the channel appears.
3. Locate the subscription you wish to remove from the channel.
4. Click **Remove**.

<Frame caption="The output of the `/launchdarkly list` command.">
  <img src="https://mintcdn.com/launchdarkly/6toei-i72Mf97ImT/images/__third_party/slack-manage-subscriptions.png?fit=max&auto=format&n=6toei-i72Mf97ImT&q=85&s=72a245e147c46507096e748c6b30de79" alt="The output of the /launchdarkly list command." width="1360" height="762" data-path="images/__third_party/slack-manage-subscriptions.png" />
</Frame>

## Notification information

Flag notifications include the following information:

* The name of the person who made the change
* The name of the flag
* The environment, project, and key of the flag
* A comment about the change, if applicable

To display additional information about the flag change, click **View details**.

The table below explains the different subscription parameters:

<table>
  <thead>
    <tr>
      <th>Subscription parameters</th>
      <th>Required</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td>Project</td>
      <td>Required</td>

      <td>
        All subscriptions must include a project and environment to get flag notifications for.
      </td>
    </tr>

    <tr>
      <td>Environment</td>
      <td>Optional, but required in modal creation</td>

      <td>
        All subscriptions must include a project and environment to get flag notifications for.
      </td>
    </tr>

    <tr>
      <td>Flag key</td>
      <td>Optional</td>

      <td>
        A flag key to get notifications for, which can begin or end with a wildcard \* to include all matching flag keys.
      </td>
    </tr>

    <tr>
      <td>Status</td>
      <td>Optional</td>

      <td>
        Filter by flag status. Available statuses are:

        <ul>
          <li>Any</li>
          <li>Active</li>
          <li>Inactive</li>
          <li>Archived</li>
          <li>Launched</li>
          <li>New</li>
        </ul>

        To learn more, read [Flag statuses and lifecycle stages](/docs/home/flags/flag-status).
      </td>
    </tr>

    <tr>
      <td>Action</td>
      <td>Optional</td>

      <td>
        Filter by action. Available actions are:

        <ul>
          <li>Any</li>
          <li>Created</li>
          <li>Updated</li>
          <li>Deleted</li>
          <li>Ready for removal</li>
          <li>New</li>
        </ul>
      </td>
    </tr>

    <tr>
      <td>Flag tag</td>
      <td>Optional</td>

      <td>
        Filter by a list of all flag tags. Does not include other types of tags, such as segment tags.
      </td>
    </tr>
  </tbody>
</table>

<FlagGate flag="docs-enable-slack-app-stale-flags" tocAnchors={["receive-alerts-when-flags-are-ready-to-remove"]}>
  ## Receive alerts when flags are ready to remove

  You can subscribe to notifications when it's time to remove flags from code. Removing from code is a necessary step before archiving flags. To learn more, read about [Flag statuses and lifecycle stages](/docs/home/flags/flag-status).

  To set up a "ready to remove" flag alert, create a subscription that includes the flag you want to receive the alert for. To learn how to create a subscription, read [Subscribe to flag notifications](#subscribe-to-notifications).
</FlagGate>

## Receive approval request notifications

<Note>
  **Approvals is available to customers on select plans**

  Approvals are only available to customers on select plans. To learn more, [read about our pricing](https://launchdarkly.com/pricing/). To upgrade your plan, [contact Sales](https://launchdarkly.com/contact-sales/).

  Requiring approvals by environment is available only to customers on an Enterprise plan. To learn more, read [Configuring approvals for an environment](/docs/home/releases/approval-config).
</Note>

If your organization uses release management tools and the Slack app, you receive a direct message in Slack when someone requests an approval from you, or when an approval request you made is approved, denied, or receives a comment.

You cannot interact with an approval from these notifications. They are indicators that you should log into LaunchDarkly and review your approval requests.

To learn more about approval requests, read [Approvals](/docs/home/releases/approvals).
