Updated on 2026-03-06 GMT+08:00

Deleting Buckets

Functions

This operation deletes specified buckets. This operation can be performed only by the bucket owner and users who have been authorized (via a policy) with the permission to delete the bucket. The bucket to be deleted must be an empty bucket. If a bucket has an object or a multipart task, the bucket is not empty. You can list objects and multipart upload tasks in a bucket to check whether the bucket is empty.

Note:

If the server returns a 5XX error or times out when a bucket is being deleted, the system needs to synchronize the bucket information. During this period, the bucket information may be inaccurate. Therefore, wait a while and then check whether the bucket is successfully deleted. If the bucket can still be queried, send the deletion request again.

Authorization Information

To call this API, you must be the bucket owner or have the permission to delete a bucket. You are advised to use IAM or bucket policies for authorization. For details about OBS authorization methods, see Differences Between OBS Permissions Control Methods.

  • If you use IAM for authorization, you need to use either role/policy-based authorization or identity policy-based authorization and configure the required permissions:
    • If you use role/policy-based authorization (IAM v3 APIs in the old IAM version), you need to grant the obs:bucket:DeleteBucket permission. For details, see Creating a Custom IAM Policy.
    • If you use identity policy-based authorization (IAM v5 APIs in the new IAM version), you need to grant the obs:bucket:deleteBucket permission, as shown in the following table. For details, see Creating a Custom IAM Identity Policy.

      Action

      Access Level

      Resource Type (*: Required)

      Condition Key

      Alias

      Dependencies

      obs:bucket:deleteBucket

      Write

      bucket *

      -

      -

      -

      • obs:EpochTime
      • obs:SourceIp
      • obs:TlsVersion
      • obs:CustomDomain

      -

  • If you use bucket policies for authorization, you need to grant the obs:bucket:DeleteBucket permission. For details, see Creating a Custom Bucket Policy.

Request Syntax

1
2
3
4
DELETE / HTTP/1.1 
Host: bucketname.obs.region.myhuaweicloud.com 
Date: date
Authorization: authorization

Request Parameters

This request contains no parameters.

Request Headers

This request uses common request headers. For details, see Table 3.

Request Elements

This request involves no elements.

Response Syntax

1
2
HTTP/1.1 status_code
Date: date

Response Headers

The response to the request uses common headers. For details, see Table 1.

Response Elements

This response contains no elements.

Error Responses

No special error responses are returned. For details about error responses, see Table 2.

Sample Request

1
2
3
4
5
6
DELETE / HTTP/1.1
User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Accept: */*
Date: WED, 01 Jul 2015 02:31:25 GMT
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:jZiAT8Vx4azWEvPRMWi0X5BpJMA=

Sample Response

1
2
3
4
5
HTTP/1.1 204 No Content
Server: OBS
x-obs-request-id: BF260000016435DE6D67C35F9B969C47
x-obs-id-2: 32AAAQAAEAABKAAQAAEAABAAAQAAEAABCTukraCnXLsb7lEw4ZKjzDWWhzXdgme3
Date: WED, 01 Jul 2015 02:31:25 GMT

Sample Request: Deleting a Bucket That Does Not Exist

DELETE / HTTP/1.1
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:iqSPeUBl66PwXDApxjRKk6hlcN4=User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Date: WED, 01 Jul 2015 02:37:22 GMT
Content-Type: application/xml;charset=UTF-8

Sample Response: Deleting a Bucket That Does Not Exist

x-obs-id-2: "32AAAQAAEAABAAAQAAEAABAAAQAAEAABCTBZPaontVN8iyR2NNEeTPRDdcmPVNFm
x-obs-request-id: "0000018A4E4567BD47CF110EE1B2A4DF
Server: OBS
Content-Length: 314
Date: WED, 01 Jul 2015 02:37:22 GMT
Content-Type: application/xml
 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
    <Code>NoSuchBucket</Code>
    <Message>The specified bucket does not exist</Message>
    <RequestId>0000018A4E4567BD47CF110EE1B2A4DF</RequestId>
    <HostId>DRmhM6VfpWGBYYGrx6tpvbs8yoGi+uvlu5/20rpZ/Y2kTuq9mRuCXeA84734xs0+</HostId>
    <BucketName>examplebucket</BucketName>
</Error>

Sample Request: Deleting a Non-Empty Bucket

DELETE / HTTP/1.1
Authorization: OBS H4IPJX0TQTHTHEBQQCEC:iqSPeUBl66PwXDApxjRKk6hlcN4=User-Agent: curl/7.29.0
Host: examplebucket.obs.region.myhuaweicloud.com
Date: WED, 01 Jul 2015 02:37:22 GMT
Content-Type: application/xml;charset=UTF-8

Sample Response: Deleting a Non-Empty Bucket

x-obs-id-2: "32AAAQAAEAABAAAQAAEAABAAAQAAEAABCTBZPaontVN8iyR2NNEeTPRDdcmPVNFm
x-obs-request-id: "0000018A4E4567BD47CF110EE1B2A4DF
Server: OBS
Content-Length: 314
Date: WED, 01 Jul 2015 02:37:22 GMT
Content-Type: application/xml
 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Error>
    <Code>BucketNotEmpty</Code>
    <Message>The bucket you tried to delete is not empty</Message>
    <RequestId>0000018A4E4D04BBD304AD8E409873EC</RequestId>
    <HostId>hME9234LDBKRFuuobDsmyUiP5Oq71oYo1vEL348QzfXHUoGs1RU1TgrOMUKTEMtA</HostId>
    <BucketName>examplebucket</BucketName>
</Error>