--- title: "Rocket Chat Retention Policy Guide" slug: "retention-policy" description: "Configure retention policies in Rocket Chat. Ensure secure communications, compliance, and data governance." updated: 2026-10-09T23:02:21Z published: 2026-10-09T23:02:21Z canonical: "docs.rocket.chat/retention-policy" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.rocket.chat/llms.txt > Use this file to discover all available pages before exploring further. # Retention Policy Settings By default, messages in Rocket.Chat are never deleted. If you need to remove older messages, you can use the retention policy feature to clear up your workspace or for regulatory reasons. Retention policy in Rocket.Chat enables you to automatically delete old messages and files in your workspace based on custom rules. In the database, the retention policy deletes data from the `rocketchat_message` collection, which is responsible for storing all chat messages. **Deleted messages are kept in the** `rocketchat__trash` **collection for 30 days before they are permanently removed. Uploaded files are not kept.** See [Deleted data and recovery](/v1/docs/retention-policy#deleted-data-and-recovery) section for more details. > [!NOTE] > Omnichannel messages are not governed by the retention policy settings; they have separate controls. Refer to the [Privacy Notice for Omnichannel](/v1/docs/privacy-notice-for-omnichannel) for details. ## Required permissions Retention policies depend on two permissions: - `edit-privileged-setting`: It is required to set a **global** retention policy. - `edit-room-retention-policy`: It is required to set a **per-room** retention policy. By default, these permissions are assigned to administrators only. To assign these permissions to a user (for example, channel owners), go to **Manage → Workspace → Permissions**. Under the role you want to edit, select the permissions listed above. Now, users with that role have access to set retention policies. See [Roles in Rocket.Chat](/roles-in-rocketchat) to know more. ## Configure retention policy To set up a retention policy on your workspace, go to **Manage → Workspace** → **Settings → Retention Policy**. | Field | Description | | --- | --- | | **Enabled** | Enable this option to configure the retention policy for your workspace. | | **Timer Precision** | Select how often the deletion script should run. Setting this to a more precise value makes channels with fast retention timers work better, but might cost extra processing power on large communities. When your policies have a long lifetime or if you are not concerned about precision, you can lower this to save processing power. | | **Use Advanced Retention Policy Configuration** | Enable this option to use an advanced retention policy configuration, which provides more granular control of the pruning frequency. If you enable this option, you can modify the **Use Advanced Retention Policy Cron** setting. Define how often the prune timer should run with a [cron job expression](https://crontab.guru/#*/5_5_8_3). Setting this to a more precise value makes channels with fast retention timers work better, but might cost extra processing power for large communities. | > [!NOTE] > When the **Use Advanced Retention Policy Configuration** setting is enabled, the policy follows the cron job expression set in **Use Advanced Retention Policy Cron**. If it's disabled, the policy follows the **Timer Precision** settings. ## Retention policy types There are two levels of retention policies in Rocket.Chat: **global policies** (enforced across the entire workspace) and **per-room policies** (implemented in specified rooms). The following sections guide you through the configuration details of each type. ### Global retention policies > [!CAUTION] > Tweaking these settings without extreme caution can **destroy** **all message history across your server**. Read this entire section **before** you enable this feature. To update the **Global Policies** settings, go to **Manage → Workspace** → **Settings → Retention Policy → Global Policies**. The policy is split into three parts: one for all channels, one for all private groups, and one for all direct messages. Each type has two options: - **Prune in channels/private groups/direct messages**: Enabling this option applies the global retention policy to this type of message. For example, if you only wish to prune messages in private groups, enable the option for private groups and disable the others. - **Prune messages older than in channels/private groups/direct messages:** This option sets the time period (in days, hours, or minutes) for automatically deleting messages. For instance, entering `30` and selecting `days` will delete all messages older than 30 days. Similarly, entering `48` and selecting `hours` or `minutes` will remove messages older than 48 hours or 48 minutes, respectively. Furthermore, other options allow you to specify how the policy works: - **Do not prune pinned messages**: If enabled, pinned messages are not deleted. For example, when you pin a few messages with essential links, these messages stay intact. - **Only delete files**: If enabled, messages are not deleted, but files are. They are replaced by a simple `File removed by automatic prune` message. When combined with **Do not prune pinned messages**, only unpinned files are deleted. - **Do not prune discussion messages:** If enabled, discussion messages are not deleted. All discussions in your workspace remain intact. - **Do not prune Threads:** When enabled, threads are not deleted. All threads in your workspace remain intact. Depending on your selected settings, messages and files can be deleted or remain in your workspace. ### Per-room retention policies > [!CAUTION] > Tweaking these settings without extreme caution can **destroy** **all message history across your server**. Read this entire section **before** you enable this feature. To enable an automated retention policy in a room that overrides the global retention policy, - Click the **Room Information** icon of the room and select the **Edit** button. - Go to **Prune**. - **Automatically prune old messages**: Enable this option to prune old messages automatically. - **Override global retention policy**: When enabled, you can define a retention policy for the room that overrides the global policy. - **Maximum message age in days**: This option sets the time period (in days) for automatically deleting messages. For instance, entering 30 will delete all messages older than 30 days, while entering 365 will remove messages older than a year. - **Exclude pinned messages**: When enabled, do not prune pinned messages. - **Prune files only, keep messages**: When enabled, remove only files during pruning and keep the messages. - **Do not prune threads**: Messages in threads are not deleted if enabled. - Click **Save**. Users can determine if a room’s messages will be pruned by scrolling to the top of the message history or opening the room info. A warning is displayed if an automated policy (global or per-room) is present. For example, `Messages older than 3 months will be pruned on June 26, 2012 at 11:30 PM` or `Files older than 3 months will be pruned on May 13, 2020 at 11:50 PM`. Watch the video to learn how the global and per-room retention policies work: [Embedded content](https://www.youtube.com/embed/cxkr888648s) --- ## Deleted data and recovery When Rocket.Chat deletes a room, message, subscription, user, or certain other records, it removes the record from its collection immediately. It also stores a full copy in the `rocketchat__trash` collection, with two extra fields: `__collection__`, which records the source collection, and `_deletedAt`, which records the deletion time. A TTL index permanently removes these copies 30 days after `_deletedAt`. Expiry is approximate, because MongoDB runs TTL cleanup periodically rather than at an exact moment. This also applies to messages removed by a retention policy. They remain in the database for up to 30 days after the policy deletes them. ### What the trash does not cover Uploaded files and avatars are not copied to the trash. When a room is deleted, its files are removed from the configured file storage, and their upload records are deleted permanently. Rocket.Chat cannot restore them. Recovery depends on your own backups or on storage-level features such as bucket versioning. ### **Before restoring data** - Take a database backup first. - Restored messages keep their original file references. If those files were deleted, the attachment links will return a 404 error. - The trash holds every deletion from the last 30 days across the whole workspace, not only the incident. Limit a restore to the affected room (`rid`) and to a `_deletedAt` window around the incident, so you don't bring back data that was removed on purpose. --- ## Prune messages manually You can also manually prune selected messages in a room as needed, outside of the automated retention policies, by following these steps: - Go to the kebab menu in the room header. - Click **Prune Messages** and update the following options: - **Newer than**: Set a date and time to prune messages newer than the selected moment. - **Older than**: Set a date and time to prune messages older than the select moment. - **Only prune content from these users**: Select users to delete their messages. Leave empty to prune everyone's content. - **Inclusive**: If you check the inclusive checkbox, messages sent on and between **Newer than** and **Older than** dates are deleted (messages are deleted between and including those dates). If you don't check the inclusive checkbox, messages between Newer than and Older than dates are deleted, and the messages sent on those dates are not deleted. - **Do not prune pinned messages**: Pinned messages are not deleted if enabled. For example, if you pinned a few messages with important links, they stay intact. - **Do not prune discussion messages**: If enabled, messages in the discussions are not deleted. - **Do not prune threads**: If enabled, messages in the threads are not deleted. - **Only remove the attached files, keep messages**: If enabled, messages are not deleted, but files are. They are replaced by a simple File removed by automatic prune message. When used together with Exclude pinned messages, only unpinned files are deleted. - Click **Prune**. The selected messages are deleted immediately based on the specified criteria. For a demonstration, you can watch the video below to learn how to prune messages manually: [Embedded content](https://www.youtube.com/embed/7EVHq431Xc0)