Stay organized with collectionsSave and categorize content based on your preferences.
Copies a source object to a destination object. Optionally overrides metadata.
Generally, you should use therewritemethod instead of thecopymethod: thecopymethod uses therewritemethod, but calls it exactly once. Larger objects can require multiplerewritecalls, so copy attempts of such objects can lead toPayload too largeerrors.
Required permissions
The authenticated user must have the following IAM permissions to use this method:
storage.objects.createon the destination bucket
storage.objects.deleteon the destination bucket, if overwriting an existing object
storage.objects.setRetentionon the destination bucket, if the request body
includes theretentionproperty.
storage.objects.geton the source bucket
Request
HTTP request
POST https://storage.googleapis.com/storage/v1/b/sourceBucket/o/sourceObject/copyTo/b/destinationBucket/o/destinationObject
To see an example of how to include query parameters in a request, see theJSON API Overviewpage.
Parameters
Parameter name
Value
Description
Path parameters
destinationBucket
string
Name of the bucket in which to store the new object. Overrides the provided object
metadata'sbucketvalue, if any. For information about how to URL encode
object names to be path safe,
seeEncoding URI path parts.
destinationObject
string
Name of the new object. Required when the object metadata is not otherwise provided.
Overrides the object metadata'snamevalue, if any.
sourceBucket
string
Name of the bucket in which to find the source object.
sourceObject
string
Name of the source object. For information about how to URL encode object names to be path
safe, seeEncoding URI path parts.
Optional query parameters
destinationKmsKeyName
string
Resource name of the
Cloud KMS keythat will be used to encrypt the object. The Cloud KMS
key must be located in same location as the object.
If the parameter is not specified, the request uses the destination bucket's
default encryption key, if any, or else it usesstandard Cloud Storage
encryption.
If the object is large, re-encryption with the key may take too long and result
in aDeadline exceedederror. For large objects, consider using therewritemethod instead.
destinationPredefinedAcl
string
Apply a predefined set of access controls to the destination object.
IfiamConfiguration.uniformBucketLevelAccess.enabledis set totrue, requests that include this parameter fail with a400 Bad Requestresponse.
ifGenerationMatch
long
Makes the operation conditional on there being a live destination object with a generation
number that matches the given value. SettingifGenerationMatchto 0 makes the
operation succeed only if there is no live destination object.
ifGenerationNotMatch
long
Makes the operation conditional on there being a live destination object with a generation
number that does not match the given value. If no live destination object exists, the
precondition fails. SettingifGenerationNotMatchto 0 makes the operation
succeed if there is a live version of the object.
ifMetagenerationMatch
long
Makes the operation conditional on there being a live destination object with a
metageneration number that matches the given value.
ifMetagenerationNotMatch
long
Makes the operation conditional on there being a live destination object with a
metageneration number that does not match the given value.
ifSourceGenerationMatch
long
Makes the operation conditional on whether the source object's generation matches the
given value.
ifSourceGenerationNotMatch
long
Makes the operation conditional on whether the source object's generation does not match
the given value.
ifSourceMetagenerationMatch
long
Makes the operation conditional on whether the source object's current metageneration
matches the given value.
ifSourceMetagenerationNotMatch
long
Makes the operation conditional on whether the source object's current metageneration
does not match the given value.
projection
string
Set of properties to return. Defaults tonoAcl, unless the object resource
specifies theaclproperty, when it defaults tofull.
Acceptable values are:
full: Include all properties.
noAcl: Omit theowner,aclproperty.
sourceGeneration
long
If present, selects a specific revision of the source object (as opposed to the latest
version, the default).
Optional extension headers
X-Goog-Copy-Source-Encryption-Algorithm
string
The encryption algorithm to use, which must beAES256. Used if the source
object was encrypted with acustomer-supplied
encryption key.
AnRFC 4648Base64-encoded string of the SHA256 hash of the encryption key used to encrypt the source
object, if it was encrypted with acustomer-supplied encryption
key.
X-Goog-Encryption-Algorithm
string
The encryption algorithm to use, which must beAES256. Used for encrypting
the destination object with acustomer-supplied encryption
key.
In the request body, supply metadata to apply to the destination object by using anobject resource. If the request body
is empty,editable metadatafrom the source object
is applied to the destination object, with the exception of any ACLs, object holds, orretentionconfiguration set on the source object. If you want to retain these from
the original object, they must be included in the request body.
Response
If successful, this method returns anobject resourcein 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.
[[["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-09-04 UTC."],[],[],null,["# Objects: copy\n\nCopies a source object to a destination object. Optionally overrides metadata.\n\nGenerally, you should use the [`rewrite`](/storage/docs/json_api/v1/objects/rewrite)\nmethod instead of the `copy` method: the `copy` method uses the\n`rewrite` method, but calls it exactly once. Larger objects can require multiple\n`rewrite` calls, so copy attempts of such objects can lead to\n`Payload too large` errors.\n| **Note:** The copied object does not retain the ACLs of the original object. Instead, it gains any ACLs you specify in the `copy` method or, if you don't specify any ACLs, the default object ACLs of the bucket it is stored in.\n\nRequired permissions\n--------------------\n\nThe authenticated user must have the following IAM permissions to use this method:\n\n- `storage.objects.create` on the destination bucket\n- `storage.objects.delete` on the destination bucket, if overwriting an existing object\n- `storage.objects.setRetention` on the destination bucket, if the request body includes the `retention` property.\n- `storage.objects.get` on the source bucket\n\nRequest\n-------\n\n### HTTP request\n\n```\nPOST https://storage.googleapis.com/storage/v1/b/sourceBucket/o/sourceObject/copyTo/b/destinationBucket/o/destinationObject\n```\n\nIn addition to [standard query parameters](/storage/docs/json_api/v1/parameters#query),\nthe following query parameters apply to this method.\n\nTo see an example of how to include query parameters in a request, see the\n[JSON API Overview](/storage/docs/json_api#query_parameters) page.\n\n### Parameters\n\n### Request body\n\nIn the request body, supply metadata to apply to the destination object by using an\n[object resource](/storage/docs/json_api/v1/objects#resource). If the request body\nis empty, [editable metadata](/storage/docs/metadata#editable) from the source object\nis applied to the destination object, with the exception of any ACLs, object holds, or\n`retention` configuration set on the source object. If you want to retain these from\nthe original object, they must be included in the request body.\n\nResponse\n--------\n\nIf successful, this method returns an\n[object resource](/storage/docs/json_api/v1/objects#resource) in the response\nbody.\n\nFor information about status and error codes returned by this API, see the\n[reference page](/storage/docs/json_api/v1/status-codes).\n\nTry it!\n-------\n\nUse the APIs Explorer below to call this method on live data and see the response."]]