Skip to content
Start here

Create Pool

client.loadBalancers.pools.create(PoolCreateParams { account_id, name, origins, 11 more } params, RequestOptionsoptions?): Pool { id, check_regions, created_on, 16 more }
POST/accounts/{account_id}/load_balancers/pools

Create a new pool.

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)
Load Balancing: Monitors and Pools Write
ParametersExpand Collapse
params: PoolCreateParams { account_id, name, origins, 11 more }
account_id: string

Path param: Identifier.

maxLength32
name: string

Body param: A short name (tag) for the pool. Only alphanumeric characters, hyphens, and underscores are allowed.

origins: Array<Origin { address, disabled_at, enabled, 5 more } >

Body param: The list of origins within this pool. Traffic directed at this pool is balanced across all currently healthy origins, provided the pool itself is healthy.

address?: string

The IP address (IPv4 or IPv6) of the origin, or its publicly addressable hostname. Hostnames entered here should resolve directly to the origin, and not be a hostname proxied by Cloudflare. To set an internal/reserved address, virtual_network_id must also be set.

disabled_at?: string

This field shows up only if the origin is disabled. This field is set with the time the origin was disabled.

formatdate-time
enabled?: boolean

Whether to enable (the default) this origin within the pool. Disabled origins will not receive traffic and are excluded from health checks. The origin will only be disabled for the current pool.

header?: Header { Host }

The request header is used to pass additional information with an HTTP request. Currently supported header is 'Host'.

Host?: Array<Host>

The 'Host' header allows to override the hostname set in the HTTP request. Current support is 1 'Host' header override per origin.

name?: string

A human-identifiable name for the origin.

port?: number

The port for upstream connections. A value of 0 means the default port for the protocol will be used.

virtual_network_id?: string

The virtual network subnet ID the origin belongs in. Virtual network must also belong to the account.

weight?: number

The weight of this origin relative to other origins in the pool. Based on the configured weight the total traffic is distributed among origins within the pool.

  • origin_steering.policy="least_outstanding_requests": Use weight to scale the origin's outstanding requests.
  • origin_steering.policy="least_connections": Use weight to scale the origin's open connections.
maximum1
minimum0
multipleOf0.01
description?: string

Body param: A human-readable description of the pool.

enabled?: boolean

Body param: Whether to enable (the default) or disable this pool. Disabled pools will not receive traffic and are excluded from health checks. Disabling a pool will cause any load balancers using it to failover to the next pool (if any).

latitude?: number

Body param: The latitude of the data center containing the origins used in this pool in decimal degrees. If this is set, longitude must also be set.

load_shedding?: LoadShedding { default_percent, default_policy, session_percent, session_policy } | null

Body param: Configures load shedding policies and percentages for the pool.

default_percent?: number

The percent of traffic to shed from the pool, according to the default policy. Applies to new sessions and traffic without session affinity.

maximum100
minimum0
default_policy?: "random" | "hash"

The default policy to use when load shedding. A random policy randomly sheds a given percent of requests. A hash policy computes a hash over the CF-Connecting-IP address and sheds all requests originating from a percent of IPs.

One of the following:
"random"
"hash"
session_percent?: number

The percent of existing sessions to shed from the pool, according to the session policy.

maximum100
minimum0
session_policy?: "hash"

Only the hash policy is supported for existing sessions (to avoid exponential decay).

longitude?: number

Body param: The longitude of the data center containing the origins used in this pool in decimal degrees. If this is set, latitude must also be set.

minimum_origins?: number

Body param: The minimum number of origins that must be healthy for this pool to serve traffic. If the number of healthy origins falls below this number, the pool will be marked unhealthy and will failover to the next available pool.

monitor?: string

Body param: The ID of the Monitor to use for checking the health of origins within this pool.

monitor_group?: string

Body param: The ID of the Monitor Group to use for checking the health of origins within this pool.

notification_email?: string

Body param: This field is now deprecated. It has been moved to Cloudflare's Centralized Notification service https://developers.cloudflare.com/fundamentals/notifications/. The email address to send health status notifications to. This can be an individual mailbox or a mailing list. Multiple emails can be supplied as a comma delimited list.

notification_filter?: NotificationFilter { origin, pool } | null

Body param: Filter pool and origin health notifications by resource type or health status. Use null to reset.

origin?: FilterOptions { disable, healthy } | null

Filter options for a particular resource type (pool or origin). Use null to reset.

disable?: boolean | null

If set true, disable notifications for this type of resource (pool or origin).

healthy?: boolean | null

If present, send notifications only for this health status (e.g. false for only DOWN events). Use null to reset (all events).

pool?: FilterOptions { disable, healthy } | null

Filter options for a particular resource type (pool or origin). Use null to reset.

disable?: boolean | null

If set true, disable notifications for this type of resource (pool or origin).

healthy?: boolean | null

If present, send notifications only for this health status (e.g. false for only DOWN events). Use null to reset (all events).

origin_steering?: OriginSteering { policy } | null

