Skip to content
Start here

List namespaces in catalog

client.R2DataCatalog.Namespaces.List(ctx, bucketName, params) (*NamespaceListResponse, error)
GET/accounts/{account_id}/r2-catalog/{bucket_name}/namespaces

Returns a list of namespaces in the specified R2 catalog. Supports hierarchical filtering and pagination for efficient traversal of large namespace hierarchies.

Security
API Token

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

Example:Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY
API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Workers R2 Data Catalog WriteWorkers R2 Data Catalog Read
ParametersExpand Collapse
bucketName string

Specifies the R2 bucket name.

maxLength63
minLength3
params NamespaceListParams
AccountID param.Field[string]

Path param: Use this to identify the account.

PageSize param.Field[int64]optional

Query param: Maximum number of namespaces to return per page. Defaults to 100, maximum 1000.

maximum1000
minimum1
PageToken param.Field[string]optional

Query param: Opaque pagination token from a previous response. Use this to fetch the next page of results.

Parent param.Field[string]optional

Query param: Parent namespace to filter by. Only returns direct children of this namespace. For nested namespaces, use %1F as separator (e.g., "bronze%1Fanalytics"). Omit this parameter to list top-level namespaces.

ReturnDetails param.Field[bool]optional

Query param: Whether to include additional metadata (timestamps). When true, response includes created_at and updated_at arrays.

ReturnUUIDs param.Field[bool]optional

Query param: Whether to include namespace UUIDs in the response. Set to true to receive the namespace_uuids array.

ReturnsExpand Collapse
type NamespaceListResponse struct{…}

Contains the list of namespaces with optional pagination.

Namespaces [][]string

Lists namespaces in the catalog.

Details []NamespaceListResponseDetailoptional

Contains detailed metadata for each namespace when return_details is true. Each object includes the namespace, UUID, and timestamps.

Namespace []string

Specifies the hierarchical namespace parts as an array of strings. For example, ["bronze", "analytics"] represents the namespace "bronze.analytics".

NamespaceUUID string

Contains the UUID that persists across renames.

formatuuid
CreatedAt Timeoptional

Indicates the creation timestamp in ISO 8601 format.

formatdate-time
UpdatedAt Timeoptional

Shows the last update timestamp in ISO 8601 format. Null if never updated.

formatdate-time
NamespaceUUIDs []stringoptional

Contains UUIDs for each namespace when return_uuids is true. The order corresponds to the namespaces array.

NextPageToken stringoptional

Use this opaque token to fetch the next page of results. A null or absent value indicates the last page.

List namespaces in catalog

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  namespaces, err := client.R2DataCatalog.Namespaces.List(
    context.TODO(),
    "my-data-bucket",
    r2_data_catalog.NamespaceListParams{
      AccountID: cloudflare.F("0123456789abcdef0123456789abcdef"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", namespaces.NamespaceUUIDs)
}
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "success": true,
  "result": {
    "namespaces": [
      [
        "bronze",
        "analytics"
      ]
    ],
    "details": [
      {
        "namespace": [
          "bronze",
          "analytics"
        ],
        "namespace_uuid": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
        "created_at": "2019-12-27T18:11:19.117Z",
        "updated_at": "2019-12-27T18:11:19.117Z"
      }
    ],
    "namespace_uuids": [
      "0199b999-6869-7383-bb1f-d30e059d5326",
      "0199b99b-2c88-73b3-8dbb-421e0e8f2757"
    ],
    "next_page_token": "MSYxNzU5NzU1NTc4NTA0MTk0JjAxOTliOTliLTJjODgtNzNiMy04ZGJiLTQyMWUwZThmMjc1Nw"
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "messages": [
    {
      "code": 0,
      "message": "message"
    }
  ],
  "success": true,
  "result": {
    "namespaces": [
      [
        "bronze",
        "analytics"
      ]
    ],
    "details": [
      {
        "namespace": [
          "bronze",
          "analytics"
        ],
        "namespace_uuid": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
        "created_at": "2019-12-27T18:11:19.117Z",
        "updated_at": "2019-12-27T18:11:19.117Z"
      }
    ],
    "namespace_uuids": [
      "0199b999-6869-7383-bb1f-d30e059d5326",
      "0199b99b-2c88-73b3-8dbb-421e0e8f2757"
    ],
    "next_page_token": "MSYxNzU5NzU1NTc4NTA0MTk0JjAxOTliOTliLTJjODgtNzNiMy04ZGJiLTQyMWUwZThmMjc1Nw"
  }
}