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 list, access, restore, and delete noncurrent objects, which typically applies to buckets with the feature Object Versioning enabled.
Required rolesTo get the permissions that you need to manage noncurrent objects, ask your administrator to grant you the Storage Object User (roles/storage.objectUser
) IAM role on the project. This predefined role contains the permissions required to manage noncurrent objects. To see the exact permissions that are required, expand the Required permissions section:
storage.objects.create
storage.objects.delete
storage.objects.get
storage.objects.list
You might also be able to get these permissions with custom roles.
For information about granting roles on projects, see Manage access to projects.
Depending on your use case, you might need additional permissions or alternative roles:
If you plan on using the Google Cloud console to perform the tasks on this page, you'll also need the storage.buckets.list
permission, which is not included in the Storage Object User (roles/storage.objectUser
) role. To get this permission, ask your administrator to grant you the Storage Admin (roles/storage.admin
) role on the project.
If uniform bucket-level access is disabled for your bucket, you need additional permissions in the following scenarios:
If you plan on returning noncurrent objects along with their ACLs, you also need the storage.objects.getIamPolicy
permission, which is not included in the Storage Object User (roles/storage.objectUser
) role. To get this permission, ask your administrator to grant you the Storage Object Admin (roles/storage.objectAdmin
) role on the project.
If you plan on renaming or restoring noncurrent objects that have ACLs, you also need the storage.objects.setIamPolicy
permission, which is not included in the Storage Object User (roles/storage.objectUser
) role. To get this permission, ask your administrator to grant you the Storage Object Admin (roles/storage.objectAdmin
) role on the project.
To list both live and noncurrent versions of objects and view their generation
numbers:
In the list of buckets, click the name of the bucket that contains the wanted object.
The Bucket details page opens, with the Objects tab selected.
To view noncurrent objects, click the Show drop-down and select Live and noncurrent objects.
In the list of objects, click the name of the object whose versions you want to see.
The Object details page opens, with the Live Object tab selected.
Click the Version history tab to see all versions of the object.
Use the gcloud storage ls --all-versions
command:
gcloud storage ls --all-versions gs://BUCKET_NAME
Where BUCKET_NAME
is the name of the bucket that contains the objects. For example, my-bucket
.
The response looks like the following example:
gs://BUCKET_NAME/OBJECT_NAME1#GENERATION_NUMBER1 gs://BUCKET_NAME/OBJECT_NAME2#GENERATION_NUMBER2 gs://BUCKET_NAME/OBJECT_NAME3#GENERATION_NUMBER3 ...Note: Use the
--long
flag along with the --all-versions
flag to get metageneration numbers in the response. Use the --full
flag along with the --all-versions
flag to get the Noncurrent Time
for noncurrent versions of an object. Client 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.
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.
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.
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.
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.
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.
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.
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.
REST APIs JSON APIHave gcloud CLI installed and initialized, which lets you generate an access token for the Authorization
header.
Use cURL
to call the JSON API with an Objects: list request:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/o?versions=true"
Where BUCKET_NAME
is the name of the bucket that contains the objects. For example, my-bucket
.
Noncurrent versions of objects have a timeDeleted
property.
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 versions
query string parameter:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/BUCKET_NAME?versions&list-type=2"
Where BUCKET_NAME
is the name of the bucket that contains the objects. For example, my-bucket
.
There are a few differences in the results of the GET
request when using the versions
query parameter compared to not using it. Specifically, Cloud Storage returns the following information when you include a versions
query parameter in your request:
Version
element that contains information about each object.DeletedTime
element that contains the time the object version became noncurrent (deleted or replaced).NextGenerationMarker
element is returned if the listing of objects is a partial listing, which occurs when you have many object versions in a bucket. Use the value of this element in the generationmarker
query parameter of subsequent requests in order to resume from your last point. The generationmarker
query parameter is used in the same way that you use the marker
query parameter to page through a listing for a nonversioned bucket.To use the noncurrent version of an object when performing tasks such as downloading the object, viewing its metadata, or updating its metadata:
ConsoleGeneral access to a noncurrent version is not available in the Google Cloud console. Using the Google Cloud console, you can only move, copy, restore or delete a noncurrent version. These actions are performed from the version history list for an object.
Command lineAppend the generation number of the noncurrent version to the object name:
OBJECT_NAME#GENERATION_NUMBER
Where:
OBJECT_NAME
is the name of the noncurrent version. For example, pets/dog.png
.GENERATION_NUMBER
is the generation number for the noncurrent version. For example, 1560468815691234
.Using the string from the previous step, proceed as you normally would for the live version of the object. For example, to view the metadata of a noncurrent object version, use the gcloud storage objects describe
command:
gcloud storage objects describe gs://my-bucket/pets/dog.png#1560468815691234
Append the generation number of the noncurrent version to the URI for the object:
https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/o/OBJECT_NAME?generation=GENERATION_NUMBER
Where:
BUCKET_NAME
is the name of the bucket containing the noncurrent version. For example, my-bucket
.OBJECT_NAME
is the URL-encoded name of the noncurrent version. For example, pets/dog.png
, URL-encoded as pets%2Fdog.png
.GENERATION_NUMBER
is the generation number for the noncurrent version. For example, 1560468815691234
.Using the URI from the previous step, proceed as you normally would for the live version of the object. For example, to view the metadata of a noncurrent object version, use cURL to call the JSON API with an Objects: get request:
curl -X GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/storage/v1/b/my-bucket/o/pets/dog.png?generation=1560468815691234"
Append the generation number of the noncurrent version to the URI for the object:
https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME?generation=GENERATION_NUMBER
Where:
BUCKET_NAME
is the name of the bucket containing the noncurrent version. For example, my-bucket
.OBJECT_NAME
is the URL-encoded name of the noncurrent version. For example, pets/dog.png
, URL-encoded as pets%2Fdog.png
.GENERATION_NUMBER
is the generation number for the noncurrent version. For example, 1560468815691234
.Using the URI from the previous step, proceed as you normally would for the live version of the object. For example, to view the metadata of a noncurrent object version, use cURL
to call the XML API with a HEAD
Object request:
curl -I GET \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/my-bucket/pets/dog.png?generation=1560468815691234"
In Cloud Storage, restoring a noncurrent object version means making a copy of it. When you do so, the copy becomes the live version, effectively restoring the version. If there is already a live version and the bucket has Object Versioning enabled, restoring the noncurrent version causes the pre-existing live version to become noncurrent.
Console Note: The Google Cloud console has a limit of 1000 versions of an object that it can list.In the list of buckets, click the name of the bucket that contains the wanted object.
The Bucket details page opens, with the Objects tab selected.
To view noncurrent objects, click the Show drop-down and select Live and noncurrent objects.
In the list of objects, click the name of the object version you want to restore.
The Object details page opens, with the Live Object tab selected.
Click the Version history tab.
Click the Restore button for the wanted version.
The restore object version pane opens.
Click Confirm.
Use the gcloud storage cp
command:
gcloud storage cp gs://BUCKET_NAME/OBJECT_NAME#GENERATION_NUMBER gs://BUCKET_NAME
Where:
BUCKET_NAME
is the name of the bucket containing the noncurrent version you want to restore. For example, my-bucket
.OBJECT_NAME
is the name of the noncurrent version you want to restore. For example, pets/dog.png
.GENERATION_NUMBER
is the generation number for the noncurrent version you want to restore. For example, 1560468815691234
.If successful, the response looks like the following example:
Operation completed over 1 objects/58.8 KiB.Note: Some shells, such as zsh when the
extendedglob
option is enabled, treat the hash character, #
, as a special character. If this is the case for your shell, you should enclose that argument in single quotes (or double quotes for Windows). Client 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.
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.
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.
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.
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.
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.
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.
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.
REST APIs JSON APIHave 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 POST
Object request:
curl -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Length: 0" \ "https://storage.googleapis.com/upload/storage/v1/b/BUCKET_NAME/o/OBJECT_NAME/rewriteTo/b/BUCKET_NAME/o/OBJECT_NAME?sourceGeneration=GENERATION_NUMBER"
Where:
BUCKET_NAME
is the name of the bucket containing the noncurrent version you want to restore. For example, my-bucket
.OBJECT_NAME
is the URL-encoded name of the noncurrent version you want to restore. For example, pets/dog.png
, URL-encoded as pets%2Fdog.png
.GENERATION_NUMBER
is the generation number for the noncurrent version you want to restore. For example, 1560468815691234
.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 PUT
Object request:
curl -X PUT \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "x-goog-copy-source: BUCKET_NAME/OBJECT_NAME" \ -H "x-goog-copy-source-generation:GENERATION_NUMBER" \ "https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME"
Where:
BUCKET_NAME
is the name of the bucket containing the noncurrent version you want to restore. For example, my-bucket
.OBJECT_NAME
is the URL-encoded name of the noncurrent version you want to restore. For example, pets/dog.png
, URL-encoded as pets%2Fdog.png
.GENERATION_NUMBER
is the generation number for the noncurrent version you want to restore. For example, 1560468815691234
.After restoring the object version, the original noncurrent version continues to exist in the bucket. If you no longer need the noncurrent version, you can subsequently delete it or configure Object Lifecycyle Management to remove it when it meets the conditions you specify.
Delete noncurrent object versions Console Note: The Google Cloud console has a limit of 1000 versions of an object that it can list.In the list of buckets, click the name of the bucket that contains the wanted object.
The Bucket details page opens, with the Objects tab selected.
To view noncurrent objects, click the Show drop-down and select Live and noncurrent objects.
Navigate to the object, which may be located in a folder.
In the list of objects, click the name of the object whose version you want to delete.
The Object details page opens, with the Live Object tab selected.
Click the Version history tab.
Select the checkbox for the wanted version.
Click the Delete button.
The delete version pane opens.
Confirm you want to delete the object by typing delete
into the text field.
Click Delete.
Use the gcloud storage rm
command:
gcloud storage rm gs://BUCKET_NAME/OBJECT_NAME#GENERATION_NUMBER
Where:
BUCKET_NAME
is the name of the bucket containing the noncurrent version you want to delete. For example, my-bucket
.OBJECT_NAME
is the name of the noncurrent version you want to delete. For example, pets/dog.png
.GENERATION_NUMBER
is the generation number for the noncurrent version you want to delete. For example, 1560468815691234
.If successful, the response looks like the following example:
Operation completed over 1 objects.Note: You can remove all versions of an object, including live and noncurrent versions, by using the
--all-versions
flag and omitting the #GENERATION_NUMBER
. You can remove all versions of all objects (and potentially the bucket itself) by using the --recursive
flag. Client 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.
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.
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.
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.
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.
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.
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.
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.
REST APIs JSON APIHave 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 DELETE
Object request:
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/storage/v1/b/BUCKET_NAME/o/OBJECT_NAME?generation=GENERATION_NUMBER"
Where:
BUCKET_NAME
is the name of the bucket containing the noncurrent version you want to delete. For example, my-bucket
.OBJECT_NAME
is the URL-encoded name of the noncurrent version you want to delete. For example, pets/dog.png
, URL-encoded as pets%2Fdog.png
.GENERATION_NUMBER
is the generation number for the noncurrent version you want to delete. For example, 1560468815691234
.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 DELETE
Object request:
curl -X DELETE \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "https://storage.googleapis.com/BUCKET_NAME/OBJECT_NAME?generation=GENERATION_NUMBER"
Where:
BUCKET_NAME
is the name of the bucket containing the noncurrent version you want to delete. For example, my-bucket
.OBJECT_NAME
is the URL-encoded name of the noncurrent version you want to delete. For example, pets/dog.png
, URL-encoded as pets%2Fdog.png
.GENERATION_NUMBER
is the generation number for the noncurrent version you want to delete. For example, 1560468815691234
.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