Skip to content
Start here

List Workers

workers.beta.workers.list(WorkerListParams**kwargs) -> SyncV4PagePaginationArray[Worker]
GET/accounts/{account_id}/workers/workers

List all Workers for an account.

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
account_id: str

Identifier.

maxLength32
order: Optional[Literal["asc", "desc"]]

Sort direction.

One of the following:
"asc"
"desc"
order_by: Optional[Literal["deployed_on", "updated_on", "created_on", "name"]]

Property to sort results by.

One of the following:
"deployed_on"
"updated_on"
"created_on"
"name"
page: Optional[int]

Current page.

minimum1
per_page: Optional[int]

Items per-page.

maximum100
minimum1
ReturnsExpand Collapse
class Worker:
id: str

Immutable ID of the Worker.

created_on: datetime

When the Worker was created.

formatdate-time
logpush: bool

Whether logpush is enabled for the Worker.

name: str

Name of the Worker.

observability: Observability

Observability settings for the Worker.

enabled: Optional[bool]

Whether observability is enabled for the Worker.

head_sampling_rate: Optional[float]

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

logs: Optional[ObservabilityLogs]

Log settings for the Worker.

destinations: Optional[List[str]]

A list of destinations where logs will be exported to.

enabled: Optional[bool]

Whether logs are enabled for the Worker.

head_sampling_rate: Optional[float]

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

invocation_logs: Optional[bool]

Whether invocation logs are enabled for the Worker.

persist: Optional[bool]

Whether log persistence is enabled for the Worker.

traces: Optional[ObservabilityTraces]

Trace settings for the Worker.

destinations: Optional[List[str]]

A list of destinations where traces will be exported to.

enabled: Optional[bool]

Whether traces are enabled for the Worker.

head_sampling_rate: Optional[float]

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

persist: Optional[bool]

Whether trace persistence is enabled for the Worker.

references: References

Other resources that reference the Worker and depend on it existing.

dispatch_namespace_outbounds: List[ReferencesDispatchNamespaceOutbound]

Other Workers that reference the Worker as an outbound for a dispatch namespace.

namespace_id: str

ID of the dispatch namespace.

namespace_name: str

Name of the dispatch namespace.

worker_id: str

ID of the Worker using the dispatch namespace.

worker_name: str

Name of the Worker using the dispatch namespace.

domains: List[ReferencesDomain]

Custom domains connected to the Worker.

id: str

ID of the custom domain.

certificate_id: str

ID of the TLS certificate issued for the custom domain.

hostname: str

Full hostname of the custom domain, including the zone name.

zone_id: str

ID of the zone.

zone_name: str

Name of the zone.

durable_objects: List[ReferencesDurableObject]

Other Workers that reference Durable Object classes implemented by the Worker.

namespace_id: str

ID of the Durable Object namespace being used.

namespace_name: str

Name of the Durable Object namespace being used.

worker_id: str

ID of the Worker using the Durable Object implementation.

worker_name: str

Name of the Worker using the Durable Object implementation.

queues: List[ReferencesQueue]

Queues that send messages to the Worker.

queue_consumer_id: str

ID of the queue consumer configuration.

queue_id: str

ID of the queue.

queue_name: str

Name of the queue.

workers: List[ReferencesWorker]

Other Workers that reference the Worker using service bindings.

id: str

ID of the referencing Worker.

name: str

Name of the referencing Worker.

subdomain: Subdomain

Subdomain settings for the Worker.

enabled: Optional[bool]

Whether the *.workers.dev subdomain is enabled for the Worker.

previews_enabled: Optional[bool]

Whether preview URLs are enabled for the Worker.

tags: List[str]

Tags associated with the Worker.

tail_consumers: List[TailConsumer]

Other Workers that should consume logs from the Worker.

name: str

Name of the consumer Worker.

updated_on: datetime

When the Worker was most recently updated.

formatdate-time
deployed_on: Optional[datetime]

When the Worker’s most recent deployment was created. null if the Worker has never been deployed.

formatdate-time

List Workers

