---
title: Create Monitor
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api/go)

[Load Balancers](https://developers.cloudflare.com/api/go/resources/load_balancers)

[Monitors](https://developers.cloudflare.com/api/go/resources/load_balancers/subresources/monitors)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Create Monitor

client.LoadBalancers.Monitors.New(ctx, params) (\*[Monitor](<https://developers.cloudflare.com/api/go/resources/load_balancers#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)>), error)

POST/accounts/{account\_id}/load\_balancers/monitors

Create a configured monitor.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**<code>X-Auth-Email: user@example.com</code>

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`Load Balancing: Monitors and Pools Write`

##### ParametersExpand Collapse

<details>

<summary>

params MonitorNewParams

</summary>

AccountID param.Field\[string]

Path param: Identifier.

maxLength32

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20account_id">Link to this property</a>

AllowInsecure param.Field\[bool]Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20allow_insecure">Link to this property</a>

ConsecutiveDown param.Field\[int64]Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20consecutive_down">Link to this property</a>

ConsecutiveUp param.Field\[int64]Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20consecutive_up">Link to this property</a>

Description param.Field\[string]Optional

Body param: Object description.

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20description">Link to this property</a>

ExpectedBody param.Field\[string]Optional

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.

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20expected_body">Link to this property</a>

ExpectedCodes param.Field\[string]Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20expected_codes">Link to this property</a>

FollowRedirects param.Field\[bool]Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20follow_redirects">Link to this property</a>

Header param.Field\[map\[string, \[]string]]Optional

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.

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20header">Link to this property</a>

Interval param.Field\[int64]Optional

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.

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20interval">Link to this property</a>

Method param.Field\[string]Optional

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.

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20method">Link to this property</a>

Path param.Field\[string]Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20path">Link to this property</a>

Port param.Field\[int64]Optional

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).

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20port">Link to this property</a>

ProbeZone param.Field\[string]Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20probe_zone">Link to this property</a>

Retries param.Field\[int64]Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20retries">Link to this property</a>

Timeout param.Field\[int64]Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20timeout">Link to this property</a>

<details>

<summary>

Type param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/load_balancers/subresources/monitors/methods/create#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">MonitorNewParamsType</a>]Optional

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

</summary>

const MonitorNewParamsTypeHTTP <a href="https://developers.cloudflare.com/api/go/resources/load_balancers/subresources/monitors/methods/create#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">MonitorNewParamsType</a> = "http"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const MonitorNewParamsTypeHTTPS <a href="https://developers.cloudflare.com/api/go/resources/load_balancers/subresources/monitors/methods/create#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">MonitorNewParamsType</a> = "https"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const MonitorNewParamsTypeTCP <a href="https://developers.cloudflare.com/api/go/resources/load_balancers/subresources/monitors/methods/create#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">MonitorNewParamsType</a> = "tcp"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

const MonitorNewParamsTypeUdpIcmp <a href="https://developers.cloudflare.com/api/go/resources/load_balancers/subresources/monitors/methods/create#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">MonitorNewParamsType</a> = "udp\_icmp"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%203">Link to this property</a>

const MonitorNewParamsTypeIcmpPing <a href="https://developers.cloudflare.com/api/go/resources/load_balancers/subresources/monitors/methods/create#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">MonitorNewParamsType</a> = "icmp\_ping"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%204">Link to this property</a>

const MonitorNewParamsTypeSmtp <a href="https://developers.cloudflare.com/api/go/resources/load_balancers/subresources/monitors/methods/create#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)">MonitorNewParamsType</a> = "smtp"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type%20%3E%20(schema)%20%3E%20(member)%205">Link to this property</a>

</details>

<a href="#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default%20%3E%20(param)%20type">Link to this property</a>

</details>

[Link to this property](<#(resource)%20load_balancers.monitors%20%3E%20(method)%20create%20%3E%20(params)%20default>)

##### ReturnsExpand Collapse

<details>

<summary>

type Monitor struct{…}

</summary>

ID stringOptional

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

AllowInsecure boolOptional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20allow_insecure">Link to this property</a>

ConsecutiveDown int64Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20consecutive_down">Link to this property</a>

ConsecutiveUp int64Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20consecutive_up">Link to this property</a>

CreatedOn stringOptional

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20created_on">Link to this property</a>

Description stringOptional

Object description.

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20description">Link to this property</a>

ExpectedBody stringOptional

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.

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20expected_body">Link to this property</a>

ExpectedCodes stringOptional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20expected_codes">Link to this property</a>

FollowRedirects boolOptional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20follow_redirects">Link to this property</a>

Header map\[string, \[]string]Optional

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.

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20header">Link to this property</a>

Interval int64Optional

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.

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20interval">Link to this property</a>

Method stringOptional

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.

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20method">Link to this property</a>

ModifiedOn stringOptional

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20modified_on">Link to this property</a>

Path stringOptional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20path">Link to this property</a>

Port int64Optional

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).

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20port">Link to this property</a>

ProbeZone stringOptional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20probe_zone">Link to this property</a>

Retries int64Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20retries">Link to this property</a>

Timeout int64Optional

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

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20timeout">Link to this property</a>

<details>

<summary>

Type MonitorTypeOptional

The protocol to use for the health check. Currently supported protocols are ‘HTTP’,‘HTTPS’, ‘TCP’, ‘ICMP-PING’, ‘UDP-ICMP’, and ‘SMTP’.

</summary>

One of the following:

const MonitorTypeHTTP MonitorType = "http"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20type%20%3E%20(member)%200">Link to this property</a>

const MonitorTypeHTTPS MonitorType = "https"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20type%20%3E%20(member)%201">Link to this property</a>

const MonitorTypeTCP MonitorType = "tcp"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20type%20%3E%20(member)%202">Link to this property</a>

const MonitorTypeUdpIcmp MonitorType = "udp\_icmp"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20type%20%3E%20(member)%203">Link to this property</a>

const MonitorTypeIcmpPing MonitorType = "icmp\_ping"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20type%20%3E%20(member)%204">Link to this property</a>

const MonitorTypeSmtp MonitorType = "smtp"

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20type%20%3E%20(member)%205">Link to this property</a>

</details>

<a href="#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)%20%3E%20(property)%20type">Link to this property</a>

</details>

[Link to this property](<#(resource)%20load_balancers.monitors%20%3E%20(model)%20monitor%20%3E%20(schema)>)

### Create Monitor

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  monitor, err := client.LoadBalancers.Monitors.New(context.TODO(), load_balancers.MonitorNewParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", monitor.ID)
}
```

200 example

```
{
  "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": "f1aba936b94213e5b8dca0c0dbf1f9cc",
    "allow_insecure": true,
    "consecutive_down": 0,
    "consecutive_up": 0,
    "created_on": "2014-01-01T05:20:00.12345Z",
    "description": "Login page monitor",
    "expected_body": "alive",
    "expected_codes": "2xx",
    "follow_redirects": true,
    "header": {
      "Host": [
        "example.com"
      ],
      "X-App-ID": [
        "abc123"
      ]
    },
    "interval": 0,
    "method": "GET",
    "modified_on": "2014-01-01T05:20:00.12345Z",
    "path": "/health",
    "port": 0,
    "probe_zone": "example.com",
    "retries": 0,
    "timeout": 0,
    "type": "https"
  },
  "success": true
}
```

##### Returns Examples

200 example

```
{
  "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": "f1aba936b94213e5b8dca0c0dbf1f9cc",
    "allow_insecure": true,
    "consecutive_down": 0,
    "consecutive_up": 0,
    "created_on": "2014-01-01T05:20:00.12345Z",
    "description": "Login page monitor",
    "expected_body": "alive",
    "expected_codes": "2xx",
    "follow_redirects": true,
    "header": {
      "Host": [
        "example.com"
      ],
      "X-App-ID": [
        "abc123"
      ]
    },
    "interval": 0,
    "method": "GET",
    "modified_on": "2014-01-01T05:20:00.12345Z",
    "path": "/health",
    "port": 0,
    "probe_zone": "example.com",
    "retries": 0,
    "timeout": 0,
    "type": "https"
  },
  "success": true
}
```