Objects: patch Stay organized with collections Save and categorize content based on your preferences.
Updates a data blob's associated metadata. This method supportspatch semantics.
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 the
retentionproperty:storage.objects.setRetention - To use the
overrideUnlockedRetentionquery parameter:storage.objects.overrideUnlockedRetention - To update object access control lists (ACLs) for buckets withuniform bucket-level access disabled:
storage.objects.setIamPolicy - To return ACLs as part of the response:
storage.objects.getIamPolicy - To attachobject contexts (Preview):
storage.objects.createContext - To update object contexts:
storage.objects.updateContext - To remove object contexts:
storage.objects.deleteContext
Request
HTTP request
PATCH 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 name | Value | Description |
|---|---|---|
| Path parameters | ||
bucket | string | Name of the bucket in which the object resides. |
object | string | Name of the object. For information about how to URL encode object names to be path safe, seeEncoding URI path parts. |
| Optional query parameters | ||
generation | long | If present, selects a specific revision of this object (as opposed to the latest version, the default). |
ifGenerationMatch | long | 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. |
ifGenerationNotMatch | long | 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. |
ifMetagenerationMatch | long | Makes the operation conditional on whether the object's current metageneration matches the given value. |
ifMetagenerationNotMatch | long | Makes the operation conditional on whether the object's current metageneration does not match the given value. |
overrideUnlockedRetention | boolean | 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. |
predefinedAcl | string | Apply a predefined set of access controls to this object. Acceptable values are:
iamConfiguration.uniformBucketLevelAccess.enabled is set totrue, requests that include this parameter fail with a400 Bad Request response. |
projection | string | Set of properties to return. Defaults tonoAcl, unless the object resource specifies theacl property, when it defaults tofull.Acceptable values are:
|
| Optional extension headers | ||
X-Goog-Encryption-Algorithm | string | 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-Key | string | 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-Sha256 | string | 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 the relevant portions of anobject resource, according to the rules of patch semantics.
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 2025-12-17 UTC.