import os
from cloudflare import Cloudflare

client = Cloudflare(
    api_token=os.environ.get("CLOUDFLARE_API_TOKEN"),  # This is the default and can be omitted
)
page = client.workers.beta.workers.list(
    account_id="023e105f4ecef8ad9ca31a8372d0c353",
)
page = page.result[0]
print(page.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": "e8f70fdbc8b1fb0b8ddb1af166186758",
      "created_on": "2019-12-27T18:11:19.117Z",
      "logpush": true,
      "name": "my-worker",
      "observability": {
        "enabled": true,
        "head_sampling_rate": 1,
        "logs": {
          "destinations": [
            "string"
          ],
          "enabled": true,
          "head_sampling_rate": 1,
          "invocation_logs": true,
          "persist": true
        },
        "traces": {
          "destinations": [
            "string"
          ],
          "enabled": true,
          "head_sampling_rate": 1,
          "persist": true
        }
      },
      "references": {
        "dispatch_namespace_outbounds": [
          {
            "namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "namespace_name": "my-dispatch-namespace",
            "worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "worker_name": "my-worker"
          }
        ],
        "domains": [
          {
            "id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "certificate_id": "certificate_id",
            "hostname": "my-worker.example.com",
            "zone_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "zone_name": "example.com"
          }
        ],
        "durable_objects": [
          {
            "namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "namespace_name": "my-durable-object-namespace",
            "worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "worker_name": "my-worker"
          }
        ],
        "queues": [
          {
            "queue_consumer_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "queue_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "queue_name": "my-queue"
          }
        ],
        "workers": [
          {
            "id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "name": "my-worker"
          }
        ]
      },
      "subdomain": {
        "enabled": true,
        "previews_enabled": true
      },
      "tags": [
        "my-team",
        "my-public-api"
      ],
      "tail_consumers": [
        {
          "name": "my-tail-consumer"
        }
      ],
      "updated_on": "2019-12-27T18:11:19.117Z",
      "deployed_on": "2019-12-27T18:11:19.117Z"
    }
  ],
  "success": true,
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}
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": "e8f70fdbc8b1fb0b8ddb1af166186758",
      "created_on": "2019-12-27T18:11:19.117Z",
      "logpush": true,
      "name": "my-worker",
      "observability": {
        "enabled": true,
        "head_sampling_rate": 1,
        "logs": {
          "destinations": [
            "string"
          ],
          "enabled": true,
          "head_sampling_rate": 1,
          "invocation_logs": true,
          "persist": true
        },
        "traces": {
          "destinations": [
            "string"
          ],
          "enabled": true,
          "head_sampling_rate": 1,
          "persist": true
        }
      },
      "references": {
        "dispatch_namespace_outbounds": [
          {
            "namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "namespace_name": "my-dispatch-namespace",
            "worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "worker_name": "my-worker"
          }
        ],
        "domains": [
          {
            "id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "certificate_id": "certificate_id",
            "hostname": "my-worker.example.com",
            "zone_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "zone_name": "example.com"
          }
        ],
        "durable_objects": [
          {
            "namespace_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "namespace_name": "my-durable-object-namespace",
            "worker_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "worker_name": "my-worker"
          }
        ],
        "queues": [
          {
            "queue_consumer_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "queue_id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "queue_name": "my-queue"
          }
        ],
        "workers": [
          {
            "id": "e8f70fdbc8b1fb0b8ddb1af166186758",
            "name": "my-worker"
          }
        ]
      },
      "subdomain": {
        "enabled": true,
        "previews_enabled": true
      },
      "tags": [
        "my-team",
        "my-public-api"
      ],
      "tail_consumers": [
        {
          "name": "my-tail-consumer"
        }
      ],
      "updated_on": "2019-12-27T18:11:19.117Z",
      "deployed_on": "2019-12-27T18:11:19.117Z"
    }
  ],
  "success": true,
  "result_info": {
    "count": 1,
    "page": 1,
    "per_page": 20,
    "total_count": 2000,
    "total_pages": 100
  }
}