Skip to content
Start here

List Workers

client.Workers.Scripts.List(ctx, params) (*SinglePage[ScriptListResponse], error)
GET/accounts/{account_id}/workers/scripts

Fetch a list of uploaded workers.

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 Tail ReadWorkers Scripts WriteWorkers Scripts Read
ParametersExpand Collapse
params ScriptListParams
AccountID param.Field[string]

Path param: Identifier.

maxLength32
Tags param.Field[string]Optional

Query param: Filter scripts by tags. Format: comma-separated list of tag:allowed pairs where allowed is ‘yes’ or ‘no’.

ReturnsExpand Collapse
type ScriptListResponse struct{…}
ID stringOptional

The name used to identify the script.

CacheOptions ScriptListResponseCacheOptionsOptional

Global CacheW configuration for the Worker. When caching is on, the platform provisions a cloudflare.app zone for the Worker. A type: worker entry in the exports map can override this value for a single entrypoint.

Enabled bool

Whether caching is enabled for this Worker.

CrossVersionCache boolOptional

Whether cached responses are shared across Worker version uploads. This is independent of enabled. It can stay true while caching is off, so the preference survives turning caching off and back on.

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.

Exports map[string, ScriptListResponseExport]Optional

Declarative exports for the Worker’s most recent version, including Durable Object classes (with their storage backend) and named Worker entrypoints. Tombstoned lifecycle entries are omitted, so only live exports (created and expecting-transfer) are returned.

Type ScriptListResponseExportsType

The kind of export.

One of the following:
const ScriptListResponseExportsTypeWorker ScriptListResponseExportsType = "worker"
const ScriptListResponseExportsTypeDurableObject ScriptListResponseExportsType = "durable-object"
Cache ScriptListResponseExportsCacheOptional

Cache override for this entrypoint. It applies only to type: worker entries and overrides the Worker’s global cache_options.enabled for that entrypoint.

Enabled bool

Whether caching is enabled for this entrypoint.

RenamedTo stringOptional

Destination class name for a state: renamed tombstone. The target must appear as a live (created) entry in the same exports map. Write-only: never present in GET responses.

State ScriptListResponseExportsStateOptional

Lifecycle state of the export entry. Defaults to created (a normal, live export) when omitted.

deleted, renamed, and transferred are tombstones: write-only lifecycle operations that retire, rename, or hand off a provisioned Durable Object namespace. They are applied at upload and are filtered out of GET responses, so a read only ever returns created or expecting-transfer.

expecting-transfer is a live export whose data is being received from another script via the two-phase transfer flow; it carries storage and transfer_from.

One of the following:
const ScriptListResponseExportsStateCreated ScriptListResponseExportsState = "created"
const ScriptListResponseExportsStateDeleted ScriptListResponseExportsState = "deleted"
const ScriptListResponseExportsStateRenamed ScriptListResponseExportsState = "renamed"
const ScriptListResponseExportsStateTransferred ScriptListResponseExportsState = "transferred"
const ScriptListResponseExportsStateExpectingTransfer ScriptListResponseExportsState = "expecting-transfer"
Storage ScriptListResponseExportsStorageOptional

Storage backend for a type: durable-object export. Required for live Durable Object entries (created and expecting-transfer). sqlite selects SQLite-backed storage; legacy-kv selects the legacy key-value storage.

One of the following:
const ScriptListResponseExportsStorageSqlite ScriptListResponseExportsStorage = "sqlite"
const ScriptListResponseExportsStorageLegacyKV ScriptListResponseExportsStorage = "legacy-kv"
TransferFrom stringOptional

Source script for a state: expecting-transfer entry. The namespace on this script is materialised from the source script’s data via the pending-transfer flow. Present on reads for expecting-transfer entries.

TransferredTo stringOptional

Destination script for a state: transferred tombstone. Must reference a script in the same account; cross-dispatch-namespace transfers are rejected. Write-only: never present in GET responses.

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 []ScriptListResponseNamedHandlerOptional

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 ScriptListResponseObservabilityOptional

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 ScriptListResponseObservabilityLogsOptional

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 ScriptListResponseObservabilityTracesOptional

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.