Body param: Configures origin steering for the pool. Controls how origins are selected for new sessions and traffic without session affinity.

policy?: "random" | "hash" | "least_outstanding_requests" | "least_connections"

The type of origin steering policy to use.

  • "random": Select an origin randomly.
  • "hash": Select an origin by computing a hash over the CF-Connecting-IP address.
  • "least_outstanding_requests": Select an origin by taking into consideration origin weights, as well as each origin's number of outstanding requests. Origins with more pending requests are weighted proportionately less relative to others.
  • "least_connections": Select an origin by taking into consideration origin weights, as well as each origin's number of open connections. Origins with more open connections are weighted proportionately less relative to others. Supported for HTTP/1 and HTTP/2 connections.
One of the following:
"random"
"hash"
"least_outstanding_requests"
"least_connections"
ReturnsExpand Collapse
Pool { id, check_regions, created_on, 16 more }
id?: string
check_regions?: Array<CheckRegion> | null

A list of regions from which to run health checks. Null means every Cloudflare data center.

One of the following:
"WNAM"
"ENAM"
"WEU"
"EEU"
"NSAM"
"SSAM"
"OC"
"ME"
"NAF"
"SAF"
"SAS"
"SEAS"
"NEAS"
"ALL_REGIONS"
created_on?: string
description?: string

A human-readable description of the pool.

disabled_at?: string

This field shows up only if the pool is disabled. This field is set with the time the pool was disabled at.

formatdate-time
enabled?: boolean

Whether to enable (the default) or disable this pool. Disabled pools will not receive traffic and are excluded from health checks. Disabling a pool will cause any load balancers using it to failover to the next pool (if any).

latitude?: number

The latitude of the data center containing the origins used in this pool in decimal degrees. If this is set, longitude must also be set.

load_shedding?: LoadShedding { default_percent, default_policy, session_percent, session_policy } | null

Configures load shedding policies and percentages for the pool.

default_percent?: number

The percent of traffic to shed from the pool, according to the default policy. Applies to new sessions and traffic without session affinity.

maximum100
minimum0
default_policy?: "random" | "hash"

The default policy to use when load shedding. A random policy randomly sheds a given percent of requests. A hash policy computes a hash over the CF-Connecting-IP address and sheds all requests originating from a percent of IPs.

One of the following:
"random"
"hash"
session_percent?: number

The percent of existing sessions to shed from the pool, according to the session policy.

maximum100
minimum0
session_policy?: "hash"

Only the hash policy is supported for existing sessions (to avoid exponential decay).

longitude?: number

The longitude of the data center containing the origins used in this pool in decimal degrees. If this is set, latitude must also be set.

minimum_origins?: number

The minimum number of origins that must be healthy for this pool to serve traffic. If the number of healthy origins falls below this number, the pool will be marked unhealthy and will failover to the next available pool.

modified_on?: string
monitor?: string

The ID of the Monitor to use for checking the health of origins within this pool.

monitor_group?: string

The ID of the Monitor Group to use for checking the health of origins within this pool.

name?: string

A short name (tag) for the pool. Only alphanumeric characters, hyphens, and underscores are allowed.

networks?: Array<string>

List of networks where Load Balancer or Pool is enabled.

notification_email?: string

This field is now deprecated. It has been moved to Cloudflare's Centralized Notification service https://developers.cloudflare.com/fundamentals/notifications/. The email address to send health status notifications to. This can be an individual mailbox or a mailing list. Multiple emails can be supplied as a comma delimited list.

notification_filter?: NotificationFilter { origin, pool } | null

Filter pool and origin health notifications by resource type or health status. Use null to reset.

origin?: FilterOptions { disable, healthy } | null

Filter options for a particular resource type (pool or origin). Use null to reset.

disable?: boolean | null

If set true, disable notifications for this type of resource (pool or origin).

healthy?: boolean | null

If present, send notifications only for this health status (e.g. false for only DOWN events). Use null to reset (all events).

pool?: FilterOptions { disable, healthy } | null

Filter options for a particular resource type (pool or origin). Use null to reset.

disable?: boolean | null

If set true, disable notifications for this type of resource (pool or origin).

healthy?: boolean | null

If present, send notifications only for this health status (e.g. false for only DOWN events). Use null to reset (all events).

origin_steering?: OriginSteering { policy } | null

Configures origin steering for the pool. Controls how origins are selected for new sessions and traffic without session affinity.

policy?: "random" | "hash" | "least_outstanding_requests" | "least_connections"

The type of origin steering policy to use.

  • "random": Select an origin randomly.
  • "hash": Select an origin by computing a hash over the CF-Connecting-IP address.
  • "least_outstanding_requests": Select an origin by taking into consideration origin weights, as well as each origin's number of outstanding requests. Origins with more pending requests are weighted proportionately less relative to others.
  • "least_connections": Select an origin by taking into consideration origin weights, as well as each origin's number of open connections. Origins with more open connections are weighted proportionately less relative to others. Supported for HTTP/1 and HTTP/2 connections.
