> For the complete documentation index, see [llms.txt](https://docs.cortex.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cortex.io/ingesting-data-into-cortex/entities-overview/entities/archiving-entities/auto-archive.md).

# Archiving entities automatically

Cortex automatically archives entities when they're no longer detected in your integrations, so your catalog stays in sync as entities come and go. For example, if AWS auto-hydrates your catalog, enabling auto-archive will archive any entities that are later deleted from AWS.

This article covers how auto-archival works and how to configure it.

{% hint style="success" %}
It's highly recommended to enable this feature to keep your data up-to-date.
{% endhint %}

Cortex checks every day at 7 a.m. UTC for any affected entities, and skips archiving if any errors are detected.

## Enabling auto-archive of entities

Users with the `Edit Settings` permission can enable the auto-archive entities feature.

1. From the main sidebar, click your avatar in the bottom-left corner.
2. Select **Settings**.
3. From the **Settings** menu, locate the **Workspace** section, then expand **Entities**.
4. Select the **General** tab.<br>

   <div align="left" data-with-frame="true"><figure><img src="/files/gqTIGRf1BfamP8Jj8ayU" alt="The &#x27;General&#x27; tab within Cortex settings." width="238"><figcaption></figcaption></figure></div>
5. On the **General** page, scroll to the **Auto-archiving entities by type** section.<br>

   <div align="left" data-with-frame="true"><figure><img src="/files/mTZFBMSpUcjGFCQesDoJ" alt="The &#x27;Auto-archiving entities by type&#x27; section." width="375"><figcaption></figcaption></figure></div>
6. Toggle on any or all of the following:
   * **Enable integration-based auto-archiving for new entity types by default**
     * Toggle on this setting if you want to enable the feature for integration-based archiving. Cortex automatically archives and unarchives entities based on their existence in a third-party integration.
     * Cortex checks for a deleted or archived repo in your integration. To prevent an entity from being unarchived, make sure you have deleted the associated repo. The entity is removed the next time the archival sync runs.
     * This option is recommended if you use microservices that all live in different repos.
   * **Enable GitOps based auto-archiving for new entity types by default**
     * Toggle on this setting if you want to enable the feature for GitOps-based archiving. Cortex automatically archives entities if their corresponding YAML file is deleted.
     * If the file is moved rather than deleted, it is not archived from Cortex. Cortex checks for files that have been deleted.
   * **Auto-archive monorepo entities**
     * When enabled, if a monorepo is archived or unarchived, all entites in Cortex relating to that repo are automatically archived or unarchived.

{% hint style="info" %}
An entity's `x-cortex-tag` cannot be overwritten; attempting to update the `x-cortex-tag` value via GitOps creates a new entity. The entity only automatically archives if its original YAML file no longer exists in your Git environment.

To change an entity's `x-cortex-tag`, you must archive or delete the entity, then create a new entity with the desired tag.
{% endhint %}

## Enabling auto-archive per entity type

Users with the `Edit Settings` permission can enable auto-archive per entity type.

Below the auto-archive setting, each entity type (default and custom) is listed with its own toggle, so you can enable auto-archival selectively per type.

<div align="left" data-with-frame="true"><figure><img src="/files/vi4xOtd5IhgLlkoMXdlE" alt="Enable auto archive per entity type."><figcaption></figcaption></figure></div>

## Triggering an entity sync

Users need the `Edit Catalog` permission, combined with either:

* `Edit Domains`, `Edit Teams`, or `Edit Services` (depending on the entity type being archived), OR
* `Edit All Catalog`, which covers every entity type.

Deleted entities appear in the Entities list until the next time the auto-archival sync runs. You can also manually trigger the sync.

1. From the main sidebar, expand **Catalogs**, then select **All entities**.
2. In the upper right corner, click **Import entities**.
3. Select **Import discovered entities**.
4. Select an integration.\
   The **Select entities to import** window opens.
5. Click **Sync entities**.

## Troubleshooting and FAQ

**Why is an entity unexpectedly re-appearing after it's been archived?**

If you are using the integration-based auto-archiving, Cortex is checking whether the entity exists in your third-party integration. When Cortex runs the background sync for entity discovery, if the repo connected to that entity still exists, Cortex will un-archive the entity. To prevent un-archival, you can either delete the associated repo, or you can use the GitOps-based auto-archiving instead.

**Why is an entity still appearing after I deleted the YAML file for it or deleted the associated repo?**

The auto-archival feature runs once a day at 7 a.m. UTC. The entity appears until the next time the auto-archival sync runs or until you [manually trigger the sync](#trigger-an-entity-sync).
