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

# Archiving flags

> This topic explains how to clean up flags you no longer need.

> For the complete documentation index, see [llms.txt](/llms.txt). For the full documentation snapshot, see [llms-full.txt](/llms-full.txt).

## Overview

This topic explains how to clean up flags you no longer need. LaunchDarkly helps you identify flags that you can remove from your code, then prompts you to archive these flags. Archiving a flag removes it from your **Flags** list in LaunchDarkly, without deleting it.

Cleaning up your flags is an important part of the [flag lifecycle](/home/flags/flag-status/#flag-lifecycle-stages), and critical to helping reduce the [technical debt](/guides/flags/technical-debt) that you may accumulate as you use flags throughout your organization.

## About archiving

LaunchDarkly considers flags ready to archive when they meet all of the criteria specified in the [flag lifecycle settings](/home/flags/flag-lifecycle-settings).

When you archive a flag in LaunchDarkly, you should also remove the flag from your code. If your application evaluates an archived flag, LaunchDarkly serves the flag's [fallback value](/home/getting-started/vocabulary#fallback-value). This means it is crucial to remove all references to a flag from your code before you archive the flag. LaunchDarkly's code references feature can help you quickly identify all the places a flag is referenced in your code. To learn more, read [Code references](/home/flags/code-references).

When you are sure a flag is no longer needed, you can permanently remove it. Delete an archived flag from the **Flags** list. To learn more, read [Deleting flags](/home/flags/delete).

<Card icon="link">
  You can also use the REST API: [Delete feature flag API](/api-reference/feature-flags/delete-feature-flag)
</Card>

<Note title="Archiving a flag removes it from every environment in your project">
  All flags exist in every environment for a project, but often only a few environments matter for your organization's production processes. LaunchDarkly recommends archiving all flags that are ready to archive in your [critical environments](/home/account/environment#critical-environments). However, archiving a flag will remove it from every environment in the project. Be certain you can archive a flag without any unintended impact.
</Note>

## Archive flags

LaunchDarkly automatically determines if a flag is [ready to archive](/home/flags/flag-status) by checking it against the criteria specified in [flag lifecycle settings](/home/flags/flag-lifecycle-settings). You can view flags that are ready to archive from the **Flags** list.

Here's how:

1. Navigate to your **Cleanup** shortcut.
2. A list of flags that are ready to archive appears. Each flag has a "Ready to archive" indicator.
3. Click the indicator for the flag you want to archive. The "Ready to archive" dialog appears:

<Frame caption="The &#x22;Ready to archive&#x22; dialog.">
  ![The "Ready to archive" dialog.](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/6d6a4e62359cc6a829f1525c3bc0b27898ffde61207a8f975c59aa8ea37b8301/assets/images/auto/ready-to-archive-dialog.auto.png)
</Frame>

4. Review the archive checks to confirm that the flag is ready to archive.
5. Enter a **Comment** to let other members in your organization know why you are archiving the flag.
6. Click **Archive**.

The flag is archived and removed from the **Flags** list. You can find it in the archived **Flags** list. To learn more, read [View and restore flags](#view-and-restore-flags).

You can also customize the **Cleanup** shortcut. For example, you could update it to include only flags that are ready to archive and are also maintained by you or your team. To learn more about shortcuts, read [Save shortcuts to filtered flags lists](/home/flags/list#save-shortcuts-to-filtered-flags-lists).

<Tip title="Review &#x22;Needs code removal&#x22; as well">
  To filter for flags that are ready for code removal, navigate to the **Flags** list, open the **Filter** menu, and use the Lifecycle filter "Needs code removal." To learn more about code references, read [Code references](/home/flags/code-references).
</Tip>

You can also find flags that are ready to archive on the **Flags** list:

1. From the **Flags** list, open the **Filters** menu.
2. Under Lifecycle, select **Ready to archive**:

<Frame caption="The project-level Filters menu, with &#x22;Ready to archive&#x22; selected.">
  ![The project-level Filters menu, with "Ready to archive" selected.](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/0d2bffbc4cafbe35dea3fcd0446feb7336642af93e01a2385786cb5db5f49293/assets/images/auto/flags-list-filter-ready-to-archive.auto.png)
</Frame>

You can also archive a flag from its right sidebar.

<Accordion title="Expand how to archive a flag from its right sidebar">
  Here's how to archive a flag from its right sidebar:

  1. Navigate to the **Flags** list and open the flag you wish to archive.

  2. Click the **three-dot** overflow menu in the right sidebar.

  3. Select **Archive**. The "Archive this flag?" panel appears.
     * If the flag has dependencies, you cannot archive it. To learn how to resolve flag dependencies, read [Resolve dependencies](#resolve-dependencies).

  4. A warning displays for any critical environments in which the flag is not ready to archive. Click on the warning message to view more information about why the flag is not ready to archive:

  <Frame caption="A flag with dependencies.">
    ![A flag with dependencies.](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/42f1350af7d38d5fceea9cca4ce18fd9f1e0b2d23e65ef0cf59f4210d48b0a5f/assets/images/__LD_UI_no_test/flag-archive-warnings.png)
  </Frame>

  5. Enter the name or key of the flag to confirm.

  6. Click **Archive**.

  The flag is archived and removed from the **Flags** list. You can find it in the archived **Flags** list. To learn more, read [View and restore flags](#view-and-restore-flags).
</Accordion>

<Note title="Archived flags serve their fallback values if requested">
  If end users request a flag after you archive it, the flag value that returns is the [fallback value](/home/getting-started/vocabulary#fallback-value) you defined in code.
</Note>

### Resolve dependencies

There are three types of flag dependencies. These align with the archive checks LaunchDarkly runs to confirm whether a flag is ready to archive:

* The flag is a prerequisite for other dependent flags
* The flag is serving multiple variations
* The flag has been requested in the last seven days

You cannot archive a flag that is a prerequisite for other flags. You must remove the flag as a prerequisite before you can archive it. Even if the flag's dependent flags themselves are archived, the dependency will still block you from archiving the prerequisite flag. If you attempt to archive a prerequisite flag, LaunchDarkly prevents you from doing so.

The other two dependencies will not stop you from archiving a flag, but we recommend resolving them before you archive it.

To learn more about archive checks, read [Description of checks](/home/releases/flag-health#description-of-checks).

Here is a screenshot of the "Archive this flag?" panel:

<Frame caption="A flag with dependencies that do not block it from being archived.">
  ![A flag with dependencies that do not block it from being archived.](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/ff1d92b7d7bb46e6ec3d51ddac61b2e00ebd57882bd7d7e075d792809dafa5f9/assets/images/auto/flag-archive-mixed-dependencies.auto.png)
</Frame>

## View and restore flags

By default, the **Flags** list shows live flags only.

To view archived flags, click **Filters** from the **Flags** list and select "Archived" or "Deprecated" under "Lifecycle":

<Frame caption="The Flags list Filters, with the lifecycle options shown.">
  ![The Flags list Filters, with the lifecycle options shown.](https://files.buildwithfern.com/https://launchdarkly.docs.buildwithfern.com/docs/755510960be3c1144a4b2f6c9576bef09c0f6991b474d9b5369049d332333824/assets/images/auto/flags-list-filter-lifecycle-highlighted.auto.png)
</Frame>

To restore an archived flag:

1. Navigate to the **Flags** list.
2. Click **Filters**. In the "Lifecycle" section, click "Archived." The archived flag list appears.
3. Click a flag name to open the flag you wish to restore.
4. Click the **three-dot** overflow menu in the right sidebar.
5. Select **Restore**. The "Restore flag" panel appears.
6. The panel shows you how the flag has been evaluated recently. Choose the environments your team or customers depend on to confirm that restoring the flag will have no unexpected consequences.
7. Enter the name or key of the flag to confirm.
8. Click **Restore**. The flag appears in the live **Flags** list.

<Note title="Restoring or permanently removing a flag">
  When you restore a flag, it returns to evaluation like any other flag. Confirm that restoring it will not have any unintended impact.

  If a flag is archived and no longer in use, you can permanently [delete it](/home/flags/delete) from the **Flags** list.

  Deleting a flag is permanent, so make sure your application no longer references it before you delete it.
</Note>
