Skip to content
Start here

List tenant accounts

client.Tenants.Accounts.List(ctx, tenantID, query) (*V4PagePaginationArray[AccountListResponse], error)
GET/tenants/{tenant_id}/accounts

Lists all Cloudflare accounts across this tenant’s hierarchy using the legacy Account response shape. Use GET /organizations/{organization_id}/accounts to list only accounts immediately attached to a specific Organization using the modern Account response shape. Use page_token and page_size for cursor pagination, or provide page and per_page together for legacy offset pagination. Cursor pagination takes precedence when requested.

Security

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
ParametersExpand Collapse
tenantID string
query AccountListParams
AccountPubname param.Field[AccountListParamsAccountPubname]Optional
Contains stringOptional

(case-insensitive) Filter the list of accounts to where the account_pubname contains a particular string.

EndsWith stringOptional

(case-insensitive) Filter the list of accounts to where the account_pubname ends with a particular string.

StartsWith stringOptional

(case-insensitive) Filter the list of accounts to where the account_pubname starts with a particular string.

Direction param.Field[AccountListParamsDirection]Optional

Sort direction for the order_by field. Valid values: asc, desc. Defaults to asc when order_by is specified.

const AccountListParamsDirectionAsc AccountListParamsDirection = "asc"
const AccountListParamsDirectionDesc AccountListParamsDirection = "desc"
IncludeTotal param.Field[bool]Optional

Whether to calculate and return the exact result_info.total_size for cursor pagination. Defaults to true. When false, total_size is omitted. Legacy page/per_page requests always calculate total_count.

Name param.Field[AccountListParamsName]Optional
Contains stringOptional

(case-insensitive) Filter the list of accounts to where the name contains a particular string.

EndsWith stringOptional

(case-insensitive) Filter the list of accounts to where the name ends with a particular string.

StartsWith stringOptional

(case-insensitive) Filter the list of accounts to where the name starts with a particular string.

OrderBy param.Field[AccountListParamsOrderBy]Optional

Field to order results by. Currently supported values: account_name.

const AccountListParamsOrderByAccountName AccountListParamsOrderBy = "account_name"
Page param.Field[int64]Optional

Legacy offset page number. Must be provided with per_page. Values below 1 are treated as

  1. Cursor pagination takes precedence when requested.
PageSize param.Field[int64]Optional

The amount of items to return. Defaults to 10.

maximum1000
minimum0
PageToken param.Field[string]Optional

An opaque token returned from the last list response that when provided will retrieve the next page.

Parameters used to filter the retrieved list must remain in subsequent requests with a page token.

PerPage param.Field[int64]Optional

Legacy offset page size. Must be provided with page. Values are clamped to the range 1-100. Cursor pagination takes precedence when requested.

Status param.Field[AccountListParamsStatus]Optional

Filter accounts by lifecycle status. Defaults to active.

const AccountListParamsStatusActive AccountListParamsStatus = "active"
const AccountListParamsStatusDeleted AccountListParamsStatus = "deleted"
ReturnsExpand Collapse
type AccountListResponse struct{…}
AccountPubname string
AccountTag string
AccountType AccountListResponseAccountType
One of the following:
const AccountListResponseAccountTypeStandard AccountListResponseAccountType = "standard"
const AccountListResponseAccountTypeEnterprise AccountListResponseAccountType = "enterprise"
CreatedOn Time
formatdate-time
Settings AccountListResponseSettings
AccessApprovalExpiry Time
formatdate-time
APIAccessEnabled bool
EnforceTwoFactor bool
UseAccountCustomNSByDefault bool

List tenant accounts

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
    option.WithAPIEmail("user@example.com"),
  )
  page, err := client.Tenants.Accounts.List(
    context.TODO(),
    "tenant_id",
    tenants.AccountListParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
{
  "errors": [],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": [
    {
      "account_pubname": "account_pubname",
      "account_tag": "account_tag",
      "account_type": "standard",
      "created_on": "2019-12-27T18:11:19.117Z",
      "settings": {
        "access_approval_expiry": "2019-12-27T18:11:19.117Z",
        "api_access_enabled": true,
        "enforce_two_factor": true,
        "use_account_custom_ns_by_default": true
      }
    }
  ],
  "result_info": {
    "next_page_token": "next_page_token",
    "total_size": 0
  },
  "success": true
}
Returns Examples
{
  "errors": [],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": [
    {
      "account_pubname": "account_pubname",
      "account_tag": "account_tag",
      "account_type": "standard",
      "created_on": "2019-12-27T18:11:19.117Z",
      "settings": {
        "access_approval_expiry": "2019-12-27T18:11:19.117Z",
        "api_access_enabled": true,
        "enforce_two_factor": true,
        "use_account_custom_ns_by_default": true
      }
    }
  ],
  "result_info": {
    "next_page_token": "next_page_token",
    "total_size": 0
  },
  "success": true
}