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

# How to manage object versioning in a bucket

Object versioning allows you to keep multiple versions of the same object in a bucket. When versioning is enabled, each update to an object creates a new version instead of replacing the existing one.

Versioning helps protect data from accidental deletion, overwriting or application errors and allows you to restore previous versions of objects.

When versioning is enabled for a bucket:

* Each object version receives a unique version ID
* Uploading an object with the same key creates a new version
* Previous versions remain stored in the bucket

If multiple write operations for the same object occur simultaneously, Object Storage stores all of the resulting object versions.

By default, versioning is disabled on buckets. After you enable versioning, you cannot fully disable it and can only suspend it.

> [!NOTE]
>
> For lower latency and higher throughput in high-load scenarios, we recommend using buckets with versioning disabled.

> [!WARNING]
>
> If your bucket has expiration lifecycle rules that permanently delete objects and you want to maintain the same behavior after enabling versioning, configure expiration for non-current object versions. Non-current version expiration rules manage the deletion of non-current object versions in a versioning-enabled bucket. For more information, see [Configure expiration lifecycle rules](https://docs.nebius.com/object-storage/objects/configure-lifecycle-rules.md#how-to-configure-expiration-lifecycle-rules).

## Prerequisites

If you use the web console, you don't need to complete any prerequisites. To use the AWS CLI with Object Storage, see [Working with Object Storage buckets and objects using the AWS CLI](https://docs.nebius.com/object-storage/interfaces/aws-cli.md).

> [tab] CLI
>
> [Install and configure](https://docs.nebius.com/cli/install.md) the Nebius AI Cloud CLI.

> [tab] Go SDK
>
> [Install and initialize the Nebius SDK for Go](https://docs.nebius.com/sdk/go/install-auth.md).

> [tab] Python SDK
>
> [Install and initialize the Nebius SDK for Python](https://docs.nebius.com/sdk/python/install-auth.md).

> [tab] JavaScript SDK
>
> [Install and initialize the Nebius SDK for JavaScript](https://docs.nebius.com/sdk/javascript/install-auth.md).

## How to enable bucket versioning

> [tab] Web console
>
> 1. In the [web console](https://console.nebius.com), go to  **Storage** → **Object Storage**.
> 2. Open the page of the required bucket.
> 3. Go to the **Settings** tab.
> 4. In the **Versioning** field, select **Enabled**.
> 5. Click **Save changes**.

> [tab] Nebius AI Cloud CLI
>
> 1. Get the bucket ID:
>    ```bash theme={null}
>    export BUCKET_ID=$(nebius storage bucket get-by-name \
>      --name <bucket_name> --format jsonpath='{.metadata.id}')
>    ```
> 2. Enable versioning for the bucket:
>    ```bash theme={null}
>    nebius storage bucket update --id $BUCKET_ID --versioning-policy enabled
>    ```

> [tab] AWS CLI
>
> Run the following command:
>
> ```bash theme={null}
> aws s3api put-bucket-versioning \
>   --bucket <bucket_name> \
>   --versioning-configuration Status=Enabled \
>   --endpoint-url https://storage.<region>.nebius.cloud
> ```

> [tab] Go SDK
>
> ```go theme={null}
> enableSvc := sdk.Services().Storage().V1().Bucket()
> enableBucket, err := enableSvc.Get(
>     ctx,
>     &storage.GetBucketRequest{
>         Id: "<bucket_ID>",
>     },
> )
> if err != nil {
>     return err
> }
> enableBucket.Spec.VersioningPolicy = storage.VersioningPolicy_ENABLED
> enableOp, err := enableSvc.Update(
>     ctx,
>     &storage.UpdateBucketRequest{
>         Metadata: enableBucket.Metadata,
>         Spec:     enableBucket.Spec,
>     },
> )
> if err != nil {
>     return err
> }
> if _, err = enableOp.Wait(ctx); err != nil {
>     return err
> }
> ```
>
> In the code, set the following parameters:
>
> * `Id`: Bucket ID.
> * `VersioningPolicy`: `VersioningPolicy_ENABLED`.

> [tab] Python SDK
>
> ```python theme={null}
> enable_service = BucketServiceClient(sdk)
> enable_bucket = await enable_service.get(
>     GetBucketRequest(id="<bucket_ID>"),
> )
> enable_bucket.spec.versioning_policy = VersioningPolicy.ENABLED
> enable_operation = await enable_service.update(
>     UpdateBucketRequest(
>         metadata=enable_bucket.metadata,
>         spec=enable_bucket.spec,
>     ),
> )
> await enable_operation.wait()
> ```
>
> In the code, set the following parameters:
>
> * `id`: Bucket ID.
> * `versioning_policy`: `VersioningPolicy.ENABLED`.

> [tab] JavaScript SDK
>
> ```ts theme={null}
> const enableService = new BucketService(sdk);
> const enableBucket = await enableService.get(
>   GetBucketRequest.create({ id: "<bucket_ID>" }),
> ).result;
> enableBucket.spec.versioningPolicy = VersioningPolicy.ENABLED;
> const enableOperation = await enableService.update(
>   UpdateBucketRequest.create({
>     metadata: enableBucket.metadata,
>     spec: enableBucket.spec,
>   }),
> ).result;
> await enableOperation.wait();
> ```
>
> In the code, set the following parameters:
>
> * `id`: Bucket ID.
> * `versioningPolicy`: `VersioningPolicy.ENABLED`.

After versioning is enabled, all subsequent object uploads and modifications create new versions.

> [!NOTE]
>
> After you enable versioning for an *existing* bucket for the first time, it may take up to 15 minutes to come into effect. We recommend waiting 15 minutes before performing any write operations (`PUT` or `DELETE`) to avoid issues with object visibility and version tracking. If you enable or suspend versioning when [*creating* a bucket](https://docs.nebius.com/object-storage/buckets/manage.md#how-to-create-buckets), it is available immediately with no waiting period.

## How to suspend bucket versioning

If needed, you can suspend versioning for a bucket:

> [tab] Web console
>
> 1. In the [web console](https://console.nebius.com), go to  **Storage** → **Object Storage**.
> 2. Open the page of the required bucket.
> 3. Go to the **Settings** tab.
> 4. In the **Versioning** field, enable the **Suspend** option.
> 5. Click **Save changes**.

> [tab] Nebius AI Cloud CLI
>
> 1. Get the bucket ID:
>    ```bash theme={null}
>    export BUCKET_ID=$(nebius storage bucket get-by-name \
>      --name <bucket_name> --format jsonpath='{.metadata.id}')
>    ```
> 2. Suspend versioning for the bucket:
>    ```bash theme={null}
>    nebius storage bucket update --id $BUCKET_ID --versioning-policy suspended
>    ```

> [tab] AWS CLI
>
> Run the following command:
>
> ```bash theme={null}
> aws s3api put-bucket-versioning \
> --bucket <bucket_name> \
> --versioning-configuration Status=Suspended \
> --endpoint-url https://storage.<region>.nebius.cloud
> ```

> [tab] Go SDK
>
> Suspend versioning for the bucket:
>
> ```go theme={null}
> suspendSvc := sdk.Services().Storage().V1().Bucket()
> suspendBucket, err := suspendSvc.Get(
>     ctx,
>     &storage.GetBucketRequest{
>         Id: "<bucket_ID>",
>     },
> )
> if err != nil {
>     return err
> }
> suspendBucket.Spec.VersioningPolicy =
>     storage.VersioningPolicy_SUSPENDED
> suspendOp, err := suspendSvc.Update(
>     ctx,
>     &storage.UpdateBucketRequest{
>         Metadata: suspendBucket.Metadata,
>         Spec:     suspendBucket.Spec,
>     },
> )
> if err != nil {
>     return err
> }
> if _, err = suspendOp.Wait(ctx); err != nil {
>     return err
> }
> ```
>
> In the code, set the following parameters:
>
> * `Id`: Bucket ID.
> * `VersioningPolicy`: `VersioningPolicy_SUSPENDED`.

> [tab] Python SDK
>
> Suspend versioning for the bucket:
>
> ```python theme={null}
> suspend_service = BucketServiceClient(sdk)
> suspend_bucket = await suspend_service.get(
>     GetBucketRequest(id="<bucket_ID>"),
> )
> suspend_bucket.spec.versioning_policy = VersioningPolicy.SUSPENDED
> suspend_operation = await suspend_service.update(
>     UpdateBucketRequest(
>         metadata=suspend_bucket.metadata,
>         spec=suspend_bucket.spec,
>     ),
> )
> await suspend_operation.wait()
> ```
>
> In the code, set the following parameters:
>
> * `id`: Bucket ID.
> * `versioning_policy`: `VersioningPolicy.SUSPENDED`.

> [tab] JavaScript SDK
>
> Suspend versioning for the bucket:
>
> ```ts theme={null}
> const suspendService = new BucketService(sdk);
> const suspendBucket = await suspendService.get(
>   GetBucketRequest.create({ id: "<bucket_ID>" }),
> ).result;
> suspendBucket.spec.versioningPolicy = VersioningPolicy.SUSPENDED;
> const suspendOperation = await suspendService.update(
>   UpdateBucketRequest.create({
>     metadata: suspendBucket.metadata,
>     spec: suspendBucket.spec,
>   }),
> ).result;
> await suspendOperation.wait();
> ```
>
> In the code, set the following parameters:
>
> * `id`: Bucket ID.
> * `versioningPolicy`: `VersioningPolicy.SUSPENDED`.
