Skip to content
Start here

Get Cron Triggers

client.Workers.Scripts.Schedules.Get(ctx, scriptName, query) (*ScriptScheduleGetResponse, error)
GET/accounts/{account_id}/workers/scripts/{script_name}/schedules

Fetches Cron Triggers for a Worker.

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)
Workers Scripts WriteWorkers Scripts Read
ParametersExpand Collapse
scriptName string

Name of the script, used in URLs and route configuration.

query ScriptScheduleGetParams
AccountID param.Field[string]

Identifier.

maxLength32
ReturnsExpand Collapse
type ScriptScheduleGetResponse struct{…}
Schedules []ScriptScheduleGetResponseSchedule
Cron string
CreatedOn stringOptional
ModifiedOn stringOptional

Get Cron Triggers

package main

import (
  "context"
  "fmt"

  "github.com/stainless-sdks/cloudflare-go"
  "github.com/stainless-sdks/cloudflare-go/option"
  "github.com/stainless-sdks/cloudflare-go/workers"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  schedule, err := client.Workers.Scripts.Schedules.Get(
    context.TODO(),
    "this-is_my_script-01",
    workers.ScriptScheduleGetParams{
      AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    },
  )
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", schedule.Schedules)
}
{
  "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": {
    "schedules": [
      {
        "cron": "*/30 * * * *",
        "created_on": "created_on",
        "modified_on": "modified_on"
      }
    ]
  },
  "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": {
    "schedules": [
      {
        "cron": "*/30 * * * *",
        "created_on": "created_on",
        "modified_on": "modified_on"
      }
    ]
  },
  "success": true
}