Skip to content
Start here

Delete Bucket

client.r2.buckets.delete(stringbucketName, BucketDeleteParams { account_id, cfR2Jurisdiction } params, RequestOptionsoptions?): BucketDeleteResponse
DELETE/accounts/{account_id}/r2/buckets/{bucket_name}

Deletes an empty R2 bucket and its configuration. The bucket must have no objects, no in-progress multipart uploads, and no event notification rules; otherwise the request fails.

Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
Accepted Permissions (at least one required)
Workers R2 Storage Write
ParametersExpand Collapse
bucketName: string

Name of the bucket.

maxLength64
minLength3
params: BucketDeleteParams { account_id, cfR2Jurisdiction }
account_id: string

Path param: Cloudflare account ID that owns the R2 resource.

maxLength32
cfR2Jurisdiction?: "default" | "eu" | "us" | 2 more

Header param: Jurisdiction where objects in this bucket are guaranteed to be stored.

One of the following:
"default"
"eu"
"us"
"fedramp"
"fedramp-high"
ReturnsExpand Collapse
BucketDeleteResponse = unknown

Delete Bucket

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});

const bucket = await client.r2.buckets.delete('example-bucket', {
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
});

console.log(bucket);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {},
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {},
  "success": true
}