---
title: "Revisions Bin Cleaner"
description: "* The Revisions Bin stores revisions of deleted documents, ensuring they remain accessible."
url: "https://docs.ravendb.net/6.2/document-extensions/revisions/revisions-bin-cleaner"
version: "6.2"
---

# Revisions Bin Cleaner

> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

## Revisions Bin Cleaner

> **Note**
>
> - The [Revisions Bin](https://docs.ravendb.net/6.2/studio/database/document-extensions/revisions.md#revisions-bin) stores revisions of deleted documents, ensuring they remain accessible.
>
> - While you can manually delete these revisions directly from the Revisions Bin,  
>   you can also set up a cleaner task to remove them automatically. Learn more below.
>
> - In this page:
>   - [The revisions bin cleaner](#the-revisions-bin-cleaner)
>   - [Setting the revisions bin cleaner - from the Studio](#setting-the-revisions-bin-cleaner---from-the-studio)
>   - [Setting the revisions bin cleaner - from the Client API](#setting-the-revisions-bin-cleaner---from-the-client-api)
>   - [Syntax](#syntax)

## The revisions bin cleaner

Each entry in the [Revisions Bin](https://docs.ravendb.net/6.2/studio/database/document-extensions/revisions.md#revisions-bin) represents a "Delete Revision",
which is a revision that marks a document as deleted and provides access to the revisions that were created for the document before it was deleted.

> **Warning**
>
> When the cleaner removes a "Delete Revision" entry,  
> ALL the revisions associated with the deleted document are **permanently deleted**.

- The Revisions Bin Cleaner is configured with the following parameters:
  - **Frequency** - How often the cleaner runs.
  - **Entries age to keep** - The cleaner deletes revision entries older than this value.

- The cleaner task can be managed from:
  - The [Revisions bin cleaner view](#setting-the-revisions-bin-cleaner---from-the-studio) in the Studio
  - The [Client API](#setting-the-revisions-bin-cleaner---from-the-client-api).

- When working with a secure server:
  - Configuring the Revisions Bin Cleaner is logged in the [audit log](https://docs.ravendb.net/6.2/server/security/audit-log/audit-log-overview.md).
  - Deleting revisions is only available to a client certificate with a security clearance of [Database Admin](https://docs.ravendb.net/6.2/server/security/authorization/security-clearance-and-permissions.md#section) or higher.

## Setting the revisions bin cleaner - from the Studio

![Revisions bin cleaner view](https://docs.ravendb.net/assets/images/revisions-bin-cleaner-1bdc1689c42f6b8279e3dbfa0ee69a9b.png)

1. Go to **Settings > Revisions Bin Cleaner**
2. Toggle ON to enable the cleaner task.
3. Set the minimum entries age to keep:
   - When toggled ON:
     - Revisions Bin entries older than this value will be deleted.
     - Default: `30` days.
   - When toggled OFF:
     - ALL Revisions Bin entries will be deleted.
4. Set the custom cleaner frequency:
   - Define how often (in seconds) the Revisions Bin Cleaner runs.
   - Default: `300` seconds (5 minutes).

## Setting the revisions bin cleaner - from the Client API

- Use `ConfigureRevisionsBinCleanerOperation` to configure the Revisions Bin Cleaner from the Client API.

- By default, the operation will be applied to the [default database](https://docs.ravendb.net/6.2/client-api/setting-up-default-database.md).  
  To operate on a different database see [switch operations to different database](https://docs.ravendb.net/6.2/client-api/operations/how-to/switch-operations-to-a-different-database.md).

- In this example, we enable the cleaner and configure its execution frequency and retention policy.

### Sync

```csharp
//Define the revisions bin cleaner configuration
var config = new RevisionsBinConfiguration()
{
  // Enable the cleaner
  Disabled = false,

  // Set the cleaner execution frequency
  CleanerFrequencyInSec = 24 * 60 * 60, // one day (in seconds)
  
  // Revisions bin entries older than the following value will be deleted
  MinimumEntriesAgeToKeepInMin = 24 * 60 // one day (in minutes)
};

// Define the operation
var configRevisionsBinCleanerOp = new ConfigureRevisionsBinCleanerOperation(config);

// Execute the operation by passing it to Maintenance.Send
store.Maintenance.Send(configRevisionsBinCleanerOp);
```

### Async

```csharp
var config = new RevisionsBinConfiguration()
{
  Disabled = false,
  CleanerFrequencyInSec = 24 * 60 * 60,
  MinimumEntriesAgeToKeepInMin = 24 * 60 
};

var configRevisionsBinCleanerOp = new ConfigureRevisionsBinCleanerOperation(config);
await store.Maintenance.SendAsync(configRevisionsBinCleanerOp);
```

## Syntax

```csharp
public ConfigureRevisionsBinCleanerOperation(RevisionsBinConfiguration configuration);
```

```csharp
public class RevisionsBinConfiguration
{
  // Set to true to enable the revisions bin cleaner.
  // Default: false (cleaner is disabled).
  public bool Disabled { get; set; }
  
  // The minimum age (in minutes) for revisions-bin entries to be kept in the database.
  // The cleaner deletes entries older than this value.
  // When set to 0: ALL revisions-bin entries will be removed from the Revisions Bin
  // Default: 30 days.
  public int MinimumEntriesAgeToKeepInMin { get; set; }
  
  // The frequency (in seconds) at which the revisions bin cleaner executes.
  // Default: 300 seconds (5 minutes).
  public long CleanerFrequencyInSec { get; set; } = 5 * 60;
}
```
