Skip to content
Start here

Scripts

List Workers
client.Workers.Scripts.List(ctx, params) (*SinglePage[ScriptListResponse], error)
GET/accounts/{account_id}/workers/scripts
Search Workers
client.Workers.Scripts.Search(ctx, params) (*[]ScriptSearchResponse, error)
GET/accounts/{account_id}/workers/scripts-search
Download Worker
client.Workers.Scripts.Get(ctx, scriptName, query) (*string, error)
GET/accounts/{account_id}/workers/scripts/{script_name}
Upload Worker Module
client.Workers.Scripts.Update(ctx, scriptName, params) (*ScriptUpdateResponse, error)
PUT/accounts/{account_id}/workers/scripts/{script_name}
Delete Worker
client.Workers.Scripts.Delete(ctx, scriptName, params) (*ScriptDeleteResponse, error)
DELETE/accounts/{account_id}/workers/scripts/{script_name}
ModelsExpand Collapse
type Script struct{…}
ID stringoptional

The name used to identify the script.

CompatibilityDate stringoptional

Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker.

CompatibilityFlags []stringoptional

Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a compatibility_date.

CreatedOn Timeoptional

When the script was created.

formatdate-time
Etag stringoptional

Hashed script content, can be used in a If-None-Match header when updating.

Handlers []stringoptional

The names of handlers exported as part of the default export.

HasAssets booloptional

Whether a Worker contains assets.

HasModules booloptional

Whether a Worker contains modules.

LastDeployedFrom stringoptional

The client most recently used to deploy this Worker.

Logpush booloptional

Whether Logpush is turned on for the Worker.

MigrationTag stringoptional

The tag of the Durable Object migration that was most recently applied for this Worker.

ModifiedOn Timeoptional

When the script was last modified.

formatdate-time
NamedHandlers []ScriptNamedHandleroptional

Named exports, such as Durable Object class implementations and named entrypoints.

Handlers []stringoptional

The names of handlers exported as part of the named export.

Name stringoptional

The name of the export.

Observability ScriptObservabilityoptional

Observability settings for the Worker.

Enabled bool

Whether observability is enabled for the Worker.

HeadSamplingRate float64optional

The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

Logs ScriptObservabilityLogsoptional

Log settings for the Worker.

Enabled bool

Whether logs are enabled for the Worker.

InvocationLogs bool

Whether invocation logs are enabled for the Worker.

Destinations []stringoptional

A list of destinations where logs will be exported to.

HeadSamplingRate float64optional

The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

Persist booloptional

Whether log persistence is enabled for the Worker.

Traces ScriptObservabilityTracesoptional

Trace settings for the Worker.

Destinations []stringoptional

A list of destinations where traces will be exported to.

Enabled booloptional

Whether traces are enabled for the Worker.

HeadSamplingRate float64optional

The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

Persist booloptional

Whether trace persistence is enabled for the Worker.

Placement ScriptPlacementoptional

Configuration for Smart Placement. Specify mode='smart' for Smart Placement, or one of region/hostname/host.

One of the following:
type ScriptPlacementObject struct{…}
Mode ScriptPlacementObjectMode

Enables Smart Placement.

LastAnalyzedAt Timeoptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptPlacementObjectStatusoptional

Status of Smart Placement.

One of the following:
const ScriptPlacementObjectStatusSuccess ScriptPlacementObjectStatus = "SUCCESS"
const ScriptPlacementObjectStatusUnsupportedApplication ScriptPlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptPlacementObjectStatusInsufficientInvocations ScriptPlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptPlacementObject struct{…}
Region string

Cloud region for targeted placement in format 'provider:region'.

LastAnalyzedAt Timeoptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptPlacementObjectStatusoptional

Status of Smart Placement.

One of the following:
const ScriptPlacementObjectStatusSuccess ScriptPlacementObjectStatus = "SUCCESS"
const ScriptPlacementObjectStatusUnsupportedApplication ScriptPlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptPlacementObjectStatusInsufficientInvocations ScriptPlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptPlacementObject struct{…}
Hostname string

HTTP hostname for targeted placement.

LastAnalyzedAt Timeoptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptPlacementObjectStatusoptional

