# 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. Click **Settings**.
3. From the **Settings** menu, locate the **Workspace** section, then click **Entities**.
4. Click **General**.<br>

   <div align="left" data-with-frame="true"><figure><img src="/files/yO0ZIYQ1sbkpLnXavJK8" alt="The &#x27;General&#x27; tab within Cortex settings." width="188"><figcaption></figcaption></figure></div>
5. On the **General** page, scroll to the **Auto-archiving entities by type** section.
6. Toggle on one or both 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.
     * This option is recommended if you use a monorepo.

   <div align="left" data-with-frame="true"><figure><img src="/files/DfXVTCtDAXuv0mDFoNu2" alt="The options to enable auto-archiving in Cortex."><figcaption></figcaption></figure></div>

{% 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).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.cortex.io/ingesting-data-into-cortex/entities-overview/entities/archiving-entities/auto-archive.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