One of the following:
"random"
"hash"
"least_outstanding_requests"
"least_connections"
origins?: Array<Origin { address, disabled_at, enabled, 5 more } >

The list of origins within this pool. Traffic directed at this pool is balanced across all currently healthy origins, provided the pool itself is healthy.

address?: string

The IP address (IPv4 or IPv6) of the origin, or its publicly addressable hostname. Hostnames entered here should resolve directly to the origin, and not be a hostname proxied by Cloudflare. To set an internal/reserved address, virtual_network_id must also be set.

disabled_at?: string

This field shows up only if the origin is disabled. This field is set with the time the origin was disabled.

formatdate-time
enabled?: boolean

Whether to enable (the default) this origin within the pool. Disabled origins will not receive traffic and are excluded from health checks. The origin will only be disabled for the current pool.

header?: Header { Host }

The request header is used to pass additional information with an HTTP request. Currently supported header is 'Host'.

Host?: Array<Host>

The 'Host' header allows to override the hostname set in the HTTP request. Current support is 1 'Host' header override per origin.

name?: string

A human-identifiable name for the origin.

port?: number

The port for upstream connections. A value of 0 means the default port for the protocol will be used.

virtual_network_id?: string

The virtual network subnet ID the origin belongs in. Virtual network must also belong to the account.

weight?: number

The weight of this origin relative to other origins in the pool. Based on the configured weight the total traffic is distributed among origins within the pool.

  • origin_steering.policy="least_outstanding_requests": Use weight to scale the origin's outstanding requests.
  • origin_steering.policy="least_connections": Use weight to scale the origin's open connections.
maximum1
minimum0
multipleOf0.01

Create Pool

import Cloudflare from 'cloudflare';

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

const pool = await client.loadBalancers.pools.create({
  account_id: '023e105f4ecef8ad9ca31a8372d0c353',
  name: 'primary-dc-1',
  origins: [{}],
});

console.log(pool.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": "17b5962d775c646f3f9725cbc7a53df4",
    "check_regions": [
      "WEU",
      "ENAM"
    ],
    "created_on": "2014-01-01T05:20:00.12345Z",
    "description": "Primary data center - Provider XYZ",
    "disabled_at": "2019-12-27T18:11:19.117Z",
    "enabled": false,
    "latitude": 0,
    "load_shedding": {
      "default_percent": 0,
      "default_policy": "random",
      "session_percent": 0,
      "session_policy": "hash"
    },
    "longitude": 0,
    "minimum_origins": 0,
    "modified_on": "2014-01-01T05:20:00.12345Z",
    "monitor": "monitor",
    "monitor_group": "monitor_group",
    "name": "primary-dc-1",
    "networks": [
      "string"
    ],
    "notification_email": "someone@example.com,sometwo@example.com",
    "notification_filter": {
      "origin": {
        "disable": true,
        "healthy": true
      },
      "pool": {
        "disable": true,
        "healthy": false
      }
    },
    "origin_steering": {
      "policy": "random"
    },
    "origins": [
      {
        "address": "0.0.0.0",
        "disabled_at": "2019-12-27T18:11:19.117Z",
        "enabled": true,
        "header": {
          "Host": [
            "example.com"
          ]
        },
        "name": "app-server-1",
        "port": 0,
        "virtual_network_id": "a5624d4e-044a-4ff0-b3e1-e2465353d4b4",
        "weight": 0.6
      }
    ]
  },
  "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": "17b5962d775c646f3f9725cbc7a53df4",
    "check_regions": [
      "WEU",
      "ENAM"
    ],
    "created_on": "2014-01-01T05:20:00.12345Z",
    "description": "Primary data center - Provider XYZ",
    "disabled_at": "2019-12-27T18:11:19.117Z",
    "enabled": false,
    "latitude": 0,
    "load_shedding": {
      "default_percent": 0,
      "default_policy": "random",
      "session_percent": 0,
      "session_policy": "hash"
    },
    "longitude": 0,
    "minimum_origins": 0,
    "modified_on": "2014-01-01T05:20:00.12345Z",
    "monitor": "monitor",
    "monitor_group": "monitor_group",
    "name": "primary-dc-1",
    "networks": [
      "string"
    ],
    "notification_email": "someone@example.com,sometwo@example.com",
    "notification_filter": {
      "origin": {
        "disable": true,
        "healthy": true
      },
      "pool": {
        "disable": true,
        "healthy": false
      }
    },
    "origin_steering": {
      "policy": "random"
    },
    "origins": [
      {
        "address": "0.0.0.0",
        "disabled_at": "2019-12-27T18:11:19.117Z",
        "enabled": true,
        "header": {
          "Host": [
            "example.com"
          ]
        },
        "name": "app-server-1",
        "port": 0,
        "virtual_network_id": "a5624d4e-044a-4ff0-b3e1-e2465353d4b4",
        "weight": 0.6
      }
    ]
  },
  "success": true
}