Status of Smart Placement.

One of the following:
const ScriptPlacementObjectStatusSuccess ScriptPlacementObjectStatus = "SUCCESS"
const ScriptPlacementObjectStatusUnsupportedApplication ScriptPlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptPlacementObjectStatusInsufficientInvocations ScriptPlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptPlacementObject struct{…}
Host string

TCP host and port for targeted placement.

LastAnalyzedAt Timeoptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptPlacementObjectStatusoptional

Status of Smart Placement.

One of the following:
const ScriptPlacementObjectStatusSuccess ScriptPlacementObjectStatus = "SUCCESS"
const ScriptPlacementObjectStatusUnsupportedApplication ScriptPlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptPlacementObjectStatusInsufficientInvocations ScriptPlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptPlacementObject struct{…}
Mode ScriptPlacementObjectMode

Targeted placement mode.

Region string

Cloud region for targeted placement in format 'provider:region'.

LastAnalyzedAt Timeoptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptPlacementObjectStatusoptional

Status of Smart Placement.

One of the following:
const ScriptPlacementObjectStatusSuccess ScriptPlacementObjectStatus = "SUCCESS"
const ScriptPlacementObjectStatusUnsupportedApplication ScriptPlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptPlacementObjectStatusInsufficientInvocations ScriptPlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptPlacementObject struct{…}
Hostname string

HTTP hostname for targeted placement.

Mode ScriptPlacementObjectMode

Targeted placement mode.

LastAnalyzedAt Timeoptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptPlacementObjectStatusoptional

Status of Smart Placement.

One of the following:
const ScriptPlacementObjectStatusSuccess ScriptPlacementObjectStatus = "SUCCESS"
const ScriptPlacementObjectStatusUnsupportedApplication ScriptPlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptPlacementObjectStatusInsufficientInvocations ScriptPlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptPlacementObject struct{…}
Host string

TCP host and port for targeted placement.

Mode ScriptPlacementObjectMode

Targeted placement mode.

LastAnalyzedAt Timeoptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptPlacementObjectStatusoptional

Status of Smart Placement.

One of the following:
const ScriptPlacementObjectStatusSuccess ScriptPlacementObjectStatus = "SUCCESS"
const ScriptPlacementObjectStatusUnsupportedApplication ScriptPlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptPlacementObjectStatusInsufficientInvocations ScriptPlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptPlacementObject struct{…}
Mode ScriptPlacementObjectMode

Targeted placement mode.

Target []ScriptPlacementObjectTarget

Array of placement targets (currently limited to single target).

One of the following:
type ScriptPlacementObjectTargetRegion struct{…}
Region string

Cloud region in format 'provider:region'.

type ScriptPlacementObjectTargetHostname struct{…}
Hostname string

HTTP hostname for targeted placement.

type ScriptPlacementObjectTargetHost struct{…}
Host string

TCP host:port for targeted placement.

LastAnalyzedAt Timeoptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptPlacementObjectStatusoptional

Status of Smart Placement.

One of the following:
const ScriptPlacementObjectStatusSuccess ScriptPlacementObjectStatus = "SUCCESS"
const ScriptPlacementObjectStatusUnsupportedApplication ScriptPlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptPlacementObjectStatusInsufficientInvocations ScriptPlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
DeprecatedPlacementMode ScriptPlacementModeoptional

Configuration for Smart Placement. Specify mode='smart' for Smart Placement, or one of region/hostname/host.

One of the following:
const ScriptPlacementModeSmart ScriptPlacementMode = "smart"
const ScriptPlacementModeTargeted ScriptPlacementMode = "targeted"
DeprecatedPlacementStatus ScriptPlacementStatusoptional

Status of Smart Placement.

One of the following:
const ScriptPlacementStatusSuccess ScriptPlacementStatus = "SUCCESS"
const ScriptPlacementStatusUnsupportedApplication ScriptPlacementStatus = "UNSUPPORTED_APPLICATION"
const ScriptPlacementStatusInsufficientInvocations ScriptPlacementStatus = "INSUFFICIENT_INVOCATIONS"
Tag stringoptional

