Create Health Check
client.Healthchecks.New(ctx, params) (*Healthcheck, error)
POST/zones/{zone_id}/healthchecks
Create a new health check.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Create Health Check
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)
}
{
"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
{
"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
}