A bucket is a container that is used to store objects in Object Storage Service (OSS). All objects in OSS are contained in buckets. This topic describes how to delete a bucket.

  • Before you delete a bucket, you must delete all objects in the bucket, LiveChannel objects, and fragments generated by multipart uploads. For more information about the API operation that you can call to delete a LiveChannel object, see DeleteLiveChannel.
  • To delete a bucket in which incomplete multipart upload tasks exist, you must first call listUploads and abortMultipartUpload to cancel the tasks.


The following code provides an example on how to delete a specified bucket:

const OSS = require('ali-oss');

const client = new OSS({
  // Specify the region in which the bucket is located. For example, if the bucket is located in the China (Hangzhou) region, set the region to oss-cn-hangzhou. 
  region: 'yourregion',
  // The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in OSS is a high-risk operation. We recommend that you use a RAM user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. 
  accessKeyId: 'yourAccessKeyId',
  accessKeySecret: 'yourAccessKeySecret'

async function deleteBucket() {
  try {
    // Specify the bucket name. 
    const result = await client.deleteBucket('yourbucketname');
  } catch (err) {



  • For the complete sample code that is used to delete a bucket, visit GitHub.
  • For more information about the API operation that you can call to delete a bucket, see DeleteBucket.