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

# Data Retention

> Automatically delete old operational logs and archived messages across your whole instance after a set number of days.

<Info>
  **Included with every self-managed instance.** This tab is part of [Whitelabel Setup](/self-host/whitelabel-setup/overview). Viewing it needs the `instance:view` permission; saving, previewing, and running a cleanup need `instance:edit`.
</Info>

## What is this?

The **Data Retention** tab lets an instance owner choose how long old operational data is kept before it is deleted automatically. Each type of data has its own switch and its own **Keep for (days)** window. The cleanup runs once a day, and changes apply from the next run. Deleted rows cannot be recovered.

Platform admins can also set their own, stricter windows for their own platform's data — see [Data Retention (Platform Settings)](/platform/settings/data-retention). A platform can never keep data longer than the instance window you set here.

\[SCREENSHOT: whitelabel-setup-data-retention-overview — The Data Retention tab showing the Enable automatic deletion switch, the last cleanup line, and the list of policies with their switches and Keep for (days) fields]

## What can I do here?

* Turn all automatic deletion on or off with **Enable automatic deletion** ("Turn off to stop every retention policy immediately.")
* Turn each policy on or off and set its **Keep for (days)** window
* See when the last cleanup ran, how many rows each policy deleted last time, and about how many rows are stored now
* Click **Preview** to see how many rows would be deleted, without deleting anything
* Click **Run now** to delete expired data immediately instead of waiting for the daily run
* Click **Save changes** to store your settings

## How to use it

### The policies

| Policy | What it covers | Default window | Minimum | On by default |
| - | - | - | - | - |
| **User activity logs** | Audit trail of actions taken by users in the app | 90 days | 7 days | Yes |
| **Contact activity logs** | Timeline events recorded on contacts | 180 days | 30 days | Yes |
| **Webhook relay logs** | Raw logs of forwarded Meta webhook deliveries | 1 day | 1 day | Yes |
| **Automation webhook triggers** | Raw payloads received by automation webhook triggers | 30 days | 7 days | No |
| **Automation step logs** | Per-step input and output of finished automation runs. Running automations are never touched | 30 days | 7 days | No |
| **Automation runs** | Finished automation run records and their step logs. Running automations are never touched | 30 days | 7 days | No |
| **Archived messages** | Messages already moved to the archive after 90 days, together with their stored media files (images, videos, audio, documents) | 730 days | 180 days | No |

The longest window you can enter is 3650 days.

### Change a policy

<Steps>
  <Step title="Open the tab">
    Go to **Platform → Instance → Whitelabel Setup** and open the **Data Retention** tab.
  </Step>

  <Step title="Choose what to delete">
    Turn a policy's switch on, then enter how many days to keep the data in **Keep for (days)**. The field is disabled while the policy or **Enable automatic deletion** is off, and shows the minimum ("Minimum 7 days").
  </Step>

  <Step title="Save">
    Click **Save changes**. The button is enabled only after you change something, and the toast says "Data retention settings saved".
  </Step>
</Steps>

### Preview before you delete

1. Save your changes first — **Preview** and **Run now** stay disabled while you have unsaved changes.
2. Click **Preview**. Under each policy you see "Preview: N rows would be deleted". Nothing is deleted.

### Run a cleanup now

1. Click **Run now**. **Run now** is disabled while **Enable automatic deletion** is off or you have unsaved changes.
2. In the **Delete expired data now?** dialog, read "Every enabled policy will permanently delete the rows older than its retention window. This cannot be undone." and click **Delete now**.
3. A toast says "Cleanup finished: N rows deleted", and each policy shows "Last run deleted N rows". The line at the top shows "Last cleanup:" with the date, plus "Platform policies removed N more rows." when platforms' own policies also deleted data.

\[SCREENSHOT: whitelabel-setup-data-retention-run-dialog — The Delete expired data now? dialog with the Cancel and Delete now buttons]

### Archived messages

**Archived messages** is the only policy that deletes customer conversation history, so it is marked "Customer data. Deleted rows and files cannot be recovered." and is off by default. Only messages that have already been moved to the archive are affected — live messages and conversations are never deleted by retention.

When you switch it on and click **Save changes**, a **Enable deletion of archived messages?** dialog asks you to confirm: once saved, the daily cleanup permanently deletes archived messages older than the chosen window, together with their stored media files. Use **Preview** first to see how much would be removed. Click **Enable and save** to continue.

The stored media files are deleted before the message rows. If the storage service fails to delete a file, the message is kept and tried again on the next run, so no file is left behind.

## Troubleshooting / Technical Notes

* **Preview and Run now are greyed out.** Click **Save changes** first — both stay disabled while you have unsaved changes. **Run now** is also disabled while **Enable automatic deletion** is off.
* **I can't type a smaller number of days.** Each policy has a minimum window (for example 7 days for **User activity logs**). The field shows it as "Minimum N days".
* **The Keep for (days) field is disabled.** Turn on **Enable automatic deletion** and the policy's own switch.
* **Nothing was deleted at the daily time.** Check **Enable automatic deletion** and the policy's switch. The cleanup is run by the **Log Retention Cleanup** job — make sure it is **Enabled** in [Cron Jobs](/self-host/whitelabel-setup/cron-jobs).
* **"Could not save data retention settings", "Could not preview data retention", or "Could not run data retention".** The server rejected the request — read the message under the title. If it says a retention run is already in progress, wait for it to finish and try again.
* **"Could not load data retention settings."** Reload the tab. You need the `instance:view` permission to see it.
* **A platform says its limit is lower than I expected.** Platforms may only choose a window equal to or shorter than the instance window for the same policy. Lowering the instance window also tightens platform windows.

## Related docs

* [Data Retention (Platform Settings)](/platform/settings/data-retention)
* [Cron Jobs](/self-host/whitelabel-setup/cron-jobs)
* [Whitelabel Setup overview](/self-host/whitelabel-setup/overview)
* [Instance Config](/self-host/whitelabel-setup/instance-config)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.