Restores a soft-deleted object .
When a soft-deleted object is restored, a new copy of that object is created in the same bucket. The new object inherits the same metadata as the soft-deleted object. The inherited metadata is the metadata that existed when the original object became soft deleted, with the following exceptions:
- The
createTimeof the new object is set to the time at which the soft-deleted object was restored. - The
softDeleteTimeandhardDeleteTimevalues are cleared. - A new generation is assigned and the metageneration is reset to 1.
- If the soft-deleted object was in a bucket that had Autoclass enabled, the new object is restored to Standard storage.
- The restored object inherits the bucket's default object ACL, unless
copySourceAclistrue.
If a live object using the same name already exists in the bucket and becomes overwritten, the live object becomes a noncurrent object if Object Versioning is enabled on the bucket. If Object Versioning is not enabled, the live object becomes soft deleted.
Request
HTTP request
POST https://storage.googleapis.com/storage/v1/b/ bucket /o/ object /restore
In addition to standard query parameters , the following query parameters apply to this method.
To see an example of how to include query parameters in a request, see the JSON API Overview page.
Parameters
bucket
string
object
string
generation
long
copySourceAcl
boolean
true
, copies the soft-deleted object's ACL and applies it to the
restored object. If false
or not specified, the restored object inherits
the bucket's default object ACL.ifGenerationMatch
long
ifGenerationMatch
to
0 makes the operation succeed only if there is no such live object.ifGenerationNotMatch
long
ifGenerationNotMatch
to 0 makes the operation
succeed if there is a live version of the object.ifMetagenerationMatch
long
ifMetagenerationNotMatch
long
projection
string
noAcl
.Acceptable values are:
-
full: Include all properties. -
noAcl: Omit theowner,aclproperty.
restoreToken
string
restoreToken
is a universally unique identifier (UUID)
associated with each soft-deleted object
. When restoring a soft-deleted object, the restoreToken
is only
required when the name
and generation
values of the object do not uniquely
identify it
. Otherwise, including a restoreToken
in the request is
optional.
Request body
Do not supply a request body with this method.
Response
If successful, this method returns an object resource in the response body.
The following errors could occur:
- If the specified bucket in the request does not have a soft delete policy, the request fails
with a
400 Bad Requesterror with the reasonSoftDeletePolicyRequired. - If the soft-deleted object's retention duration has passed, or the soft-deleted
object no longer exists, the request fails with a
404 Not Founderror with the reasonnotFound. - If the specified object in the request is not a soft-deleted object but is either live or
noncurrent, the request fails with a
412 Failed Preconditionerror with the reasonobjectNotSoftDeleted. - If the specified object in the request belongs to a bucket that has a Bucket Lock retention policy
, where the object's age is
less than the retention duration, the request fails with a
403 Forbiddenerror with the reasonretentionPolicyNotMet.
For more information about status and error codes returned by this API, see the reference page .
Try it!
Use the APIs Explorer below to call this method on live data and see the response.

