Deletes an empty bucket. The request fails if there are any objects in the bucket, but the request succeeds if the bucket only contains soft-deleted objects or incomplete uploads, such as ongoing XML API multipart uploads. Does not delete soft-deleted objects.
The DELETE Bucket method is a simple DELETE request with bucket scope. You must have the project owners role to delete buckets. Also, all DELETE Bucket requests must be authenticated.
As a best practice, after you delete all of the objects from a bucket you should set the bucket ACLs so that no users can create objects in the bucket.
If there are objects in the bucket when you attempt to delete it you will get a
409 Conflict status code and the
body of the error response will contain BucketNotEmpty
in the
Code
element.
If the bucket does not exist you will get a
404 Not Found status code and the
body of the error response will contain NoSuchBucket
in the
Code
element.
Query string parameters
This request does not typically include query string parameters.
See signed URL query string parameters for information on the parameters you include when creating and using signed URLs.
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-user-project |
The project to be billed for charges associated with the request. | No |
Request body elements
This request does not include an XML document in the request body.
Request syntax
DELETE / HTTP/1.1 Host: BUCKET_NAME.storage.googleapis.com Date: DATE Content-Length: 0 Authorization: AUTHENTICATION_STRING
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 example deletes a bucket named travel-maps.
Request
DELETE / 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 Expires: Mon, 15 Feb 2010 11:00:01 GMT