DELETE Object

Deletes an object.

If you make a DELETE request for an object that doesn't exist, you will get a 404 Not Found status code and the body of the error response will contain NoSuchKey in the Code element.

Query string parameters

Parameter Description Required
generation You can use this if you want to delete a specific object generation. If this query parameter is used on a versioned bucket and the object is the current one, no archive of the object is made, but instead the object is deleted completely. No

Request headers

Header Description Required
Authorization The authentication string for the request. Yes
Content-Length

The length of the request body without headers (in bytes).

* Not required for requests that use chunked transfer encoding.

Yes*
Date The date and time of the request. Yes
Host The URI for Cloud Storage. For more information, see Request Endpoints. Yes
x-goog-if-generation-match If the generation you specify is the same as the current object, then the object is deleted. No

Request body elements

This request does not include an XML document in the request body.

Request syntax

DELETE /<object> HTTP/1.1
Host: <bucket>.storage.googleapis.com
Date: <date>
Content-Length: <request body length>
Authorization: Bearer ya29.AHES6ZRVmB7fkLtd1XTmq6mo0S1wqZZi3-Lh_s-6Uw7p8vtgSwg

Response headers

The request can return a variety of response headers depending on the request headers you use.

Response body elements

The response does not include an XML document in the response body.

Example

The following sample deletes an object named paris.jpg.

Request

DELETE /paris.jpg HTTP/1.1
Host: travel-maps.storage.googleapis.com
Date: Mon, 15 Feb  2010 11:00:00 GMT
Content-Length: 0
Authorization: Bearer ya29.AHES6ZRVmB7fkLtd1XTmq6mo0S1wqZZi3-Lh_s-6Uw7p8vtgSwg

Response

HTTP/1.1 204 No Content
Date: Mon, 15 Feb  2010 11:00:01 GMT

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Cloud Storage Documentation