---
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: "python"
---

# Enforce Revisions Configuration Operation

> Client language: Python. Also available for [C#](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/operations/enforce-revisions-configuration.md), [Java](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/operations/enforce-revisions-configuration.java.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.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.python.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 `max_ops_per_second` 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 `include_force_created` is set to `True`.

## 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.

```python
# Define the enforce revisions configuration operation
enforce_configuration_op = EnforceRevisionsConfigurationOperation()

# Execute the operation by passing it to operations.send_async
# send_async returns an Operation object, NOT the operation result
operation = store.operations.send_async(enforce_configuration_op)

# Wait for the operation to complete
operation.wait_for_completion()
```

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

Set the `collections` parameter to enforce the configuration only on revisions in the specified collections.  
When `collections` is not set, is `None`, or is an empty list, the operation is applied to all collections.

```python
enforce_configuration_op = EnforceRevisionsConfigurationOperation(
    EnforceRevisionsConfigurationOperation.Parameters(
        # The configuration will be enforced only on these collections
        collections=["Users", "Products"]
    )
)

operation = store.operations.send_async(enforce_configuration_op)
operation.wait_for_completion()
```

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

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

Set `include_force_created` to `True` to allow those force-created revisions to be removed as well.

```python
enforce_configuration_op = EnforceRevisionsConfigurationOperation(
    EnforceRevisionsConfigurationOperation.Parameters(
        # Force-created revisions will also be subject to the configuration rules
        include_force_created=True
    )
)

operation = store.operations.send_async(enforce_configuration_op)
operation.wait_for_completion()
```

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

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

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

```python
enforce_configuration_op = EnforceRevisionsConfigurationOperation(
    EnforceRevisionsConfigurationOperation.Parameters(
        # Process at most 100 documents per second
        max_ops_per_second=100
    )
)

operation = store.operations.send_async(enforce_configuration_op)
operation.wait_for_completion()
```

> **Warning**
>
> `max_ops_per_second` must be greater than `0`.  
> Setting it to `0` or a negative value raises a `ValueError` when the `Parameters` object is created.

## Syntax {#syntax}

```python
# Available overloads:
# ====================

class EnforceRevisionsConfigurationOperation(IOperation[OperationIdResult]):
    # Enforce the configuration using default parameters (all collections),
    # or pass a Parameters object to customize the operation.
    def __init__(
        self,
        parameters: Optional[EnforceRevisionsConfigurationOperation.Parameters] = None,
    ): ...
```

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

```python
class Parameters(RevisionsOperationParameters):
    def __init__(
        self,
        include_force_created: bool = False,
        max_ops_per_second: int = None,       # raises ValueError if value <= 0
        collections: List[str] = None,
    ): ...
```

| Parameter | Type | Description |
| - | - | - |
| **include\_force\_created** | `bool` | `True` - [Force-created revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/overview.python.md#force-revision-creation) may also be removed by the operation.<br />`False` (default) - Force-created revisions are not included in deletion paths that protect them. |
| **max\_ops\_per\_second** | `int` | Limits the number of documents processed per second.<br />`None` (default) - no throttling.<br />Must be greater than `0`, otherwise a `ValueError` is raised. |
| **collections** | `List[str]` | The collections the operation applies to.<br />`None` or empty list - the operation applies to all collections. |

Enforcing the configuration is a long-running server operation.  
`store.operations.send_async` returns an `Operation` object built from an `OperationIdResult`:

```python
class OperationIdResult:
    def __init__(self, operation_id: int = None, operation_node_tag: str = None): ...
```

## See also

- [Revisions Overview](https://docs.ravendb.net/7.2/document-extensions/revisions/overview.python.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.python.md)
- [Revisions: API Overview](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/overview.python.md)
- [Session: Loading Revisions](https://docs.ravendb.net/7.2/document-extensions/revisions/client-api/session/loading.python.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.python.md)
- [What Are Operations](https://docs.ravendb.net/7.2/client-api/operations/what-are-operations.python.md)
- [Switch Operation Database](https://docs.ravendb.net/7.2/client-api/operations/how-to/switch-operations-to-a-different-database.python.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)
