Stay organized with collectionsSave and categorize content based on your preferences.
Stores a new object and metadata. The uploaded object replaces any existing object
with the same name. For an overview of uploading to Cloud Storage, seeUploads and downloads. For examples of performing
object uploads with different Cloud Storage tools and client libraries, see theUploading Objects guide.
This method accepts uploaded object data with the following characteristics:
Maximum file size:5 TiB
Accepted Media MIME types:*/*
This method generally requires the following headers be included in a request:
Note: Metadata-only requests arenotallowed. To change an object's metadata,
use thepatchmethod.
Required permissions
The authenticated user must have thestorage.objects.createIAM
permission to use this method. If the object being inserted has the same name as an existing
object, the user must also have thestorage.objects.deletepermission to overwrite the
existing object. If the request body includes theretentionproperty, the
authenticated user must also have thestorage.objects.setRetentionIAM
permission.
Request
HTTP request
Note: Therequest endpointfor this method
differs from typical Cloud Storage JSON API endpoints.
POST https://storage.googleapis.com/upload/storage/v1/b/bucket/o
In addition tostandard query parameters,
the following query parameters apply to this method. Note that forresumable uploads, these headers can be used in the
initialPOSTrequest but are ignored in the subsequentPUTrequests.
To see an example of how to include query parameters in a request, see theJSON API Overviewpage.
Parameters
Parameter name
Value
Description
Path parameters
bucket
string
Name of the bucket in which to store the new object. Overrides the provided object
metadata'sbucketvalue, if any.
Required query parameters
name
string
Name of the object. Not required if the request body contains object metadata that
includes anamevalue. Overrides the object metadata'snamevalue, if any. For information about how to URL encode object names to be path safe, seeEncoding URI path parts.
media- Data-only upload. Upload the object data only, without any
metadata.
multipart- Multipart upload. Upload both the object data and its
metadata, in a single request.
resumable- Resumable upload. Upload the object data in a resumable
fashion, using a series of at least two requests where the first request includes the
metadata.
Optional query parameters
contentEncoding
string
If set, sets thecontentEncodingproperty of the final object to this value.
Setting this parameter is equivalent to setting thecontentEncodingmetadata
property. This can be useful when uploading an object withuploadType=mediato indicate the encoding of the content being uploaded.
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. For more information, seeRequest preconditions.
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. For more information, seeRequest preconditions.
ifMetagenerationMatch
long
Makes the operation conditional on whether the object's current metageneration matches
the given value. For more information, seeRequest preconditions.
ifMetagenerationNotMatch
long
Makes the operation conditional on whether the object's current metageneration does not
match the given value. For more information, seeRequest preconditions.
Applicable only when used the final request of aresumable upload. An optional way to setcustom metadatafor the uploaded
object.
Request body
When performing asimple upload, provide the
object data in the request body. When performing amultipart uploador when
initiating aresumable upload, both of which allow
you to include object metadata as part of the request, supply the following properties. If you
do not wish to provide object metadata in a resumable upload, the request body can be empty.
Property name
Value
Description
Notes
Optional Properties
acl[]
list
Access controls on the object, containing one or moreobjectAccessControls
Resources. Do not supply this field ifiamConfiguration.uniformBucketLevelAccess.enabledistruefor
the bucket to which you are uploading the object.
writable
cacheControl
string
Cache-Controldirective for the object data. If omitted, and the object is accessible to all anonymous
users, the default will be"public, max-age=3600".
Content-Typeof the object data. If an object is stored without a Content-Type, it is served as
application/octet-stream.
writable
crc32c
string
CRC32c checksum, as described inRFC 4960,
Appendix B; encoded usingbase64in
big-endian byte order. For more information about using the CRC32c checksum, seeData validation.
writable
customTime
datetime1
A user-specified timestamp for the object inRFC 3339format.
MD5 hash of the data; encoded usingbase64.
For more information about using the MD5 hash, seeData validation.
writable
metadata
object
User-provided metadata, in key/value pairs.
writable
metadata.(key)
string
An individual metadata entry.
writable
name
string
The name of the object. Required if not specified by URL parameter.
writable
retention
object
The object'sretention configuration, which
defines the earliest datetime that the object can be deleted or replaced.
writable
retention.mode
string
The mode of the retention configuration, which can be eitherUnlockedorLocked. If set toLocked,retention.modecannot be
changed, the retention configuration cannot be removed, andretention.retainUntilTimecannot be reduced.
writable
retention.retainUntilTime
datetime1
The earliest time that the object can be deleted or replaced,
inRFC 3339format. This property has a maximum value of 3,155,760,000 seconds (100 years) from the
current date and time.
writable
storageClass
string
Storage class of the object.
writable
temporaryHold
boolean
Whether or not the object is subject to atemporary hold.
writable
1This property is a string formatted as the specified value type.
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.
[[["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: insert\n\nStores a new object and metadata. The uploaded object replaces any existing object\nwith the same name. For an overview of uploading to Cloud Storage, see\n[Uploads and downloads](/storage/docs/uploads-downloads). For examples of performing\nobject uploads with different Cloud Storage tools and client libraries, see the\n[Uploading Objects guide](/storage/docs/uploading-objects).\n\nThis method accepts uploaded object data with the following characteristics:\n\n- **Maximum file size:** 5 TiB\n- **Accepted Media MIME types:** `*/*`\n\nThis method generally requires the following headers be included in a request:\n\n- [`Content-Length`](/storage/docs/json_api/v1/parameters#contentlength)\n- [`Content-Type`](/storage/docs/json_api/v1/parameters#contenttype)\n\nNote: Metadata-only requests are **not** allowed. To change an object's metadata,\nuse the [patch](/storage/docs/json_api/v1/objects/patch) method.\n\nRequired permissions\n--------------------\n\nThe authenticated user must have the `storage.objects.create` IAM\npermission to use this method. If the object being inserted has the same name as an existing\nobject, the user must also have the `storage.objects.delete` permission to overwrite the\nexisting object. If the request body includes the `retention` property, the\nauthenticated user must also have the `storage.objects.setRetention` IAM\npermission.\n\nRequest\n-------\n\n### HTTP request\n\nNote: The [request endpoint](/storage/docs/request-endpoints) for this method\ndiffers from typical Cloud Storage JSON API endpoints. \n\n```\nPOST https://storage.googleapis.com/upload/storage/v1/b/bucket/o\n```\n\nIn addition to [standard query parameters](/storage/docs/json_api/v1/parameters#query),\nthe following query parameters apply to this method. Note that for\n[resumable uploads](/storage/docs/resumable-uploads), these headers can be used in the\ninitial `POST` request but are ignored in the subsequent `PUT` requests.\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\nWhen performing a [simple upload](/storage/docs/uploading-objects), provide the\nobject data in the request body. When performing a\n[multipart upload](/storage/docs/uploading-objects) or when\ninitiating a [resumable upload](/storage/docs/resumable-uploads), both of which allow\nyou to include object metadata as part of the request, supply the following properties. If you\ndo not wish to provide object metadata in a resumable upload, the request body can be empty.\n\n^1^ This property is a string formatted as the specified value type.\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)."]]