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

# Configuring dataset retention policies

> Add, edit, and manage retention policies from the dataset details page to automate data lifecycle cleanup

Retention policies automate data lifecycle management by removing data that has exceeded a specified age. You can configure retention policies directly from the dataset details page using the **Retention** tab.

<Info>
  This guide covers the UI-based configuration. You can also manage retention policies programmatically through the [Upsert Retention Policies API](/api-reference/datasets/upsert-retention-policies-for-a-dataset) or the [TypeScript SDK](/guides/sdk/managing-datasets).
</Info>

## Prerequisites

* A dataset you own or have write access to
* The dataset must be on an active [data plane](/concepts/primitives/data-planes)

## Understanding policy classes

Before configuring a policy, choose the right policy class for your use case. The available classes depend on your data plane:

| Policy class     | What it deletes                                            | Available on          |
| ---------------- | ---------------------------------------------------------- | --------------------- |
| **Row TTL**      | Individual rows whose event timestamp exceeds the interval | Snowflake data planes |
| **Snapshot TTL** | Old ingestion snapshots based on snapshot age              | AWS data planes       |
| **Table TTL**    | The entire dataset when table age exceeds the interval     | Both                  |

For a detailed explanation of each policy class, see [Dataset retention policies](/concepts/primitives/dataset-retention-policies).

<Warning>
  Deletions on Snowflake-based data planes are immediate with no grace period. AWS-based data planes apply a default 30-day grace period before permanent deletion.
</Warning>

## Adding a retention policy

<Steps>
  <Step title="Navigate to the dataset">
    Go to **My Data > Datasets** and select the dataset you want to configure.
  </Step>

  <Step title="Open the Retention tab">
    Select the **Retention** tab on the dataset details page. If no policies are configured, you see an empty state with a prompt to add your first policy.
  </Step>

  <Step title="Start a new policy">
    Click the **New Policy +** button. You can either:

    * Click the button directly to open the manual configuration drawer
    * Click the dropdown arrow to choose between **Ask Rosetta** (AI-assisted) or **Configure manually**
  </Step>

  <Step title="Configure the policy">
    In the configuration drawer, set the following:

    **Policy class** — Select the type of retention policy. The available options depend on your data plane.

    **Interval** — Choose a preset duration (30, 90, 180, or 365 days) or enter a custom [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) such as `P60D` for 60 days.

    **Class-specific settings:**

    <Tabs>
      <Tab title="Row TTL">
        **Event time clock** — Select the [Rosetta Stone](/concepts/rosetta-stone/overview) attribute that maps to a timestamp column in your dataset. The dropdown shows all `timestamptz` attributes mapped on the dataset. If you don't specify one, the system defaults to `nio_last_modified`.
      </Tab>

      <Tab title="Snapshot TTL">
        **Retention value** — Choose how snapshots are handled:

        * **Time-based** — Delete snapshots older than the interval
        * **Retain everything** — Keep all snapshots indefinitely
        * **Expire everything** — Remove all snapshots on each evaluation
      </Tab>

      <Tab title="Table TTL">
        **Clock type** — Choose how table age is measured:

        * **`created_at`** — Uses when the dataset was created
        * **`max_event_time`** — Uses the most recent event timestamp (requires a column reference)
        * **`static_time`** — Uses a fixed timestamp (requires a column reference)
      </Tab>
    </Tabs>

    **Status** — Toggle the policy on or off. Policies are enabled by default.
  </Step>

  <Step title="Save the policy">
    Click **Add Policy** to save. The policy appears in the retention policies table.
  </Step>
</Steps>

## Using Ask Rosetta to generate a policy

Instead of configuring a policy manually, you can describe what you want in plain language and let Rosetta generate the configuration for you.

<Steps>
  <Step title="Open Ask Rosetta">
    From the **Retention** tab, click the dropdown arrow on the **New Policy +** button and select **Ask Rosetta**.
  </Step>

  <Step title="Describe your policy">
    Enter a plain-language description of the retention behavior you want. For example:

    > Delete individual rows older than 90 days based on when the event occurred. Use the event\_timestamp attribute as the clock. Keep the policy enabled.

    You can also click **Use this prompt** to start with the sample prompt provided.
  </Step>

  <Step title="Generate and review">
    Click **Generate Policy**. Rosetta converts your description into a structured policy configuration and opens the configuration drawer with the values pre-filled. Review the settings and adjust if needed.
  </Step>

  <Step title="Save the policy">
    Click **Add Policy** to save the generated configuration.
  </Step>
</Steps>

<Tip>
  If you prefer to configure manually instead, click the **Manual** button in the Ask Rosetta dialog to switch to the manual configuration drawer.
</Tip>

## Editing a retention policy

To modify an existing policy, click the actions menu (three dots) on the policy row and select **Edit**. The configuration drawer opens in edit mode with the current settings pre-populated. You cannot change the policy class when editing — to switch policy classes, delete the existing policy and create a new one.

## Enabling or disabling a policy

You can toggle a policy on or off without deleting it:

* **From the table** — Click the toggle switch next to the policy class badge
* **From the actions menu** — Click the actions menu and select **Enable** or **Disable**

Disabled policies remain in the configuration but are not evaluated during retention runs.

## Deleting a retention policy

Click the actions menu on the policy row and select **Delete**. Confirm the deletion in the dialog that appears. This removes the policy configuration entirely — it does not undo any deletions that have already occurred.

## Related content

<CardGroup cols={2}>
  <Card title="Dataset retention policies" icon="clock-rotate-left" href="/concepts/primitives/dataset-retention-policies">
    Understand how retention policies work and when to use each policy class
  </Card>

  <Card title="Data planes" icon="database" href="/concepts/primitives/data-planes">
    Learn where your data physically resides and how it affects retention behavior
  </Card>

  <Card title="EXPIRE clause" icon="list-check" href="/nql/commands/create-materialized-view#expire">
    Set retention on materialized views using NQL
  </Card>

  <Card title="Upsert Retention Policies API" icon="code" href="/api-reference/datasets/upsert-retention-policies-for-a-dataset">
    Manage retention policies programmatically
  </Card>
</CardGroup>
