Skip to content
Start here

List Roles

client.accounts.roles.list(RoleListParams { account_id, page, per_page } params, RequestOptionsoptions?): V4PagePaginationArray<Role { id, description, name, permissions } >
GET/accounts/{account_id}/roles

Get all available roles for an account.

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
Accepted Permissions (at least one required)
SCIM ProvisioningAccount Settings WriteAccount Settings Read
ParametersExpand Collapse
params: RoleListParams { account_id, page, per_page }
account_id: string

Path param: Account identifier tag.

maxLength32
minLength32
page?: number

Query param: Page number of paginated results.

minimum1
per_page?: number

Query param: Number of roles per page.

maximum50
minimum5
ReturnsExpand Collapse
Role { id, description, name, permissions }
id: string

Role identifier tag.

maxLength32
description: string

Description of role’s permissions.

name: string

Role name.

maxLength120
permissions: Permissions { analytics, billing, cache_purge, 9 more }
analytics?: PermissionGrant { read, write }
read?: boolean
write?: boolean
billing?: PermissionGrant { read, write }
read?: boolean
write?: boolean
cache_purge?: PermissionGrant { read, write }
read?: boolean
write?: boolean
dns?: PermissionGrant { read, write }
read?: boolean
write?: boolean
dns_records?: PermissionGrant { read, write }
read?: boolean
write?: boolean
lb?: PermissionGrant { read, write }
read?: boolean
write?: boolean
logs?: PermissionGrant { read, write }
read?: boolean
write?: boolean
organization?: PermissionGrant { read, write }
read?: boolean
write?: boolean
ssl?: PermissionGrant { read, write }
read?: boolean
write?: boolean
waf?: PermissionGrant { read, write }
read?: boolean
write?: boolean
zone_settings?: PermissionGrant { read, write }
read?: boolean
write?: boolean
zones?: PermissionGrant { read, write }
read?: boolean
write?: boolean

List Roles

import Cloudflare from 'cloudflare';

const client = new Cloudflare({
  apiEmail: process.env['CLOUDFLARE_EMAIL'], // This is the default and can be omitted
  apiKey: process.env['CLOUDFLARE_API_KEY'], // This is the default and can be omitted
});

// Automatically fetches more pages as needed.
for await (const role of client.accounts.roles.list({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
})) {
  console.log(role.id);
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": [
    {
      "id": "3536bcfad5faccb999b47003c79917fb",
      "description": "Administrative access to the entire Account",
      "name": "Account Administrator",
      "permissions": {
        "analytics": {
          "read": true,
          "write": false
        },
        "billing": {
          "read": true,
          "write": false
        },
        "cache_purge": {
          "read": true,
          "write": false
        },
        "dns": {
          "read": true,
          "write": false
        },
        "dns_records": {
          "read": true,
          "write": false
        },
        "lb": {
          "read": true,
          "write": false
        },
        "logs": {
          "read": true,
          "write": false
        },
        "organization": {
          "read": true,
          "write": false
        },
        "ssl": {
          "read": true,
          "write": false
        },
        "waf": {
          "read": true,
          "write": false
        },
        "zone_settings": {
          "read": true,
          "write": false
        },
        "zones": {
          "read": true,
          "write": true
        }
      }
    }
  ],
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": [
    {
      "id": "3536bcfad5faccb999b47003c79917fb",
      "description": "Administrative access to the entire Account",
      "name": "Account Administrator",
      "permissions": {
        "analytics": {
          "read": true,
          "write": false
        },
        "billing": {
          "read": true,
          "write": false
        },
        "cache_purge": {
          "read": true,
          "write": false
        },
        "dns": {
          "read": true,
          "write": false
        },
        "dns_records": {
          "read": true,
          "write": false
        },
        "lb": {
          "read": true,
          "write": false
        },
        "logs": {
          "read": true,
          "write": false
        },
        "organization": {
          "read": true,
          "write": false
        },
        "ssl": {
          "read": true,
          "write": false
        },
        "waf": {
          "read": true,
          "write": false
        },
        "zone_settings": {
          "read": true,
          "write": false
        },
        "zones": {
          "read": true,
          "write": true
        }
      }
    }
  ],
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000
  }
}