Skip to content
Start here

Create scheduled page test

client.Speed.Schedule.New(ctx, url, params) (*ScheduleNewResponse, error)
POST/zones/{zone_id}/speed_api/schedule/{url}

Creates a scheduled test for a page.

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)
Zone Settings Write
ParametersExpand Collapse
url string

A URL.

params ScheduleNewParams
ZoneID param.Field[string]

Path param: Identifier.

maxLength32
Frequency param.Field[ScheduleNewParamsFrequency]optional

Query param: The frequency of the scheduled test. Defaults to WEEKLY for free plans, DAILY for paid plans.

const ScheduleNewParamsFrequencyDaily ScheduleNewParamsFrequency = "DAILY"
const ScheduleNewParamsFrequencyWeekly ScheduleNewParamsFrequency = "WEEKLY"
Region param.Field[ScheduleNewParamsRegion]optional

Query param: A test region.

const ScheduleNewParamsRegionAsiaEast1 ScheduleNewParamsRegion = "asia-east1"
const ScheduleNewParamsRegionAsiaNortheast1 ScheduleNewParamsRegion = "asia-northeast1"
const ScheduleNewParamsRegionAsiaNortheast2 ScheduleNewParamsRegion = "asia-northeast2"
const ScheduleNewParamsRegionAsiaSouth1 ScheduleNewParamsRegion = "asia-south1"
const ScheduleNewParamsRegionAsiaSoutheast1 ScheduleNewParamsRegion = "asia-southeast1"
const ScheduleNewParamsRegionAustraliaSoutheast1 ScheduleNewParamsRegion = "australia-southeast1"
const ScheduleNewParamsRegionEuropeNorth1 ScheduleNewParamsRegion = "europe-north1"
const ScheduleNewParamsRegionEuropeSouthwest1 ScheduleNewParamsRegion = "europe-southwest1"
const ScheduleNewParamsRegionEuropeWest1 ScheduleNewParamsRegion = "europe-west1"
const ScheduleNewParamsRegionEuropeWest2 ScheduleNewParamsRegion = "europe-west2"
const ScheduleNewParamsRegionEuropeWest3 ScheduleNewParamsRegion = "europe-west3"
const ScheduleNewParamsRegionEuropeWest4 ScheduleNewParamsRegion = "europe-west4"
const ScheduleNewParamsRegionEuropeWest8 ScheduleNewParamsRegion = "europe-west8"
const ScheduleNewParamsRegionEuropeWest9 ScheduleNewParamsRegion = "europe-west9"
const ScheduleNewParamsRegionMeWest1 ScheduleNewParamsRegion = "me-west1"
const ScheduleNewParamsRegionSouthamericaEast1 ScheduleNewParamsRegion = "southamerica-east1"
const ScheduleNewParamsRegionUsCentral1 ScheduleNewParamsRegion = "us-central1"
const ScheduleNewParamsRegionUsEast1 ScheduleNewParamsRegion = "us-east1"
const ScheduleNewParamsRegionUsEast4 ScheduleNewParamsRegion = "us-east4"
const ScheduleNewParamsRegionUsSouth1 ScheduleNewParamsRegion = "us-south1"
const ScheduleNewParamsRegionUsWest1 ScheduleNewParamsRegion = "us-west1"
ReturnsExpand Collapse
type ScheduleNewResponse struct{…}
Schedule Scheduleoptional

The test schedule.

Frequency ScheduleFrequencyoptional

The frequency of the test.

One of the following:
const ScheduleFrequencyDaily ScheduleFrequency = "DAILY"
const ScheduleFrequencyWeekly ScheduleFrequency = "WEEKLY"
Region ScheduleRegionoptional

A test region.

One of the following:
const ScheduleRegionAsiaEast1 ScheduleRegion = "asia-east1"
const ScheduleRegionAsiaNortheast1 ScheduleRegion = "asia-northeast1"
const ScheduleRegionAsiaNortheast2 ScheduleRegion = "asia-northeast2"
const ScheduleRegionAsiaSouth1 ScheduleRegion = "asia-south1"
const ScheduleRegionAsiaSoutheast1 ScheduleRegion = "asia-southeast1"
const ScheduleRegionAustraliaSoutheast1 ScheduleRegion = "australia-southeast1"
const ScheduleRegionEuropeNorth1 ScheduleRegion = "europe-north1"
const ScheduleRegionEuropeSouthwest1 ScheduleRegion = "europe-southwest1"
const ScheduleRegionEuropeWest1 ScheduleRegion = "europe-west1"
const ScheduleRegionEuropeWest2 ScheduleRegion = "europe-west2"
const ScheduleRegionEuropeWest3 ScheduleRegion = "europe-west3"
const ScheduleRegionEuropeWest4 ScheduleRegion = "europe-west4"
const ScheduleRegionEuropeWest8 ScheduleRegion = "europe-west8"
const ScheduleRegionEuropeWest9 ScheduleRegion = "europe-west9"
const ScheduleRegionMeWest1 ScheduleRegion = "me-west1"
const ScheduleRegionSouthamericaEast1 ScheduleRegion = "southamerica-east1"
const ScheduleRegionUsCentral1 ScheduleRegion = "us-central1"
const ScheduleRegionUsEast1 ScheduleRegion = "us-east1"
const ScheduleRegionUsEast4 ScheduleRegion = "us-east4"
const ScheduleRegionUsSouth1 ScheduleRegion = "us-south1"
const ScheduleRegionUsWest1 ScheduleRegion = "us-west1"
URL stringoptional

