---
title: List Buckets
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/go)

[R2](https://developers.cloudflare.com/api/go/resources/r2)

[Buckets](https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# List Buckets

client.R2.Buckets.List(ctx, params) (\*[BucketListResponse](<https://developers.cloudflare.com/api/go/resources/r2#(resource)%20r2.buckets%20%3E%20(model)%20BucketListResponse%20%3E%20(schema)>), error)

GET/accounts/{account\_id}/r2/buckets

Lists a page of R2 buckets in the account and selected jurisdiction. Use the returned cursor to retrieve the next page.

##### Security

API Token

The preferred authorization scheme for interacting with the Cloudflare API. [Create a token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/).

**Example:**`Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY`

##### Accepted Permissions (at least one required)

`Workers R2 Storage Write``Workers R2 Storage Read`

##### ParametersExpand Collapse

<details>

<summary>

params BucketListParams

</summary>

AccountID param.Field\[string]

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

maxLength32

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

Cursor param.Field\[string]Optional

Query param: Pagination cursor received during the last List Buckets call. R2 buckets are paginated using cursors instead of page numbers.

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cursor">Link to this property</a>

<details>

<summary>

Direction param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20direction%20%3E%20(schema)">BucketListParamsDirection</a>]Optional

Query param: Direction to order buckets.

</summary>

const BucketListParamsDirectionAsc <a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20direction%20%3E%20(schema)">BucketListParamsDirection</a> = "asc"

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20direction%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const BucketListParamsDirectionDesc <a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20direction%20%3E%20(schema)">BucketListParamsDirection</a> = "desc"

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20direction%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20direction">Link to this property</a>

NameContains param.Field\[string]Optional

Query param: Bucket names to filter by. Only buckets with this phrase in their name will be returned.

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20name_contains">Link to this property</a>

<details>

<summary>

Order param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20order%20%3E%20(schema)">BucketListParamsOrder</a>]Optional

Query param: Field to order buckets by.

</summary>

const BucketListParamsOrderName <a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20order%20%3E%20(schema)">BucketListParamsOrder</a> = "name"

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20order%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

</details>

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20order">Link to this property</a>

PerPage param.Field\[float64]Optional

Query param: Maximum number of buckets to return in a single call.

maximum1000

minimum1

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20per_page">Link to this property</a>

StartAfter param.Field\[string]Optional

Query param: Bucket name to start searching after. Buckets are ordered lexicographically.

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20start_after">Link to this property</a>

<details>

<summary>

CfR2Jurisdiction param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)">BucketListParamsCfR2Jurisdiction</a>]Optional

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

</summary>

const BucketListParamsCfR2JurisdictionDefault <a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)">BucketListParamsCfR2Jurisdiction</a> = "default"

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const BucketListParamsCfR2JurisdictionEu <a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)">BucketListParamsCfR2Jurisdiction</a> = "eu"

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const BucketListParamsCfR2JurisdictionUs <a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)">BucketListParamsCfR2Jurisdiction</a> = "us"

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

const BucketListParamsCfR2JurisdictionFedramp <a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)">BucketListParamsCfR2Jurisdiction</a> = "fedramp"

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)%20%3E%20(member)%203">Link to this property</a>

const BucketListParamsCfR2JurisdictionFedrampHigh <a href="https://developers.cloudflare.com/api/go/resources/r2/subresources/buckets/methods/list#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)">BucketListParamsCfR2Jurisdiction</a> = "fedramp-high"

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction%20%3E%20(schema)%20%3E%20(member)%204">Link to this property</a>

</details>

<a href="#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default%20%3E%20(param)%20cf-r2-jurisdiction">Link to this property</a>

</details>

