---
title: Create Health Check
---

[Skip to content](#_top)

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

[Healthchecks](https://developers.cloudflare.com/api/go/resources/healthchecks)

Copy Markdown

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

---

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

# Create Health Check

client.Healthchecks.New(ctx, params) (\*[Healthcheck](<https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)>), error)

POST/zones/{zone\_id}/healthchecks

Create a new health check.

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

`Health Checks Write`

##### ParametersExpand Collapse

<details>

<summary>

params HealthcheckNewParams

</summary>

ZoneID param.Field\[string]

Path param: Identifier

maxLength32

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

QueryHealthcheck param.Field\[<a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20query_healthcheck%20%3E%20(schema)">QueryHealthcheck</a>]

Body param

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

</details>

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

##### ReturnsExpand Collapse

<details>

<summary>

type Healthcheck struct{…}

</summary>

ID stringOptional

Identifier

maxLength32

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20id">Link to this property</a>

Address stringOptional

The hostname or IP address of the origin server to run health checks on.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20address">Link to this property</a>

<details>

<summary>

CheckRegions \[]<a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a>Optional

A list of regions from which to run health checks. Null means Cloudflare will pick a default region.

</summary>

One of the following:

const CheckRegionWnam <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "WNAM"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%200">Link to this property</a>

const CheckRegionEnam <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "ENAM"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%201">Link to this property</a>

const CheckRegionWeu <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "WEU"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%202">Link to this property</a>

const CheckRegionEeu <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "EEU"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%203">Link to this property</a>

const CheckRegionNsam <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "NSAM"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%204">Link to this property</a>

const CheckRegionSsam <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "SSAM"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%205">Link to this property</a>

const CheckRegionOc <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "OC"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%206">Link to this property</a>

const CheckRegionMe <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "ME"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%207">Link to this property</a>

const CheckRegionNaf <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "NAF"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%208">Link to this property</a>

const CheckRegionSaf <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "SAF"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%209">Link to this property</a>

const CheckRegionIn <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "IN"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%2010">Link to this property</a>

const CheckRegionSeas <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "SEAS"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%2011">Link to this property</a>

const CheckRegionNeas <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "NEAS"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%2012">Link to this property</a>

const CheckRegionAllRegions <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)">CheckRegion</a> = "ALL\_REGIONS"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20check_region%20%3E%20(schema)%20%3E%20(member)%2013">Link to this property</a>

</details>

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20check_regions">Link to this property</a>

ConsecutiveFails int64Optional

The number of consecutive fails required from a health check before changing the health to unhealthy.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20consecutive_fails">Link to this property</a>

ConsecutiveSuccesses int64Optional

The number of consecutive successes required from a health check before changing the health to healthy.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20consecutive_successes">Link to this property</a>

CreatedOn TimeOptional

formatdate-time

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20created_on">Link to this property</a>

Description stringOptional

A human-readable description of the health check.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20description">Link to this property</a>

FailureReason stringOptional

The current failure reason if status is unhealthy.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20failure_reason">Link to this property</a>

<details>

<summary>

HTTPConfig <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20http_configuration%20%3E%20(schema)">HTTPConfiguration</a>Optional

Parameters specific to an HTTP or HTTPS health check.

</summary>

AllowInsecure boolOptional

Do not validate the certificate when the health check uses HTTPS.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20http_configuration%20%3E%20(schema)%20%3E%20(property)%20allow_insecure">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.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20http_configuration%20%3E%20(schema)%20%3E%20(property)%20expected_body">Link to this property</a>

ExpectedCodes \[]stringOptional

The expected HTTP response codes (e.g. “200”) or code ranges (e.g. “2xx” for all codes starting with 2) of the health check.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20http_configuration%20%3E%20(schema)%20%3E%20(property)%20expected_codes">Link to this property</a>

FollowRedirects boolOptional

Follow redirects if the origin returns a 3xx status code.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20http_configuration%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.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20http_configuration%20%3E%20(schema)%20%3E%20(property)%20header">Link to this property</a>

<details>

<summary>

Method HTTPConfigurationMethodOptional

The HTTP method to use for the health check.

</summary>

One of the following:

const HTTPConfigurationMethodGet HTTPConfigurationMethod = "GET"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20http_configuration%20%3E%20(schema)%20%3E%20(property)%20method%20%3E%20(member)%200">Link to this property</a>

const HTTPConfigurationMethodHead HTTPConfigurationMethod = "HEAD"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20http_configuration%20%3E%20(schema)%20%3E%20(property)%20method%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20http_configuration%20%3E%20(schema)%20%3E%20(property)%20method">Link to this property</a>

Path stringOptional

The endpoint path to health check against.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20http_configuration%20%3E%20(schema)%20%3E%20(property)%20path">Link to this property</a>

Port int64Optional

Port number to connect to for the health check. Defaults to 80 if type is HTTP or 443 if type is HTTPS.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20http_configuration%20%3E%20(schema)%20%3E%20(property)%20port">Link to this property</a>

</details>

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20http_config">Link to this property</a>

Interval int64Optional

The interval between each health check. Shorter intervals may give quicker notifications if the origin status changes, but will increase load on the origin as we check from multiple locations.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20interval">Link to this property</a>

ModifiedOn TimeOptional

formatdate-time

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20modified_on">Link to this property</a>

Name stringOptional

A short name to identify the health check. Only alphanumeric characters, hyphens and underscores are allowed.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20name">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)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20retries">Link to this property</a>

<details>

<summary>

Status HealthcheckStatusOptional

The current status of the origin server according to the health check.

</summary>

One of the following:

const HealthcheckStatusUnknown HealthcheckStatus = "unknown"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%200">Link to this property</a>

const HealthcheckStatusHealthy HealthcheckStatus = "healthy"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%201">Link to this property</a>

const HealthcheckStatusUnhealthy HealthcheckStatus = "unhealthy"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%202">Link to this property</a>

const HealthcheckStatusSuspended HealthcheckStatus = "suspended"

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20status%20%3E%20(member)%203">Link to this property</a>

</details>

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20status">Link to this property</a>

Suspended boolOptional

If suspended, no health checks are sent to the origin.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20suspended">Link to this property</a>

<details>

<summary>

TCPConfig <a href="https://developers.cloudflare.com/api/go/resources/healthchecks#(resource)%20healthchecks%20%3E%20(model)%20tcp_configuration%20%3E%20(schema)">TCPConfiguration</a>Optional

Parameters specific to TCP health check.

</summary>

Method TCPConfigurationMethodOptional

The TCP connection method to use for the health check.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20tcp_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20tcp_configuration%20%3E%20(schema)%20%3E%20(property)%20method">Link to this property</a>

Port int64Optional

Port number to connect to for the health check. Defaults to 80.

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20tcp_config%20%2B%20(resource)%20healthchecks%20%3E%20(model)%20tcp_configuration%20%3E%20(schema)%20%3E%20(property)%20port">Link to this property</a>

</details>

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20tcp_config">Link to this property</a>

Timeout int64Optional

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

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20timeout">Link to this property</a>

Type stringOptional

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

<a href="#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)%20%3E%20(property)%20type">Link to this property</a>

</details>

[Link to this property](<#(resource)%20healthchecks%20%3E%20(model)%20healthcheck%20%3E%20(schema)>)

### Create Health Check

Go

HTTPTypeScriptPythonGoTerraform

```
package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  healthcheck, err := client.Healthchecks.New(context.TODO(), healthchecks.HealthcheckNewParams{
    ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    QueryHealthcheck: healthchecks.QueryHealthcheckParam{
      Address: cloudflare.F("www.example.com"),
      Name: cloudflare.F("server-1"),
    },
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", healthcheck.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": "023e105f4ecef8ad9ca31a8372d0c353",
    "address": "www.example.com",
    "check_regions": [
      "WEU",
      "ENAM"
    ],
    "consecutive_fails": 0,
    "consecutive_successes": 0,
    "created_on": "2014-01-01T05:20:00.12345Z",
    "description": "Health check for www.example.com",
    "failure_reason": "",
    "http_config": {
      "allow_insecure": true,
      "expected_body": "success",
      "expected_codes": [
        "2xx",
        "302"
      ],
      "follow_redirects": true,
      "header": {
        "Host": [
          "example.com"
        ],
        "X-App-ID": [
          "abc123"
        ]
      },
      "method": "GET",
      "path": "/health",
      "port": 0
    },
    "interval": 0,
    "modified_on": "2014-01-01T05:20:00.12345Z",
    "name": "server-1",
    "retries": 0,
    "status": "healthy",
    "suspended": true,
    "tcp_config": {
      "method": "connection_established",
      "port": 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": "023e105f4ecef8ad9ca31a8372d0c353",
    "address": "www.example.com",
    "check_regions": [
      "WEU",
      "ENAM"
    ],
    "consecutive_fails": 0,
    "consecutive_successes": 0,
    "created_on": "2014-01-01T05:20:00.12345Z",
    "description": "Health check for www.example.com",
    "failure_reason": "",
    "http_config": {
      "allow_insecure": true,
      "expected_body": "success",
      "expected_codes": [
        "2xx",
        "302"
      ],
      "follow_redirects": true,
      "header": {
        "Host": [
          "example.com"
        ],
        "X-App-ID": [
          "abc123"
        ]
      },
      "method": "GET",
      "path": "/health",
      "port": 0
    },
    "interval": 0,
    "modified_on": "2014-01-01T05:20:00.12345Z",
    "name": "server-1",
    "retries": 0,
    "status": "healthy",
    "suspended": true,
    "tcp_config": {
      "method": "connection_established",
      "port": 0
    },
    "timeout": 0,
    "type": "HTTPS"
  },
  "success": true
}
```