A URL.

Test Testoptional
ID stringoptional

UUID.

maxLength36
Date Timeoptional
formatdate-time
DesktopReport LighthouseReportoptional

The Lighthouse report.

CLS float64optional

Cumulative Layout Shift.

DeviceType LighthouseReportDeviceTypeoptional

The type of device.

One of the following:
const LighthouseReportDeviceTypeDesktop LighthouseReportDeviceType = "DESKTOP"
const LighthouseReportDeviceTypeMobile LighthouseReportDeviceType = "MOBILE"
Error LighthouseReportErroroptional
Code LighthouseReportErrorCodeoptional

The error code of the Lighthouse result.

One of the following:
const LighthouseReportErrorCodeNotReachable LighthouseReportErrorCode = "NOT_REACHABLE"
const LighthouseReportErrorCodeDNSFailure LighthouseReportErrorCode = "DNS_FAILURE"
const LighthouseReportErrorCodeNotHTML LighthouseReportErrorCode = "NOT_HTML"
const LighthouseReportErrorCodeLighthouseTimeout LighthouseReportErrorCode = "LIGHTHOUSE_TIMEOUT"
const LighthouseReportErrorCodeUnknown LighthouseReportErrorCode = "UNKNOWN"
Detail stringoptional

Detailed error message.

FinalDisplayedURL stringoptional

The final URL displayed to the user.

FCP float64optional

First Contentful Paint.

JsonReportURL stringoptional

The URL to the full Lighthouse JSON report.

LCP float64optional

Largest Contentful Paint.

PerformanceScore float64optional

The Lighthouse performance score.

Si float64optional

Speed Index.

State LighthouseReportStateoptional

The state of the Lighthouse report.

One of the following:
const LighthouseReportStateRunning LighthouseReportState = "RUNNING"
const LighthouseReportStateComplete LighthouseReportState = "COMPLETE"
const LighthouseReportStateFailed LighthouseReportState = "FAILED"
TBT float64optional

Total Blocking Time.

TTFB float64optional

Time To First Byte.

TTI float64optional

Time To Interactive.

MobileReport LighthouseReportoptional

The Lighthouse report.

CLS float64optional

Cumulative Layout Shift.

DeviceType LighthouseReportDeviceTypeoptional

The type of device.

One of the following:
const LighthouseReportDeviceTypeDesktop LighthouseReportDeviceType = "DESKTOP"
const LighthouseReportDeviceTypeMobile LighthouseReportDeviceType = "MOBILE"
Error LighthouseReportErroroptional
Code LighthouseReportErrorCodeoptional

The error code of the Lighthouse result.

One of the following:
const LighthouseReportErrorCodeNotReachable LighthouseReportErrorCode = "NOT_REACHABLE"
const LighthouseReportErrorCodeDNSFailure LighthouseReportErrorCode = "DNS_FAILURE"
const LighthouseReportErrorCodeNotHTML LighthouseReportErrorCode = "NOT_HTML"
const LighthouseReportErrorCodeLighthouseTimeout LighthouseReportErrorCode = "LIGHTHOUSE_TIMEOUT"
const LighthouseReportErrorCodeUnknown LighthouseReportErrorCode = "UNKNOWN"
Detail stringoptional

Detailed error message.

FinalDisplayedURL stringoptional

The final URL displayed to the user.

FCP float64optional

First Contentful Paint.

JsonReportURL stringoptional

The URL to the full Lighthouse JSON report.

LCP float64optional

Largest Contentful Paint.

PerformanceScore float64optional

The Lighthouse performance score.

Si float64optional

Speed Index.

State LighthouseReportStateoptional

The state of the Lighthouse report.

One of the following:
const LighthouseReportStateRunning LighthouseReportState = "RUNNING"
const LighthouseReportStateComplete LighthouseReportState = "COMPLETE"
const LighthouseReportStateFailed LighthouseReportState = "FAILED"
TBT float64optional

Total Blocking Time.

TTFB float64optional

Time To First Byte.

TTI float64optional

Time To Interactive.

Region LabeledRegionoptional

A test region with a label.

Label stringoptional
Value LabeledRegionValueoptional

A test region.

