Skip to content
Start here

Patch Bucket

client.R2.Buckets.Edit(ctx, bucketName, params) (*Bucket, error)
PATCH/accounts/{account_id}/r2/buckets/{bucket_name}

Updates properties of an existing R2 bucket.

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
AccountID param.Field[string]

Path param: Account ID.

maxLength32
StorageClass param.Field[BucketEditParamsCfR2StorageClass]

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

const BucketEditParamsCfR2StorageClassStandard BucketEditParamsCfR2StorageClass = "Standard"
const BucketEditParamsCfR2StorageClassInfrequentAccess BucketEditParamsCfR2StorageClass = "InfrequentAccess"
Jurisdiction param.Field[BucketEditParamsCfR2Jurisdiction]optional

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

const BucketEditParamsCfR2JurisdictionDefault BucketEditParamsCfR2Jurisdiction = "default"
const BucketEditParamsCfR2JurisdictionEu BucketEditParamsCfR2Jurisdiction = "eu"
const BucketEditParamsCfR2JurisdictionFedramp BucketEditParamsCfR2Jurisdiction = "fedramp"
ReturnsExpand Collapse
type Bucket struct{…}

A single R2 bucket.

CreationDate stringoptional

Creation timestamp.

Jurisdiction BucketJurisdictionoptional

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

One of the following:
const BucketJurisdictionDefault BucketJurisdiction = "default"
const BucketJurisdictionEu BucketJurisdiction = "eu"
const BucketJurisdictionFedramp BucketJurisdiction = "fedramp"
Location BucketLocationoptional

Location of the bucket.

One of the following:
const BucketLocationApac BucketLocation = "apac"
const BucketLocationEeur BucketLocation = "eeur"
const BucketLocationEnam BucketLocation = "enam"
const BucketLocationWeur BucketLocation = "weur"
const BucketLocationWnam BucketLocation = "wnam"
const BucketLocationOc BucketLocation = "oc"
Name stringoptional

Name of the bucket.

maxLength64
minLength3
StorageClass BucketStorageClassoptional

Storage class for newly uploaded objects, unless specified otherwise.

One of the following:
const BucketStorageClassStandard BucketStorageClass = "Standard"
const BucketStorageClassInfrequentAccess BucketStorageClass = "InfrequentAccess"

Patch Bucket

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/option"
  "github.com/cloudflare/cloudflare-go/r2"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  bucket, err := client.R2.Buckets.Edit(
    context.TODO(),
    "example-bucket",
    r2.BucketEditParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
      StorageClass: cloudflare.F(r2.BucketEditParamsCfR2StorageClassStandard),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", bucket.CreationDate)
}
{
  "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
}