---
title: "Enforce Revisions Configuration Operation"
description: "Apply the current revisions configuration to all existing revisions using the EnforceRevisionsConfigurationOperation, with optional throttling via MaxOpsPerSecond."
url: "https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/operations/enforce-revisions-configuration"
version: "7.2"
language: "java"
---

# Enforce Revisions Configuration Operation

> Client language: Java. Also available for [C#](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/operations/enforce-revisions-configuration.md), [Python](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/operations/enforce-revisions-configuration.python.md), [Node.js](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/operations/enforce-revisions-configuration.nodejs.md).
>
> 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."

> **Note**
>
> - The revision configuration rules are usually applied to a document's revisions only when the document is modified.  
>   Use `EnforceRevisionsConfigurationOperation` to apply the current [revisions configuration](https://docs.ravendb.net/7.2/studio/database/settings/document-revisions.md)
>   to existing revisions, instead of waiting for each document to be modified.
>
> - Running this operation scans existing revisions and enforces the current rules immediately,
>   **deleting** eligible revisions that should be purged according to the configuration.
>
> - The operation can be applied to all collections (default) or to a specified set of collections.
>
> - By default, the operation is applied to the [default database](https://docs.ravendb.net/7.2/client-api/setting-up-default-database.java.md).  
>   To operate on a different database, see [switch operations to a different database](https://docs.ravendb.net/7.2/client-api/operations/how-to/switch-operations-to-a-different-database.java.md).
>
> - This article explains how to run the operation from the Client API.  
>   To run it from Studio, see [Enforce configuration](https://docs.ravendb.net/7.2/studio/database/settings/document-revisions.md#enforce-configuration) in the Document Revisions settings view.
>
> - In this article:
>   - [Enforce configuration on all collections](#enforce-configuration-on-all-collections)
>   - [Enforce configuration on specific collections](#enforce-configuration-on-specific-collections)
>   - [Include force-created revisions](#include-force-created-revisions)
>   - [Throttle the operation](#throttle-the-operation)
>   - [Syntax](#syntax)

> **Warning:** Resource consumption
>
> - Large databases may contain many revisions that will be deleted when the current configuration is enforced.  
>   Running the operation can delete them all in a single enforcement run and may require substantial server resources.
>   Schedule it accordingly.
>
> - On large datasets, use `setMaxOpsPerSecond(...)` to [throttle the operation](#throttle-the-operation)
>   and reduce its resource consumption.
>
> - Revisions in collections that no current configuration applies to may be deleted.
>   Make sure your revisions configuration includes the default settings and collection-specific configurations needed to keep the revisions you want to preserve.
>   Force-created revisions may also be removed when `setIncludeForceCreated(true)` is used.

## Enforce configuration on all collections {#enforce-configuration-on-all-collections}

In this example, the current revisions configuration is enforced on the revisions of all collections.

```java
// Define the enforce revisions configuration operation
EnforceRevisionsConfigurationOperation enforceConfigurationOp =
    new EnforceRevisionsConfigurationOperation();

// Execute the operation by passing it to operations().sendAsync
// 'sendAsync' returns an Operation object that can be awaited
Operation operation = store.operations().sendAsync(enforceConfigurationOp);

// Wait for the operation to complete
operation.waitForCompletion();
```

## Enforce configuration on specific collections {#enforce-configuration-on-specific-collections}

Use `setCollections(...)` to enforce the configuration only on revisions in the specified collections.  
When `collections` is not set, is `null`, or is an empty array, the operation is applied to all collections.

```java
EnforceRevisionsConfigurationOperation.Parameters parameters =
    new EnforceRevisionsConfigurationOperation.Parameters();

// The configuration will be enforced only on these collections
parameters.setCollections(new String[]{ "Users", "Products" });

Operation operation = store.operations().sendAsync(
    new EnforceRevisionsConfigurationOperation(parameters));

operation.waitForCompletion();
```

## Include force-created revisions {#include-force-created-revisions}

By default, [force-created revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/overview.md#force-revision-creation)
are preserved and are not removed by the operation.

Call `setIncludeForceCreated(true)` to allow those force-created revisions to be removed as well.

```java
EnforceRevisionsConfigurationOperation.Parameters parameters =
    new EnforceRevisionsConfigurationOperation.Parameters();

// Force-created revisions will also be subject to the configuration rules
parameters.setIncludeForceCreated(true);

Operation operation = store.operations().sendAsync(
    new EnforceRevisionsConfigurationOperation(parameters));

operation.waitForCompletion();
```

## Throttle the operation {#throttle-the-operation}

Running the operation on a large database may consume substantial server resources and affect server performance.

Set `setMaxOpsPerSecond(...)` to limit the number of documents processed per second,  
throttling the operation to reduce its resource consumption.

```java
EnforceRevisionsConfigurationOperation.Parameters parameters =
    new EnforceRevisionsConfigurationOperation.Parameters();

// Process at most 100 documents per second
parameters.setMaxOpsPerSecond(100);

Operation operation = store.operations().sendAsync(
    new EnforceRevisionsConfigurationOperation(parameters));

operation.waitForCompletion();
```

> **Warning**
>
> `maxOpsPerSecond` must be greater than `0`.  
> Calling `setMaxOpsPerSecond` with `0` or a negative value throws an `IllegalStateException`.

## Syntax {#syntax}

```java
// Available constructors:
// ====================

// Enforce the configuration using default parameters (all collections)
public EnforceRevisionsConfigurationOperation();

// Enforce the configuration using the specified parameters
public EnforceRevisionsConfigurationOperation(Parameters parameters);
```

| Parameter | Type | Description |
| - | - | - |
| **parameters** | `Parameters` | The parameters defining how the configuration is enforced.<br />See the `Parameters` class below. |

```java
public static class Parameters {
    public boolean isIncludeForceCreated();
    public void setIncludeForceCreated(boolean includeForceCreated);

    public String[] getCollections();
    public void setCollections(String[] collections);

    public Integer getMaxOpsPerSecond();
    public void setMaxOpsPerSecond(Integer maxOpsPerSecond);
}
```

| Parameter | Type | Description |
| - | - | - |
| **includeForceCreated** | `boolean` | `true` - [Force-created revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/overview.md#force-revision-creation)may also be removed by the operation.<br />`false` (default) - Force-created revisions are not included in deletion paths that explicitly protect them. |
| **collections** | `String[]` | The collections the operation applies to.<br />When not set or `null`, the operation applies to all collections. |
| **maxOpsPerSecond** | `Integer` | Limits the number of documents processed per second, throttling the operation to reduce resource consumption.<br />When not set (`null`), no throttling is applied.<br />Must be greater than `0`, otherwise an `IllegalStateException` is thrown. |

The operation returns an `OperationIdResult`.  
Use the returned `Operation` object to wait for the operation to complete via `waitForCompletion()`.

## See also

- [Revisions Overview](https://docs.ravendb.net/7.2/document-extensions/revisions/overview.md)
- [Delete Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/operations/delete-revisions.md)
- [Revert Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/revert-documents-to-revisions/revert-documents-to-specific-time.md)
- [Revisions and Other Features](https://docs.ravendb.net/7.2/document-extensions/revisions/revisions-and-other-features.java.md)
- [Revisions: API Overview](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/overview.java.md)
- [Session: Loading Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/session/loading.java.md)
- [Session: Including Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/session/including.md)
- [Session: Counting Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/session/counting.md)
- [What Are Operations](https://docs.ravendb.net/7.2/client-api/operations/what-are-operations.java.md)
- [Switch Operation Database](https://docs.ravendb.net/7.2/client-api/operations/how-to/switch-operations-to-a-different-database.java.md)
- [Settings: Document Revisions](https://docs.ravendb.net/7.2/studio/database/settings/document-revisions.md)
- [Document Extensions: Revisions](https://docs.ravendb.net/7.2/studio/database/document-extensions/revisions/revisions-overview.md)
