Skip to content
Start here

List organization accounts

client.Organizations.OrganizationAccounts.Get(ctx, organizationID, params) (*[]OrganizationAccountGetResponse, error)
GET/organizations/{organization_id}/accounts

Retrieve the accounts immediately attached to a specific organization. Accounts attached to sub-organizations are not included. 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. The default response uses Account fields; Accept: application/json; legacy=true requests the LegacyAccount representation.

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
organizationID string
params OrganizationAccountGetParams
AccountPubname param.Field[OrganizationAccountGetParamsAccountPubname]Optional

Query param

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[OrganizationAccountGetParamsDirection]Optional

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

const OrganizationAccountGetParamsDirectionAsc OrganizationAccountGetParamsDirection = "asc"
const OrganizationAccountGetParamsDirectionDesc OrganizationAccountGetParamsDirection = "desc"
IncludeTags param.Field[bool]Optional

Query param: Include Account tags from the resource tag mirror. Omit this parameter to preserve the existing Account response shape.

IncludeTotal param.Field[bool]Optional

Query param: Whether to calculate and return the exact result_info.total_size for cursor pagination. Defaults to true. When false, total_size is omitted. page_size and include_total may change between pages; next_page_token remains the authoritative continuation signal. Legacy page/per_page requests always calculate total_count.

Name param.Field[OrganizationAccountGetParamsName]Optional

Query param

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[OrganizationAccountGetParamsOrderBy]Optional

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

const OrganizationAccountGetParamsOrderByAccountName OrganizationAccountGetParamsOrderBy = "account_name"
Page param.Field[int64]Optional

Query param: 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

Query param: The amount of items to return. Defaults to 10.

maximum1000
minimum0
PageToken param.Field[string]Optional

Query param: 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

Query param: 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[OrganizationAccountGetParamsStatus]Optional

Query param: Filter accounts by lifecycle status. Defaults to active.

const OrganizationAccountGetParamsStatusActive OrganizationAccountGetParamsStatus = "active"
const OrganizationAccountGetParamsStatusDeleted OrganizationAccountGetParamsStatus = "deleted"
Accept param.Field[string]Optional

Header param: Request application/json; legacy=true for the LegacyAccount representation.

ReturnsExpand Collapse
type OrganizationAccountGetResponseEnvelopeResult []OrganizationAccountGetResponse
One of the following:
type TenantAccount struct{…}
ID string
CreatedOn Time
formatdate-time
Name string
Settings TenantAccountSettings
AbuseContactEmail string
AccessApprovalExpiry Time
formatdate-time
APIAccessEnabled bool
DeprecatedDefaultNameservers string

Use DNS Settings instead. Deprecated.

EnforceTwofactor bool
DeprecatedUseAccountCustomNSByDefault bool

Use DNS Settings instead. Deprecated.

Type TenantAccountType
One of the following:
const TenantAccountTypeStandard TenantAccountType = "standard"
const TenantAccountTypeEnterprise TenantAccountType = "enterprise"
Tags map[string, string]Optional

Account tags, present only when include_tags=true is requested.

type OrganizationAccountGetResponseOrganizationsAPILegacyAccount struct{…}
AccountPubname string
AccountTag string
AccountType OrganizationAccountGetResponseOrganizationsAPILegacyAccountAccountType
One of the following:
const OrganizationAccountGetResponseOrganizationsAPILegacyAccountAccountTypeStandard OrganizationAccountGetResponseOrganizationsAPILegacyAccountAccountType = "standard"
const OrganizationAccountGetResponseOrganizationsAPILegacyAccountAccountTypeEnterprise OrganizationAccountGetResponseOrganizationsAPILegacyAccountAccountType = "enterprise"
CreatedOn Time
formatdate-time
Settings OrganizationAccountGetResponseOrganizationsAPILegacyAccountSettings
AccessApprovalExpiry Time
formatdate-time
APIAccessEnabled bool
EnforceTwoFactor bool
UseAccountCustomNSByDefault bool

List organization accounts

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
    option.WithAPIEmail("user@example.com"),
  )
  organizationAccounts, err := client.Organizations.OrganizationAccounts.Get(
    context.TODO(),
    "a7b9c3d2e8f4a1b5c6d0e9f2a3b7c4d8",
    organizations.OrganizationAccountGetParams{

    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", organizationAccounts)
}
{
  "errors": [],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "result": [
    {
      "id": "id",
      "created_on": "2019-12-27T18:11:19.117Z",
      "name": "name",
      "settings": {
        "abuse_contact_email": "abuse_contact_email",
        "access_approval_expiry": "2019-12-27T18:11:19.117Z",
        "api_access_enabled": true,
        "default_nameservers": "default_nameservers",
        "enforce_twofactor": true,
        "use_account_custom_ns_by_default": true
      },
      "type": "standard",
      "tags": {
        "foo": "string"
      }
    }
  ],
  "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": [
    {
      "id": "id",
      "created_on": "2019-12-27T18:11:19.117Z",
      "name": "name",
      "settings": {
        "abuse_contact_email": "abuse_contact_email",
        "access_approval_expiry": "2019-12-27T18:11:19.117Z",
        "api_access_enabled": true,
        "default_nameservers": "default_nameservers",
        "enforce_twofactor": true,
        "use_account_custom_ns_by_default": true
      },
      "type": "standard",
      "tags": {
        "foo": "string"
      }
    }
  ],
  "result_info": {
    "next_page_token": "next_page_token",
    "total_size": 0
  },
  "success": true
}