The immutable ID of the script.

Tags []stringoptional

Tags associated with the Worker.

TailConsumers []ConsumerScriptoptional

List of Workers that will consume logs from the attached Worker.

Service string

Name of Worker that is to be the consumer.

Environment stringoptional

Optional environment if the Worker utilizes one.

Namespace stringoptional

Optional dispatch namespace the script belongs to.

UsageModel ScriptUsageModeloptional

Usage model for the Worker invocations.

One of the following:
const ScriptUsageModelStandard ScriptUsageModel = "standard"
const ScriptUsageModelBundled ScriptUsageModel = "bundled"
const ScriptUsageModelUnbound ScriptUsageModel = "unbound"
type ScriptSetting struct{…}
Logpush booloptional

Whether Logpush is turned on for the Worker.

Observability ScriptSettingObservabilityoptional

Observability settings for the Worker.

Enabled bool

Whether observability is enabled for the Worker.

HeadSamplingRate float64optional

The sampling rate for incoming requests. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

Logs ScriptSettingObservabilityLogsoptional

Log settings for the Worker.

Enabled bool

Whether logs are enabled for the Worker.

InvocationLogs bool

Whether invocation logs are enabled for the Worker.

Destinations []stringoptional

A list of destinations where logs will be exported to.

HeadSamplingRate float64optional

The sampling rate for logs. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

Persist booloptional

Whether log persistence is enabled for the Worker.

Traces ScriptSettingObservabilityTracesoptional

Trace settings for the Worker.

Destinations []stringoptional

A list of destinations where traces will be exported to.

Enabled booloptional

Whether traces are enabled for the Worker.

HeadSamplingRate float64optional

The sampling rate for traces. From 0 to 1 (1 = 100%, 0.1 = 10%). Default is 1.

Persist booloptional

Whether trace persistence is enabled for the Worker.

Tags []stringoptional

Tags associated with the Worker.

TailConsumers []ConsumerScriptoptional

List of Workers that will consume logs from the attached Worker.

Service string

Name of Worker that is to be the consumer.

Environment stringoptional

Optional environment if the Worker utilizes one.

Namespace stringoptional

Optional dispatch namespace the script belongs to.

ScriptsAssets

ScriptsAssetsUpload

Create Assets Upload Session
client.Workers.Scripts.Assets.Upload.New(ctx, scriptName, params) (*ScriptAssetUploadNewResponse, error)
POST/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session

ScriptsSubdomain

Get Worker subdomain
client.Workers.Scripts.Subdomain.Get(ctx, scriptName, query) (*ScriptSubdomainGetResponse, error)
GET/accounts/{account_id}/workers/scripts/{script_name}/subdomain
Post Worker subdomain
client.Workers.Scripts.Subdomain.New(ctx, scriptName, params) (*ScriptSubdomainNewResponse, error)
POST/accounts/{account_id}/workers/scripts/{script_name}/subdomain
Delete Worker subdomain
client.Workers.Scripts.Subdomain.Delete(ctx, scriptName, body) (*ScriptSubdomainDeleteResponse, error)
DELETE/accounts/{account_id}/workers/scripts/{script_name}/subdomain

ScriptsSchedules

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

ScriptsTail

List Tails
client.Workers.Scripts.Tail.Get(ctx, scriptName, query) (*ScriptTailGetResponse, error)
GET/accounts/{account_id}/workers/scripts/{script_name}/tails
Start Tail
client.Workers.Scripts.Tail.New(ctx, scriptName, params) (*ScriptTailNewResponse, error)
POST/accounts/{account_id}/workers/scripts/{script_name}/tails
Delete Tail
client.Workers.Scripts.Tail.Delete(ctx, scriptName, id, body) (*ScriptTailDeleteResponse, error)
DELETE/accounts/{account_id}/workers/scripts/{script_name}/tails/{id}
ModelsExpand Collapse
type ConsumerScript struct{…}

A reference to a script that will consume logs from the attached Worker.

Service string

Name of Worker that is to be the consumer.

Environment stringoptional

Optional environment if the Worker utilizes one.

Namespace stringoptional

Optional dispatch namespace the script belongs to.

ScriptsContent

