Updated on 2026-04-16 GMT+08:00

Deleting Buckets

Functions

This API is used to delete buckets. Only the bucket owner or a user who has the bucket deletion permission can delete the bucket. For more information about deleting buckets, see Deleting a Bucket.

Important Notes

  • If a 5XX error is returned or the request times out when you delete a bucket, the system may be processing bucket information consistency. During this period, the bucket information may be inaccurate. Wait for a while and then check whether the bucket is successfully deleted. If the bucket fails to be deleted, that is, the bucket can still be queried, call this API again to delete the bucket.

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

The following is an example request. Replace BucketName with your bucket name and RegionID with the ID of the region where your bucket resides. You can obtain the region ID by referring to Supported Regions.

DELETE / HTTP/1.1 
Host: BucketName.obs.RegionID.myhuaweicloud.com 
Date: GMT Date
Authorization: SignatureValue

URI parameters

The request of this API contains no URI parameters.

Request Headers

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

Request Body

This request contains no request body parameters.

Response Syntax

HTTP/1.1 status_code
Date: GMT Date

Response Headers

This response uses common headers. For details, see Table 1.

Response Body

The response of this API does not contain a response body.

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>

Using SDKs to Call APIs

You are advised to use OBS SDKs to call APIs. SDKs encapsulate APIs to simplify development. You can call SDK API functions to access OBS without manually calculating signatures.

References