[Link to this property](<#(resource)%20r2.buckets%20%3E%20(method)%20list%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type BucketListResponse struct{…}

</summary>

<details>

<summary>

Buckets \[]<a href="https://developers.cloudflare.com/api/go/resources/r2#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)">Bucket</a>Optional

</summary>

CreationDate stringOptional

Creation timestamp.

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20creation_date">Link to this property</a>

<details>

<summary>

Jurisdiction BucketJurisdictionOptional

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

</summary>

One of the following:

const BucketJurisdictionDefault BucketJurisdiction = "default"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%200">Link to this property</a>

const BucketJurisdictionEu BucketJurisdiction = "eu"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%201">Link to this property</a>

const BucketJurisdictionUs BucketJurisdiction = "us"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%202">Link to this property</a>

const BucketJurisdictionFedramp BucketJurisdiction = "fedramp"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%203">Link to this property</a>

const BucketJurisdictionFedrampHigh BucketJurisdiction = "fedramp-high"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20jurisdiction%20%3E%20(member)%204">Link to this property</a>

</details>

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20jurisdiction">Link to this property</a>

<details>

<summary>

Location BucketLocationOptional

Location of the bucket.

</summary>

One of the following:

const BucketLocationApac BucketLocation = "apac"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20location%20%3E%20(member)%200">Link to this property</a>

const BucketLocationEeur BucketLocation = "eeur"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20location%20%3E%20(member)%201">Link to this property</a>

const BucketLocationEnam BucketLocation = "enam"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20location%20%3E%20(member)%202">Link to this property</a>

const BucketLocationWeur BucketLocation = "weur"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20location%20%3E%20(member)%203">Link to this property</a>

const BucketLocationWnam BucketLocation = "wnam"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20location%20%3E%20(member)%204">Link to this property</a>

const BucketLocationOc BucketLocation = "oc"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20location%20%3E%20(member)%205">Link to this property</a>

</details>

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20location">Link to this property</a>

Name stringOptional

Name of the bucket.

maxLength64

minLength3

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20name">Link to this property</a>

<details>

<summary>

StorageClass BucketStorageClassOptional

Storage class for newly uploaded objects, unless specified otherwise.

</summary>

One of the following:

const BucketStorageClassStandard BucketStorageClass = "Standard"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20storage_class%20%3E%20(member)%200">Link to this property</a>

const BucketStorageClassInfrequentAccess BucketStorageClass = "InfrequentAccess"

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20storage_class%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20bucket%20%3E%20(schema)%20%3E%20(property)%20storage_class">Link to this property</a>

</details>

<a href="#(resource)%20r2.buckets%20%3E%20(model)%20BucketListResponse%20%3E%20(schema)%20%3E%20(property)%20buckets">Link to this property</a>

</details>

[Link to this property](<#(resource)%20r2.buckets%20%3E%20(model)%20BucketListResponse%20%3E%20(schema)>)

### List Buckets

Go

HTTPTypeScriptPythonGoTerraform

```
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"),
  )
  buckets, err := client.R2.Buckets.List(context.TODO(), r2.BucketListParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", buckets.Buckets)
}
```

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "buckets": [
      {
        "creation_date": "creation_date",
        "jurisdiction": "default",
        "location": "apac",
        "name": "example-bucket",
        "storage_class": "Standard"
      }
    ]
  },
  "success": true,
  "result_info": {
    "cursor": "1-JTdCJTIydiUyMiUzQTElMkMlMjJzdGFydEFmdGVyJTIyJTNBJTIyZGF2aWRwdWJsaWMlMjIlN0Q=",
    "per_page": 20
  }
}
```

##### Returns Examples

200 example

```
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    "string"
  ],
  "result": {
    "buckets": [
      {
        "creation_date": "creation_date",
        "jurisdiction": "default",
        "location": "apac",
        "name": "example-bucket",
        "storage_class": "Standard"
      }
    ]
  },
  "success": true,
  "result_info": {
    "cursor": "1-JTdCJTIydiUyMiUzQTElMkMlMjJzdGFydEFmdGVyJTIyJTNBJTIyZGF2aWRwdWJsaWMlMjIlN0Q=",
    "per_page": 20
  }
}
```