PropagationPolicy ScriptListResponseObservabilityTracesPropagationPolicyOptional

Controls how inbound trace context (traceparent/tracestate) headers on incoming requests are handled. “authenticated” (default) honors inbound trace context only when accompanied by a valid trace auth token. “accept” unconditionally accepts inbound trace context. Requires the trace propagation feature to be enabled.

One of the following:
const ScriptListResponseObservabilityTracesPropagationPolicyAuthenticated ScriptListResponseObservabilityTracesPropagationPolicy = "authenticated"
const ScriptListResponseObservabilityTracesPropagationPolicyAccept ScriptListResponseObservabilityTracesPropagationPolicy = "accept"
Placement ScriptListResponsePlacementOptional

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

One of the following:
type ScriptListResponsePlacementObject struct{…}
Mode ScriptListResponsePlacementObjectMode
LastAnalyzedAt TimeOptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptListResponsePlacementObjectStatusOptional

Status of Smart Placement.

One of the following:
const ScriptListResponsePlacementObjectStatusSuccess ScriptListResponsePlacementObjectStatus = "SUCCESS"
const ScriptListResponsePlacementObjectStatusUnsupportedApplication ScriptListResponsePlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptListResponsePlacementObjectStatusInsufficientInvocations ScriptListResponsePlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptListResponsePlacementObject 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 ScriptListResponsePlacementObjectStatusOptional

Status of Smart Placement.

One of the following:
const ScriptListResponsePlacementObjectStatusSuccess ScriptListResponsePlacementObjectStatus = "SUCCESS"
const ScriptListResponsePlacementObjectStatusUnsupportedApplication ScriptListResponsePlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptListResponsePlacementObjectStatusInsufficientInvocations ScriptListResponsePlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptListResponsePlacementObject struct{…}
Hostname string

HTTP hostname for targeted placement.

LastAnalyzedAt TimeOptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptListResponsePlacementObjectStatusOptional

Status of Smart Placement.

One of the following:
const ScriptListResponsePlacementObjectStatusSuccess ScriptListResponsePlacementObjectStatus = "SUCCESS"
const ScriptListResponsePlacementObjectStatusUnsupportedApplication ScriptListResponsePlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptListResponsePlacementObjectStatusInsufficientInvocations ScriptListResponsePlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptListResponsePlacementObject 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 ScriptListResponsePlacementObjectStatusOptional

Status of Smart Placement.

One of the following:
const ScriptListResponsePlacementObjectStatusSuccess ScriptListResponsePlacementObjectStatus = "SUCCESS"
const ScriptListResponsePlacementObjectStatusUnsupportedApplication ScriptListResponsePlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptListResponsePlacementObjectStatusInsufficientInvocations ScriptListResponsePlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptListResponsePlacementObject struct{…}
Mode ScriptListResponsePlacementObjectMode

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 ScriptListResponsePlacementObjectStatusOptional

Status of Smart Placement.

One of the following:
const ScriptListResponsePlacementObjectStatusSuccess ScriptListResponsePlacementObjectStatus = "SUCCESS"
const ScriptListResponsePlacementObjectStatusUnsupportedApplication ScriptListResponsePlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptListResponsePlacementObjectStatusInsufficientInvocations ScriptListResponsePlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptListResponsePlacementObject struct{…}
Hostname string

HTTP hostname for targeted placement.

Mode ScriptListResponsePlacementObjectMode

Targeted placement mode.

LastAnalyzedAt TimeOptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptListResponsePlacementObjectStatusOptional

Status of Smart Placement.

One of the following:
const ScriptListResponsePlacementObjectStatusSuccess ScriptListResponsePlacementObjectStatus = "SUCCESS"
const ScriptListResponsePlacementObjectStatusUnsupportedApplication ScriptListResponsePlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptListResponsePlacementObjectStatusInsufficientInvocations ScriptListResponsePlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptListResponsePlacementObject struct{…}
Host string

TCP host and port for targeted placement.

