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

# Data Retention

> Automatically delete old observability data based on configurable retention policies

ABV accumulates data continuously, but privacy principles and regulations (GDPR, CCPA) require "data minimization"—keeping only data necessary for legitimate purposes. Storing old traces with personal information longer than needed violates this principle.

# How Data Retention Works

ABV's retention system automatically deletes old data based on configurable policies:

<Steps>
  <Step title="Configure retention policy" icon="calendar">
    Set retention period at the project level in Project Settings. Specify the number of days to retain event data (traces, observations, scores, media assets).

    **Minimum retention**: 3 days (prevents accidental immediate deletion)
    **Default**: Indefinite (no automatic deletion until you configure retention)

    Only project Owners and Admins can configure retention policies (requires appropriate RBAC permissions).
  </Step>

  <Step title="Nightly deletion process" icon="moon">
    ABV runs automated deletion nightly (scheduled background process). The system identifies data older than the retention period and deletes it permanently.

    **Deletion is irreversible**: Once deleted during retention enforcement, data cannot be recovered. Export important data before configuring aggressive retention policies.
  </Step>

  <Step title="Age determination by entity type" icon="clock">
    ABV uses specific timestamp fields to determine age for each entity type:

    * **Traces**: `timestamp` field (when the trace was created)
    * **Observations**: `start_time` field (when the observation began)
    * **Scores**: `timestamp` field (when the score was created)
    * **Media Assets**: `created_at` field (when the asset was uploaded)

    If a trace is outside the retention window, all related entities (observations, scores, media) are deleted regardless of their individual timestamps.
  </Step>

  <Step title="Permanent deletion" icon="trash">
    Deleted data is permanently removed from all ABV storage (online databases, analytical data warehouses, backups). Data cannot be recovered after retention deletion.

    **Audit trail**: Retention deletions are logged in audit logs (immutable records showing automated deletion occurred, even though the deleted data itself is gone).
  </Step>
</Steps>

# Configuring Data Retention

## Via UI

<Steps>
  <Step title="Navigate to project settings" icon="gear">
    Open the project where you want to configure retention and go to **Project Settings** > **General**.
  </Step>

  <Step title="Find data retention section" icon="calendar-days">
    Scroll to the **Data Retention** section in the General settings page.
  </Step>

  <Step title="Set retention period" icon="input-numeric">
    Enter the number of days to retain data (minimum 3 days).

    **Examples**:

    * Development projects: 7-30 days
    * Production analytics: 90-365 days
    * Compliance-driven (HIPAA): 2190 days (6 years)
    * Financial compliance: 2555 days (7 years)
  </Step>

  <Step title="Save changes" icon="floppy-disk">
    Click **Save** to apply the retention policy. Retention enforcement begins with the next nightly deletion process.
  </Step>

  <Step title="Verify configuration" icon="check">
    Return to the Data Retention section to confirm the policy is saved and displayed correctly.
  </Step>
</Steps>

<Info>
  By default, ABV stores event data (traces, observations, scores, and media assets) **indefinitely**—no automatic deletion occurs until you configure a retention policy.
</Info>

## Via API

Configure retention policies programmatically using the Public API:

```bash theme={null}
PUT https://app.abv.dev/api/public/projects/{projectId}
Content-Type: application/json

{
  "dataRetentionDays": 90
}
```

**Authentication**: Requires API key with `project:update` permission (Owner or Admin roles).

**Parameters**:

* `dataRetentionDays`: Number of days to retain data (integer, minimum 3)
* Set to `null` or omit to disable retention (indefinite storage)

[API Reference →](/developer/platform/api-data-platform/public-api)

# What Gets Deleted

Retention policies affect these entity types:

<AccordionGroup>
  <Accordion title="Traces and Observations" icon="chart-network">
    **Traces**: Complete LLM interaction records with inputs, outputs, costs, latency, and metadata.

    **Observations**: Steps within traces—individual LLM calls, tool uses, retrieval operations, and other observations.

    **Age determination**: Traces use the `timestamp` field (trace creation time). When a trace exceeds the retention period, it and **all related observations** are deleted, regardless of observation `start_time`.

    **Why this matters**: If you set 90-day retention, a 91-day-old trace with a recent observation (added as a correction) still gets deleted because the parent trace is old.
  </Accordion>

  <Accordion title="Scores and Evaluations" icon="star">
    **Scores**: Quality evaluations, user feedback, and annotations attached to traces.

    **Age determination**: Scores use the `timestamp` field (when the score was created).

    **Cascade deletion**: If the parent trace is deleted due to retention, all associated scores are deleted regardless of score age. Scores can also be deleted independently if they're older than retention and orphaned (parent trace already deleted).

    **Use case**: User provides feedback on a trace (creating a score). If the trace gets retention-deleted 90 days later, the score disappears too.
  </Accordion>

  <Accordion title="Media Assets" icon="images">
    **Media assets**: Images, audio files, or other media attached to traces (screenshots, generated images, audio recordings).

    **Age determination**: Media uses the `created_at` field (when the asset was uploaded to ABV).

    **Storage impact**: Media files can be large (images, audio). Aggressive retention for projects with heavy media usage significantly reduces storage costs.
  </Accordion>
</AccordionGroup>

**What does NOT get deleted**:

* **Prompts and prompt versions**: Managed separately, not affected by trace retention
* **Datasets and dataset items**: Curated collections for evaluation, retained independently
* **Audit logs**: Immutable compliance records, never deleted by retention policies
* **Project configurations**: Settings, integrations, API keys persist regardless of data retention
* **User accounts and memberships**: Access control data unaffected by retention

To retain data longer than your retention period, use the Public API to automate exports before it's deleted.

# Retention and Audit Logs

<Info>
  **Audit logs are NOT affected by data retention policies.** Audit logs are immutable and persist regardless of retention settings.
</Info>

**Why audit logs persist**:

* Compliance and regulatory requirements demand long-term audit trails
* Investigations may need historical activity records
* Retention deletions themselves are logged (audit trail of what was deleted and when)

**Pattern**: Even after retention deletes 90-day-old traces, audit logs showing who created those traces, when, and how they were deleted remain indefinitely (subject to audit log retention policies, if configured separately).

[Learn more about audit logs →](/developer/platform/administration/audit-logs)

# Next Steps

<CardGroup cols={2}>
  <Card title="Data Deletion" icon="trash" href="/developer/platform/administration/data-deletion">
    Manually delete specific data outside of retention policies
  </Card>

  <Card title="Export Data" icon="download" href="/developer/platform/api-data-platform/export-data-from-ui">
    Export data before retention deletes it for long-term archival
  </Card>

  <Card title="Blob Storage Export" icon="cloud" href="/developer/platform/api-data-platform/export-via-blob-storage">
    Set up continuous export to external storage for compliance and disaster recovery
  </Card>

  <Card title="Audit Logs" icon="file-shield" href="/developer/platform/administration/audit-logs">
    Verify retention deletions are occurring through audit log monitoring
  </Card>
</CardGroup>