One of the following:
const LabeledRegionValueAsiaEast1 LabeledRegionValue = "asia-east1"
const LabeledRegionValueAsiaNortheast1 LabeledRegionValue = "asia-northeast1"
const LabeledRegionValueAsiaNortheast2 LabeledRegionValue = "asia-northeast2"
const LabeledRegionValueAsiaSouth1 LabeledRegionValue = "asia-south1"
const LabeledRegionValueAsiaSoutheast1 LabeledRegionValue = "asia-southeast1"
const LabeledRegionValueAustraliaSoutheast1 LabeledRegionValue = "australia-southeast1"
const LabeledRegionValueEuropeNorth1 LabeledRegionValue = "europe-north1"
const LabeledRegionValueEuropeSouthwest1 LabeledRegionValue = "europe-southwest1"
const LabeledRegionValueEuropeWest1 LabeledRegionValue = "europe-west1"
const LabeledRegionValueEuropeWest2 LabeledRegionValue = "europe-west2"
const LabeledRegionValueEuropeWest3 LabeledRegionValue = "europe-west3"
const LabeledRegionValueEuropeWest4 LabeledRegionValue = "europe-west4"
const LabeledRegionValueEuropeWest8 LabeledRegionValue = "europe-west8"
const LabeledRegionValueEuropeWest9 LabeledRegionValue = "europe-west9"
const LabeledRegionValueMeWest1 LabeledRegionValue = "me-west1"
const LabeledRegionValueSouthamericaEast1 LabeledRegionValue = "southamerica-east1"
const LabeledRegionValueUsCentral1 LabeledRegionValue = "us-central1"
const LabeledRegionValueUsEast1 LabeledRegionValue = "us-east1"
const LabeledRegionValueUsEast4 LabeledRegionValue = "us-east4"
const LabeledRegionValueUsSouth1 LabeledRegionValue = "us-south1"
const LabeledRegionValueUsWest1 LabeledRegionValue = "us-west1"
ScheduleFrequency TestScheduleFrequencyoptional

The frequency of the test.

One of the following:
const TestScheduleFrequencyDaily TestScheduleFrequency = "DAILY"
const TestScheduleFrequencyWeekly TestScheduleFrequency = "WEEKLY"
URL stringoptional

A URL.

Create scheduled page test

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  schedule, err := client.Speed.Schedule.New(
    context.TODO(),
    "example.com",
    speed.ScheduleNewParams{
      ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", schedule.Schedule)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "schedule": {
      "frequency": "DAILY",
      "region": "us-central1",
      "url": "example.com"
    },
    "test": {
      "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
      "date": "2014-01-01T05:20:00.12345Z",
      "desktopReport": {
        "cls": 100,
        "deviceType": "DESKTOP",
        "error": {
          "code": "NOT_REACHABLE",
          "detail": "Details: net::ERR_CONNECTION_CLOSED",
          "finalDisplayedUrl": "example.com"
        },
        "fcp": 100,
        "jsonReportUrl": "jsonReportUrl",
        "lcp": 100,
        "performanceScore": 90,
        "si": 100,
        "state": "COMPLETE",
        "tbt": 100,
        "ttfb": 100,
        "tti": 100
      },
      "mobileReport": {
        "cls": 100,
        "deviceType": "DESKTOP",
        "error": {
          "code": "NOT_REACHABLE",
          "detail": "Details: net::ERR_CONNECTION_CLOSED",
          "finalDisplayedUrl": "example.com"
        },
        "fcp": 100,
        "jsonReportUrl": "jsonReportUrl",
        "lcp": 100,
        "performanceScore": 90,
        "si": 100,
        "state": "COMPLETE",
        "tbt": 100,
        "ttfb": 100,
        "tti": 100
      },
      "region": {
        "label": "Iowa, USA",
        "value": "us-central1"
      },
      "scheduleFrequency": "DAILY",
      "url": "example.com"
    }
  }
}
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"
      }
    }
  ],
  "success": true,
  "result": {
    "schedule": {
      "frequency": "DAILY",
      "region": "us-central1",
      "url": "example.com"
    },
    "test": {
      "id": "f174e90a-fafe-4643-bbbc-4a0ed4fc8415",
      "date": "2014-01-01T05:20:00.12345Z",
      "desktopReport": {
        "cls": 100,
        "deviceType": "DESKTOP",
        "error": {
          "code": "NOT_REACHABLE",
          "detail": "Details: net::ERR_CONNECTION_CLOSED",
          "finalDisplayedUrl": "example.com"
        },
        "fcp": 100,
        "jsonReportUrl": "jsonReportUrl",
        "lcp": 100,
        "performanceScore": 90,
        "si": 100,
        "state": "COMPLETE",
        "tbt": 100,
        "ttfb": 100,
        "tti": 100
      },
      "mobileReport": {
        "cls": 100,
        "deviceType": "DESKTOP",
        "error": {
          "code": "NOT_REACHABLE",
          "detail": "Details: net::ERR_CONNECTION_CLOSED",
          "finalDisplayedUrl": "example.com"
        },
        "fcp": 100,
        "jsonReportUrl": "jsonReportUrl",
        "lcp": 100,
        "performanceScore": 90,
        "si": 100,
        "state": "COMPLETE",
        "tbt": 100,
        "ttfb": 100,
        "tti": 100
      },
      "region": {
        "label": "Iowa, USA",
        "value": "us-central1"
      },
      "scheduleFrequency": "DAILY",
      "url": "example.com"
    }
  }
}