Discover
Get started
Create buckets
Access and manage buckets
Upload and download objects
Access and manage objects
Get insights on your stored data
Cache objects
Control data lifecycles
Make requests
Secure data
Monitor data and usage
Protection, backup, and recovery
Mount buckets with Cloud Storage FUSE
Work across products, Clouds, and platforms
Troubleshoot
Stay organized with collections Save and categorize content based on your preferences.
This page describes how to enable, disable, and check the status of Object Versioning on a bucket. See Using versioned objects to learn how to list, restore, and delete the objects that are retained by Object Versioning.
Important: There is no default limit on the number of object versions you can have. Each noncurrent version of an object is charged at the same rate as the live version of the object. If you enable versioning, consider using Object Lifecycle Management, which can remove the oldest versions of an object as newer versions become noncurrent. Required rolesTo get the permissions that you need to set and manage Object Versioning on a bucket, ask your administrator to grant you the Storage Admin (roles/storage.admin
) IAM role on the bucket or the project that contains the bucket. This predefined role contains the permissions required to set and manage Object Versioning for a bucket. To see the exact permissions that are required, expand the Required permissions section:
storage.buckets.get
storage.buckets.update
storage.buckets.list
You might also be able to get these permissions with custom roles.
For information about granting roles on buckets, see Use IAM with buckets. For information about granting roles on projects, see Manage access to projects.
Set Object Versioning on a bucket ConsoleIn the list of buckets, click the name of the bucket for which you want to enable or disable Object Versioning.
Select the Protection tab near the top of the page.
The current status of Object versioning is found in the Object versioning section.
In the Object versioning section, click the current status to make changes to it.
The Object versioning dialog appears.
Click Confirm.
Use the gcloud storage buckets update
command with the appropriate flag:
gcloud storage buckets update gs://BUCKET_NAME FLAG
Where:
BUCKET_NAME
is the name of the relevant bucket. For example, my-bucket
.
FLAG
is either --versioning
to enable Object Versioning or --no-versioning
to disable it.
If successful, the response looks similar to the following example:
Updating gs://my-bucket/... Completed 1Client libraries C++
For more information, see the Cloud Storage C++ API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample enables Object Versioning on a bucket:
The following sample disables Object Versioning on a bucket:
C#For more information, see the Cloud Storage C# API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample enables Object Versioning on a bucket:
The following sample disables Object Versioning on a bucket:
GoFor more information, see the Cloud Storage Go API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample enables Object Versioning on a bucket:
The following sample disables Object Versioning on a bucket:
JavaFor more information, see the Cloud Storage Java API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample enables Object Versioning on a bucket:
The following sample disables Object Versioning on a bucket:
Node.jsFor more information, see the Cloud Storage Node.js API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample enables Object Versioning on a bucket:
The following sample disables Object Versioning on a bucket:
PHPFor more information, see the Cloud Storage PHP API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample enables Object Versioning on a bucket:
The following sample disables Object Versioning on a bucket:
PythonFor more information, see the Cloud Storage Python API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample enables Object Versioning on a bucket:
The following sample disables Object Versioning on a bucket:
RubyFor more information, see the Cloud Storage Ruby API reference documentation.
To authenticate to Cloud Storage, set up Application Default Credentials. For more information, see Set up authentication for client libraries.
The following sample enables Object Versioning on a bucket:
The following sample disables Object Versioning on a bucket:
REST APIsOnce Object Versioning is enabled, each time a live object version is replaced or deleted, that version becomes a noncurrent version.
Check whether Object Versioning is enabledTo check whether Object Versioning is enabled on a bucket:
ConsoleIn the list of buckets, the Object Versioning status of each bucket is found in the Protection column.
If enabled, the text Object versioning appears.
Command lineUse the gcloud storage buckets describe
command with the --format
flag:
gcloud storage buckets describe gs://BUCKET_NAME --format="default(versioning_enabled)"
Where BUCKET_NAME
is the name of the bucket whose status you want to view. For example, my-bucket
.
If successful and Object Versioning is enabled, the response looks similar to the following example:
versioning: enabled: true
If successful and Object Versioning is not enabled, the response looks similar to the following example:
nullREST APIs JSON API
Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization
header.
Use cURL
to call the JSON API with a GET
Bucket request:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME?fields=versioning"
Where BUCKET_NAME
is the name of the relevant bucket. For example, my-bucket
.
If successful and Object Versioning is enabled, the response looks similar to the following example:
{ "versioning": { "enabled": true } }
If successful and Object Versioning is not enabled, the response looks similar to the following example:
{}XML API
Have gcloud CLI installed and initialized, which lets you generate an access token for the Authorization
header.
Use cURL
to call the XML API, with a GET
Bucket request and versioning
query string parameter:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/BUCKET_NAME?versioning"
Where BUCKET_NAME
is the name of the relevant bucket. For example, my-bucket
.
If successful and Object Versioning is enabled, the response looks similar to the following example:
<VersioningConfiguration> <Status>Enabled</Status> </VersioningConfiguration>
If successful and Object Versioning is not enabled, the response looks similar to the following example:
<VersioningConfiguration/>What's next
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-07 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[]]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4