Skip to content
Start here

Preview Monitor

client.loadBalancers.monitors.previews.create(stringmonitorId, PreviewCreateParams { account_id, allow_insecure, consecutive_down, 14 more } params, RequestOptionsoptions?): PreviewCreateResponse { pools, preview_id }
POST/accounts/{account_id}/load_balancers/monitors/{monitor_id}/preview

Preview pools using the specified monitor with provided monitor details. The returned preview_id can be used in the preview endpoint to retrieve the results.

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
ParametersExpand Collapse
monitorId: string
params: PreviewCreateParams { account_id, allow_insecure, consecutive_down, 14 more }
account_id: string

Path param: Identifier.

maxLength32
allow_insecure?: boolean

Body param: Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors.

consecutive_down?: number

Body param: To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times.

consecutive_up?: number

Body param: To be marked healthy the monitored origin must pass this healthcheck N consecutive times.

description?: string

Body param: Object description.

expected_body?: string

Body param: A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors.

expected_codes?: string

Body param: The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors.

follow_redirects?: boolean

Body param: Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors.

header?: Record<string, Array<string>>

Body param: The HTTP request headers to send in the health check. It is recommended you set a Host header by default. The User-Agent header cannot be overridden. This parameter is only valid for HTTP and HTTPS monitors.

interval?: number

Body param: The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations.

method?: string

Body param: The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks.

path_?: string

Body param: The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors.

port?: number | null

Body param: The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443).

probe_zone?: string

Body param: Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors.

retries?: number

Body param: The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately.

timeout?: number

Body param: The timeout (in seconds) before marking the health check as failed.

type?: "http" | "https" | "tcp" | 3 more

Body param: The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'.

One of the following:
"http"
"https"
"tcp"
"udp_icmp"
"icmp_ping"
"smtp"
ReturnsExpand Collapse
PreviewCreateResponse { pools, preview_id }
pools?: Record<string, string>

Monitored pool IDs mapped to their respective names.

preview_id?: string

Preview Monitor

import Cloudflare from 'cloudflare';

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

const preview = await client.loadBalancers.monitors.previews.create(
  'f1aba936b94213e5b8dca0c0dbf1f9cc',
  { account_id: '023e105f4ecef8ad9ca31a8372d0c353' },
);

console.log(preview.preview_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": {
    "pools": {
      "abwlnp5jbqn45ecgxd03erbgtxtqai0d": "WNAM Datacenter",
      "ve8h9lrcip5n5bbga9yqmdws28ay5d0l": "EEU Datacenter"
    },
    "preview_id": "f1aba936b94213e5b8dca0c0dbf1f9cc"
  },
  "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": {
    "pools": {
      "abwlnp5jbqn45ecgxd03erbgtxtqai0d": "WNAM Datacenter",
      "ve8h9lrcip5n5bbga9yqmdws28ay5d0l": "EEU Datacenter"
    },
    "preview_id": "f1aba936b94213e5b8dca0c0dbf1f9cc"
  },
  "success": true
}