Get script content
client.Workers.Scripts.Content.Get(ctx, scriptName, query) (*Response, error)
GET/accounts/{account_id}/workers/scripts/{script_name}/content/v2
Put script content
client.Workers.Scripts.Content.Update(ctx, scriptName, params) (*Script, error)
PUT/accounts/{account_id}/workers/scripts/{script_name}/content

ScriptsSettings

Get Script Settings
client.Workers.Scripts.Settings.Get(ctx, scriptName, query) (*ScriptSetting, error)
GET/accounts/{account_id}/workers/scripts/{script_name}/script-settings
Patch Script Settings
client.Workers.Scripts.Settings.Edit(ctx, scriptName, params) (*ScriptSetting, error)
PATCH/accounts/{account_id}/workers/scripts/{script_name}/script-settings

ScriptsDeployments

List Deployments
client.Workers.Scripts.Deployments.List(ctx, scriptName, query) (*ScriptDeploymentListResponse, error)
GET/accounts/{account_id}/workers/scripts/{script_name}/deployments
Create Deployment
client.Workers.Scripts.Deployments.New(ctx, scriptName, params) (*Deployment, error)
POST/accounts/{account_id}/workers/scripts/{script_name}/deployments
Get Deployment
client.Workers.Scripts.Deployments.Get(ctx, scriptName, deploymentID, query) (*Deployment, error)
GET/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}
Delete Deployment
client.Workers.Scripts.Deployments.Delete(ctx, scriptName, deploymentID, body) (*ScriptDeploymentDeleteResponse, error)
DELETE/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}
ModelsExpand Collapse
type Deployment struct{…}
ID string
formatuuid
CreatedOn Time
formatdate-time
Source string
Strategy DeploymentStrategy
Versions []DeploymentVersion
Percentage float64
maximum100
minimum0.01
VersionID string
formatuuid
Annotations DeploymentAnnotationsoptional
WorkersMessage stringoptional

Human-readable message about the deployment. Truncated to 100 bytes.

maxLength100
WorkersTriggeredBy stringoptional

Operation that triggered the creation of the deployment.

AuthorEmail stringoptional
formatemail

ScriptsVersions

List Versions
client.Workers.Scripts.Versions.List(ctx, scriptName, params) (*V4PagePagination[ScriptVersionListResponse], error)
GET/accounts/{account_id}/workers/scripts/{script_name}/versions
Get Version Detail
client.Workers.Scripts.Versions.Get(ctx, scriptName, versionID, query) (*ScriptVersionGetResponse, error)
GET/accounts/{account_id}/workers/scripts/{script_name}/versions/{version_id}
Upload Version
client.Workers.Scripts.Versions.New(ctx, scriptName, params) (*ScriptVersionNewResponse, error)
POST/accounts/{account_id}/workers/scripts/{script_name}/versions

ScriptsSecrets

List script secrets
client.Workers.Scripts.Secrets.List(ctx, scriptName, query) (*SinglePage[ScriptSecretListResponse], error)
GET/accounts/{account_id}/workers/scripts/{script_name}/secrets
Get secret binding
client.Workers.Scripts.Secrets.Get(ctx, scriptName, secretName, params) (*ScriptSecretGetResponse, error)
GET/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}
Add script secret
client.Workers.Scripts.Secrets.Update(ctx, scriptName, params) (*ScriptSecretUpdateResponse, error)
PUT/accounts/{account_id}/workers/scripts/{script_name}/secrets
Delete script secret
client.Workers.Scripts.Secrets.Delete(ctx, scriptName, secretName, params) (*ScriptSecretDeleteResponse, error)
DELETE/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}

ScriptsScript And Version Settings

Get Settings
client.Workers.Scripts.ScriptAndVersionSettings.Get(ctx, scriptName, query) (*ScriptScriptAndVersionSettingGetResponse, error)
GET/accounts/{account_id}/workers/scripts/{script_name}/settings
Patch Settings
client.Workers.Scripts.ScriptAndVersionSettings.Edit(ctx, scriptName, params) (*ScriptScriptAndVersionSettingEditResponse, error)
PATCH/accounts/{account_id}/workers/scripts/{script_name}/settings