Mode ScriptListResponsePlacementObjectMode

Targeted placement mode.

LastAnalyzedAt TimeOptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptListResponsePlacementObjectStatusOptional

Status of Smart Placement.

One of the following:
const ScriptListResponsePlacementObjectStatusSuccess ScriptListResponsePlacementObjectStatus = "SUCCESS"
const ScriptListResponsePlacementObjectStatusUnsupportedApplication ScriptListResponsePlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptListResponsePlacementObjectStatusInsufficientInvocations ScriptListResponsePlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
type ScriptListResponsePlacementObject struct{…}
Mode ScriptListResponsePlacementObjectMode

Targeted placement mode.

Target []ScriptListResponsePlacementObjectTarget

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

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

Cloud region in format ‘provider:region’.

type ScriptListResponsePlacementObjectTargetHostname struct{…}
Hostname string

HTTP hostname for targeted placement.

type ScriptListResponsePlacementObjectTargetHost struct{…}
Host string

TCP host:port for targeted placement.

LastAnalyzedAt TimeOptional

The last time the script was analyzed for Smart Placement.

formatdate-time
Status ScriptListResponsePlacementObjectStatusOptional

Status of Smart Placement.

One of the following:
const ScriptListResponsePlacementObjectStatusSuccess ScriptListResponsePlacementObjectStatus = "SUCCESS"
const ScriptListResponsePlacementObjectStatusUnsupportedApplication ScriptListResponsePlacementObjectStatus = "UNSUPPORTED_APPLICATION"
const ScriptListResponsePlacementObjectStatusInsufficientInvocations ScriptListResponsePlacementObjectStatus = "INSUFFICIENT_INVOCATIONS"
DeprecatedPlacementMode ScriptListResponsePlacementModeOptional
One of the following:
const ScriptListResponsePlacementModeSmart ScriptListResponsePlacementMode = "smart"
const ScriptListResponsePlacementModeTargeted ScriptListResponsePlacementMode = "targeted"
DeprecatedPlacementStatus ScriptListResponsePlacementStatusOptional
One of the following:
const ScriptListResponsePlacementStatusSuccess ScriptListResponsePlacementStatus = "SUCCESS"
const ScriptListResponsePlacementStatusUnsupportedApplication ScriptListResponsePlacementStatus = "UNSUPPORTED_APPLICATION"
const ScriptListResponsePlacementStatusInsufficientInvocations ScriptListResponsePlacementStatus = "INSUFFICIENT_INVOCATIONS"
Routes []ScriptListResponseRouteOptional

Routes associated with the Worker.

ID string

Identifier.

maxLength32
Pattern string

Pattern to match incoming requests against. Learn more.

Script stringOptional

Name of the script to run if the route matches.

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 ScriptListResponseUsageModelOptional

Usage model for the Worker invocations.

One of the following:
const ScriptListResponseUsageModelStandard ScriptListResponseUsageModel = "standard"
const ScriptListResponseUsageModelBundled ScriptListResponseUsageModel = "bundled"
const ScriptListResponseUsageModelUnbound ScriptListResponseUsageModel = "unbound"

List Workers

package main

