Skip to content
Start here

Patch Bucket

client.r2.buckets.edit(stringbucketName, BucketEditParams { account_id, storage_class, cfR2Jurisdiction } params, RequestOptionsoptions?): Bucket { creation_date, jurisdiction, location, 2 more }
PATCH/accounts/{account_id}/r2/buckets/{bucket_name}

Changes the default storage class for newly uploaded objects in an existing R2 bucket. Existing objects retain their storage class, and individual uploads can override the bucket default.

Security

API Token

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

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
ParametersExpand Collapse
bucketName: string

Name of the bucket.

maxLength64
minLength3
params: BucketEditParams { account_id, storage_class, cfR2Jurisdiction }
account_id: string

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

maxLength32
storage_class: "Standard" | "InfrequentAccess"

Header param: Storage class for newly uploaded objects, unless specified otherwise.

One of the following:
"Standard"
"InfrequentAccess"
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
Bucket { creation_date, jurisdiction, location, 2 more }

A single R2 bucket.

creation_date?: string

Creation timestamp.

jurisdiction?: "default" | "eu" | "us" | 2 more

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

One of the following:
"default"
"eu"
"us"
"fedramp"
"fedramp-high"
location?: "apac" | "eeur" | "enam" | 3 more

Location of the bucket.

One of the following:
"apac"
"eeur"
"enam"
"weur"
"wnam"
"oc"
name?: string

Name of the bucket.

maxLength64
minLength3
storage_class?: "Standard" | "InfrequentAccess"

Storage class for newly uploaded objects, unless specified otherwise.

One of the following:
"Standard"
"InfrequentAccess"

Patch 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.edit('example-bucket', {
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  storage_class: 'Standard',
});

console.log(bucket.creation_date);
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "creation_date": "creation_date",
    "jurisdiction": "default",
    "location": "apac",
    "name": "example-bucket",
    "storage_class": "Standard"
  },
  "success": true
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "creation_date": "creation_date",
    "jurisdiction": "default",
    "location": "apac",
    "name": "example-bucket",
    "storage_class": "Standard"
  },
  "success": true
}