Objects: update

Updates the metadata of an object.

Caution: You should generally use thePATCH method, which changes only metadata you define in the request. The UPDATE method always attempts to change certain metadata fields for the object, even if those fields are not specified in the request.

Required permissions

The authenticated user must have thestorage.objects.update IAM permission to use this method.

Additionally, the following permissions are required for specific request properties or parameters:

  • If the request body includes theretention property:storage.objects.setRetention
  • To use theoverrideUnlockedRetention query parameter:storage.objects.overrideUnlockedRetention
  • To update object access control lists (ACLs), which only apply to objects stored in buckets withuniform bucket-level access disabled:storage.objects.setIamPolicy
  • To return ACLs as part of the response:storage.objects.getIamPolicy
  • To attach object contexts:storage.objects.createContext
  • To update object contexts:storage.objects.updateContext
  • To remove object contexts:storage.objects.deleteContext

Request

HTTP request

PUT https://storage.googleapis.com/storage/v1/b/bucket/o/object

In addition tostandard query parameters, the following query parameters apply to this method.

To see an example of how to include query parameters in a request, see theJSON API Overview page.

Parameters

Parameter nameValueDescription
Path parameters
bucketstring Name of the bucket in which the object resides.
objectstring Name of the object. For information about how to URL encode object names to be path safe, seeEncoding URI path parts.
Optional query parameters
generationlong If present, selects a specific revision of this object (as opposed to the latest version, the default).
ifGenerationMatchlong Makes the operation conditional on whether the object's current generation matches the given value. Setting to 0 makes the operation succeed only if there are no live versions of the object.
ifGenerationNotMatchlong Makes the operation conditional on whether the object's current generation does not match the given value. If no live object exists, the precondition fails. Setting to 0 makes the operation succeed only if there is a live version of the object.
ifMetagenerationMatchlong Makes the operation conditional on whether the object's current metageneration matches the given value.
ifMetagenerationNotMatchlong Makes the operation conditional on whether the object's current metageneration does not match the given value.
overrideUnlockedRetentionboolean Applicable for object's that have an unlockedretention configuration: Required to be set totrue if the operation includes aretention property that changes themode toLocked, reduces theretainUntilTime, or removes the retention configuration from the object.
predefinedAclstring Apply a predefined set of access controls to this object.

Acceptable values are:
  • authenticatedRead: Object owner getsOWNER access, andallAuthenticatedUsers getREADER access.
  • bucketOwnerFullControl: Object owner getsOWNER access, and project team owners getOWNER access.
  • bucketOwnerRead: Object owner getsOWNER access, and project team owners getREADER access.
  • private: Object owner getsOWNER access.
  • projectPrivate: Object owner getsOWNER access, and project team members get access according to their roles.
  • publicRead: Object owner getsOWNER access, andallUsers getREADER access.
IfiamConfiguration.uniformBucketLevelAccess.enabled is set totrue, requests that include this parameter fail with a400 Bad Request response.
projectionstring Set of properties to return. Defaults tofull.

Acceptable values are:
  • full: Include all properties.
  • noAcl: Omit theowner,acl property.
Optional extension headers
X-Goog-Encryption-Algorithmstring The encryption algorithm to use, which must beAES256. Use this header if the object is encrypted with acustomer-supplied encryption key and you want the object's content hashes returned in the response.
X-Goog-Encryption-Keystring AnRFC 4648 Base64-encoded string of your AES-256 encryption key. Use this header if the object is encrypted with acustomer-supplied encryption key and you want the object's content hashes returned in the response.
X-Goog-Encryption-Key-Sha256string AnRFC 4648 Base64-encoded string of the SHA256 hash of your encryption key. Use this header if the object is encrypted with acustomer-supplied encryption key and you want the object's content hashes returned in the response.

Request body

In the request body, supply anobject resource with any of the following optional properties:

Property nameValueDescriptionNotes
acl[]list

Access controls on the object. If empty, this parameter is ignored. Can contain one or moreobjectAccessControls Resources.

Note: ACLs do not apply to objects in buckets whereiamConfiguration.uniformBucketLevelAccess.enabled is set totrue. Requests to such objects fail with a400 Bad Request response if the request contains a non-emptyacl[] property.
writable
cacheControlstringCache-Control directive for the object data. If omitted, and the object is accessible to all anonymous users, the default will be"public, max-age=3600". writable
contentDispositionstringContent-Disposition of the object data. writable
contentEncodingstringContent-Encoding of the object data. writable
contentLanguagestringContent-Language of the object data. writable
contentTypestringContent-Type of the object data. If an object is stored without a Content-Type, it is served as application/octet-stream. writable
contextsobjectContexts attached to the object, specified in key-value pairs. For more information about object contexts (Preview), seeObject context overview. For specific JSON formats and combinations, seeAttach or modify contexts to an existing object. writable
customTimedatetime1A user-specified timestamp for the object inRFC 3339 format. If the object hascustomTime metadata already set on it, any update request must include acustomTime with an equal or later datetime. writable
eventBasedHoldbooleanWhether or not the object is subject to anevent-based hold. writable
metadataobjectUser-provided metadata, in key/value pairs. writable
metadata.(key)stringAn individual metadata entry. writable
retentionobjectThe object'sretention configuration, which defines the earliest datetime that the object can be deleted or replaced. writable
retention.modestringThe mode of the retention configuration, which can be eitherUnlocked orLocked. If set toLocked,retention.mode cannot be changed, the retention configuration cannot be removed, andretention.retainUntilTime cannot be reduced. writable
retention.retainUntilTimedatetime1The earliest time that the object can be deleted or replaced, inRFC 3339 format. This property has a maximum value of 3,155,760,000 seconds (100 years) from the current date and time. writable
temporaryHoldbooleanWhether or not the object is subject to atemporary hold. writable
1 This property is a string formatted as the specified value type.

Response

If successful, this method returns anobject resource in the response body.

For information about status and error codes returned by this API, see thereference page.

Try it!

Use the APIs Explorer below to call this method on live data and see the response.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.