import (
  "context"
  "fmt"

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

func main() {
  client := cloudflare.NewClient(
    option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
  )
  page, err := client.Workers.Scripts.List(context.TODO(), workers.ScriptListParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", page)
}
{
  "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": "my-workers-script",
      "cache_options": {
        "enabled": true,
        "cross_version_cache": true
      },
      "compatibility_date": "2021-01-01",
      "compatibility_flags": [
        "nodejs_compat"
      ],
      "created_on": "2017-01-01T00:00:00Z",
      "etag": "ea95132c15732412d22c1476fa83f27a",
      "exports": {
        "Admin": {
          "type": "worker",
          "cache": {
            "enabled": true
          },
          "state": "created",
          "storage": "sqlite",
          "transfer_from": "transfer_from"
        },
        "default": {
          "type": "worker",
          "cache": {
            "enabled": false
          },
          "state": "created",
          "storage": "sqlite",
          "transfer_from": "transfer_from"
        }
      },
      "handlers": [
        "fetch",
        "scheduled"
      ],
      "has_assets": false,
      "has_modules": false,
      "last_deployed_from": "wrangler",
      "logpush": false,
      "migration_tag": "v1",
      "modified_on": "2017-01-01T00:00:00Z",
      "named_handlers": [
        {
          "handlers": [
            "class"
          ],
          "name": "MyDurableObject"
        }
      ],
      "observability": {
        "enabled": true,
        "head_sampling_rate": 0.1,
        "logs": {
          "enabled": true,
          "invocation_logs": true,
          "destinations": [
            "cloudflare"
          ],
          "head_sampling_rate": 0.1,
          "persist": true
        },
        "traces": {
          "destinations": [
            "cloudflare"
          ],
          "enabled": true,
          "head_sampling_rate": 0.1,
          "persist": true,
          "propagation_policy": "authenticated"
        }
      },
      "placement": {
        "mode": "smart",
        "last_analyzed_at": "2025-01-01T00:00:00Z",
        "status": "SUCCESS"
      },
      "placement_mode": "smart",
      "placement_status": "SUCCESS",
      "routes": [
        {
          "id": "023e105f4ecef8ad9ca31a8372d0c353",
          "pattern": "example.com/*",
          "script": "my-workers-script"
        }
      ],
      "tag": "e8f70fdbc8b1fb0b8ddb1af166186758",
      "tags": [
        "my-team",
        "my-public-api"
      ],
      "tail_consumers": [
        {
          "service": "my-log-consumer",
          "environment": "production",
          "namespace": "my-namespace"
        }
      ],
      "usage_model": "standard"
    }
  ],
  "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": "my-workers-script",
      "cache_options": {
        "enabled": true,
        "cross_version_cache": true
      },
      "compatibility_date": "2021-01-01",
      "compatibility_flags": [
        "nodejs_compat"
      ],
      "created_on": "2017-01-01T00:00:00Z",
      "etag": "ea95132c15732412d22c1476fa83f27a",
      "exports": {
        "Admin": {
          "type": "worker",
          "cache": {
            "enabled": true
          },
          "state": "created",
          "storage": "sqlite",
          "transfer_from": "transfer_from"
        },
        "default": {
          "type": "worker",
          "cache": {
            "enabled": false
          },
          "state": "created",
          "storage": "sqlite",
          "transfer_from": "transfer_from"
        }
      },
      "handlers": [
        "fetch",
        "scheduled"
      ],
      "has_assets": false,
      "has_modules": false,
      "last_deployed_from": "wrangler",
      "logpush": false,
      "migration_tag": "v1",
      "modified_on": "2017-01-01T00:00:00Z",
      "named_handlers": [
        {
          "handlers": [
            "class"
          ],
          "name": "MyDurableObject"
        }
      ],
      "observability": {
        "enabled": true,
        "head_sampling_rate": 0.1,
        "logs": {
          "enabled": true,
          "invocation_logs": true,
          "destinations": [
            "cloudflare"
          ],
          "head_sampling_rate": 0.1,
          "persist": true
        },
        "traces": {
          "destinations": [
            "cloudflare"
          ],
          "enabled": true,
          "head_sampling_rate": 0.1,
          "persist": true,
          "propagation_policy": "authenticated"
        }
      },
      "placement": {
        "mode": "smart",
        "last_analyzed_at": "2025-01-01T00:00:00Z",
        "status": "SUCCESS"
      },
      "placement_mode": "smart",
      "placement_status": "SUCCESS",
      "routes": [
        {
          "id": "023e105f4ecef8ad9ca31a8372d0c353",
          "pattern": "example.com/*",
          "script": "my-workers-script"
        }
      ],
      "tag": "e8f70fdbc8b1fb0b8ddb1af166186758",
      "tags": [
        "my-team",
        "my-public-api"
      ],
      "tail_consumers": [
        {
          "service": "my-log-consumer",
          "environment": "production",
          "namespace": "my-namespace"
        }
      ],
      "usage_model": "standard"
    }
  ],
  "success": true
}