Skip to content
Start here

Get lists

client.rules.lists.list(ListListParams { account_id } params, RequestOptionsoptions?): SinglePage<ListsList { id, created_on, kind, 5 more } >
GET/accounts/{account_id}/rules/lists

Fetches all lists in the account.

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)
Account Filter Lists ReadAccount Filter Lists Edit
ParametersExpand Collapse
params: ListListParams { account_id }
account_id: string

The Account ID for this resource.

maxLength32
minLength32
ReturnsExpand Collapse
ListsList { id, created_on, kind, 5 more }
id: string

The unique ID of the list.

maxLength32
minLength32
created_on: string

The RFC 3339 timestamp of when the list was created.

kind: "ip" | "redirect" | "hostname" | "asn"

The type of the list. Each type supports specific list items (IP addresses, ASNs, hostnames or redirects).

One of the following:
"ip"
"redirect"
"hostname"
"asn"
modified_on: string

The RFC 3339 timestamp of when the list was last modified.

name: string

An informative name for the list. Use this name in filter and rule expressions.

maxLength50
num_items: number

The number of items in the list.

num_referencing_filters: number

The number of filters referencing the list.

description?: string

An informative summary of the list.

maxLength500

Get lists

import Cloudflare from 'cloudflare';

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

// Automatically fetches more pages as needed.
for await (const listsList of client.rules.lists.list({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
})) {
  console.log(listsList.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"
      }
    }
  ],
  "result": [
    {
      "id": "2c0fc9fa937b11eaa1b71c4d701ab86e",
      "created_on": "2020-01-01T08:00:00Z",
      "kind": "ip",
      "modified_on": "2020-01-10T14:00:00Z",
      "name": "list1",
      "num_items": 10,
      "num_referencing_filters": 2,
      "description": "This is a note"
    }
  ],
  "success": true
}
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"
      }
    }
  ],
  "result": [
    {
      "id": "2c0fc9fa937b11eaa1b71c4d701ab86e",
      "created_on": "2020-01-01T08:00:00Z",
      "kind": "ip",
      "modified_on": "2020-01-10T14:00:00Z",
      "name": "list1",
      "num_items": 10,
      "num_referencing_filters": 2,
      "description": "This is a note"
    }
  ],
  "success": true
}