Workers

workers

Domain types

MigrationStep = { deleted_classes, new_classes, new_sqlite_classes, 2 more... }
SingleStepMigration = { deleted_classes, new_classes, new_sqlite_classes, 4 more... }

A single set of migrations to apply.

WorkerMetadata = { body_part, main_module }

JSON-encoded metadata about the uploaded parts and Worker configuration.

Workers

Account Settings

workers.account_settings

Methods

Fetch Worker Account Settings -> Envelope<{ default_usage_model, green_compute }>
get/accounts/{account_id}/workers/account-settings

Fetches Worker account settings for an account.

Security

The preferred authorization scheme for interacting with the Cloudflare API. Create a token.

Example: Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY

Accepted Permissions (at least one required)

Trust and Safety Write Trust and Safety Read DNS View Write DNS View Read SCIM Provisioning Load Balancers Account Write Load Balancers Account Read Zero Trust: PII Read DDoS Botnet Feed Write DDoS Botnet Feed Read Workers R2 Storage Write Workers R2 Storage Read DDoS Protection Write DDoS Protection Read Workers Tail Read Workers KV Storage Write Workers KV Storage Read Workers Scripts Write Workers Scripts Read Load Balancing: Monitors and Pools Write Load Balancing: Monitors and Pools Read Account Firewall Access Rules Write Account Firewall Access Rules Read DNS Firewall Write DNS Firewall Read Billing Write Billing Read Account Settings Write Account Settings Read

path Parameters
account_id: string
(maxLength: 32)

Identifier.

Response fields
errors: Array<{ code, message, documentation_url, 1 more... }>
messages: Array<{ code, message, documentation_url, 1 more... }>
result: { default_usage_model, green_compute }
success: true

Whether the API call was successful.

Request example
200Example
Create Worker Account Settings -> Envelope<{ default_usage_model, green_compute }>
put/accounts/{account_id}/workers/account-settings

Creates Worker account settings for an account.

Workers

Assets

workers.assets

workers.assets.upload

Methods

Upload Assets -> Envelope<{ jwt }>
post/accounts/{account_id}/workers/assets/upload

Upload assets ahead of creating a Worker version. To learn more about the direct uploads of assets, see https://developers.cloudflare.com/workers/static-assets/direct-upload/.

workers.beta

workers.beta.workers

Methods

List Workers -> V4PagePaginationArray<>
get/accounts/{account_id}/workers/workers

List all Workers for an account.

Get Worker -> Envelope<>
get/accounts/{account_id}/workers/workers/{worker_id}

Get details about a specific Worker.

Create Worker -> Envelope<>
post/accounts/{account_id}/workers/workers

Create a new Worker.

Update Worker -> Envelope<>
put/accounts/{account_id}/workers/workers/{worker_id}

Perform a complete replacement of a Worker, where omitted properties are set to their default values. This is the exact same as the Create Worker endpoint, but operates on an existing Worker. To perform a partial update instead, use the Edit Worker endpoint.

Edit Worker -> Envelope<>
patch/accounts/{account_id}/workers/workers/{worker_id}

Perform a partial update on a Worker, where omitted properties are left unchanged from their current values.

Delete Worker -> { errors, messages, success }
delete/accounts/{account_id}/workers/workers/{worker_id}

Delete a Worker and all its associated resources (versions, deployments, etc.).

Domain types

Worker = { id, created_on, logpush, 7 more... }

workers.beta.workers.versions

Methods

List Versions -> V4PagePaginationArray<>
get/accounts/{account_id}/workers/workers/{worker_id}/versions

List all versions for a Worker.

Get Version -> Envelope<>
get/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}

Get details about a specific version.

Create Version -> Envelope<>
post/accounts/{account_id}/workers/workers/{worker_id}/versions

Create a new version.

Delete Version -> { errors, messages, success }
delete/accounts/{account_id}/workers/workers/{worker_id}/versions/{version_id}

Delete a version.

Domain types

Version = { id, created_on, number, 12 more... }
Workers

Domains

workers.domains

Methods

List Domains -> SinglePage<>
get/accounts/{account_id}/workers/domains

Lists all Worker Domains for an account.

Get A Domain -> Envelope<>
get/accounts/{account_id}/workers/domains/{domain_id}

Gets a Worker domain.

Attach To Domain -> Envelope<>
put/accounts/{account_id}/workers/domains

Attaches a Worker to a zone and hostname.

Detach From Domain ->
delete/accounts/{account_id}/workers/domains/{domain_id}

Detaches a Worker from a zone and hostname.

Domain types

Domain = { id, environment, hostname, 3 more... }
Workers

Observability

workers.observability

workers.observability.telemetry

Methods

List Keys -> SinglePage<{ key, lastSeenAt, type }>
post/accounts/{account_id}/workers/observability/telemetry/keys

List all the keys in your telemetry events.

Run A Query -> Envelope<{ run, statistics, calculations, 4 more... }>
post/accounts/{account_id}/workers/observability/telemetry/query

Runs a temporary or saved query

List Values -> SinglePage<{ dataset, key, type, 1 more... }>
post/accounts/{account_id}/workers/observability/telemetry/values

List unique values found in your events

Workers

Routes

workers.routes

Methods

List Routes -> SinglePage<{ id, pattern, script }>
get/zones/{zone_id}/workers/routes

Returns routes for a zone.

Get Route -> Envelope<{ id, pattern, script }>
get/zones/{zone_id}/workers/routes/{route_id}

Returns information about a route, including URL pattern and Worker.

Create Route -> Envelope<{ id, pattern, script }>
post/zones/{zone_id}/workers/routes

Creates a route that maps a URL pattern to a Worker.

Update Route -> Envelope<{ id, pattern, script }>
put/zones/{zone_id}/workers/routes/{route_id}

Updates the URL pattern or Worker associated with a route.

Delete Route -> Envelope<{ id }>
delete/zones/{zone_id}/workers/routes/{route_id}

Deletes a route.

Workers

Scripts

workers.scripts

Methods

List Workers -> SinglePage<{ id, compatibility_date, compatibility_flags, 19 more... }>
get/accounts/{account_id}/workers/scripts

Fetch a list of uploaded workers.

Search Workers -> Envelope<Array<{ created_on, modified_on, script_name, 4 more... }>>
get/accounts/{account_id}/workers/scripts-search

Search for Workers in an account.

Download Worker -> string
get/accounts/{account_id}/workers/scripts/{script_name}

Fetch raw script content for your worker. Note this is the original script content, not JSON encoded.

Upload Worker Module -> Envelope<{ startup_time_ms, id, compatibility_date, 20 more... }>
put/accounts/{account_id}/workers/scripts/{script_name}

Upload a worker module. You can find more about the multipart metadata on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/.

Delete Worker -> Envelope<unknown>
delete/accounts/{account_id}/workers/scripts/{script_name}

Delete your worker. This call has no response body on a successful delete.

Domain types

Script = { id, compatibility_date, compatibility_flags, 18 more... }
ScriptSetting = { logpush, observability, tags, 1 more... }

workers.scripts.assets

workers.scripts.assets.upload

Methods

Create Assets Upload Session -> Envelope<{ buckets, jwt }>
post/accounts/{account_id}/workers/scripts/{script_name}/assets-upload-session

Start uploading a collection of assets for use in a Worker version. To learn more about the direct uploads of assets, see https://developers.cloudflare.com/workers/static-assets/direct-upload/.

workers.scripts.content

Methods

Get Script Content -> unknown
get/accounts/{account_id}/workers/scripts/{script_name}/content/v2

Fetch script content only.

Put Script Content -> Envelope<>
put/accounts/{account_id}/workers/scripts/{script_name}/content

Put script content without touching config or metadata.

WorkersScripts

Deployments

workers.scripts.deployments

Methods

List Deployments -> Envelope<{ deployments }>
get/accounts/{account_id}/workers/scripts/{script_name}/deployments

List of Worker Deployments. The first deployment in the list is the latest deployment actively serving traffic.

Create Deployment -> Envelope<>
post/accounts/{account_id}/workers/scripts/{script_name}/deployments

Deployments configure how Worker Versions are deployed to traffic. A deployment can consist of one or two versions of a Worker.

Get Deployment -> Envelope<>
get/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}

Get information about a Worker Deployment.

Delete Deployment -> { errors, messages, success }
delete/accounts/{account_id}/workers/scripts/{script_name}/deployments/{deployment_id}

Delete a Worker Deployment. The latest deployment, which is actively serving traffic, cannot be deleted. All other deployments can be deleted.

Domain types

Deployment = { id, created_on, source, 4 more... }

workers.scripts.schedules

Methods

Get Cron Triggers -> Envelope<{ schedules }>
get/accounts/{account_id}/workers/scripts/{script_name}/schedules

Fetches Cron Triggers for a Worker.

Update Cron Triggers -> Envelope<{ schedules }>
put/accounts/{account_id}/workers/scripts/{script_name}/schedules

Updates Cron Triggers for a Worker.

WorkersScripts

Script And Version Settings

workers.scripts.script_and_version_settings

Methods

Get Settings -> Envelope<{ bindings, compatibility_date, compatibility_flags, 8 more... }>
get/accounts/{account_id}/workers/scripts/{script_name}/settings

Get metadata and config, such as bindings or usage model.

Patch Settings -> Envelope<{ bindings, compatibility_date, compatibility_flags, 8 more... }>
patch/accounts/{account_id}/workers/scripts/{script_name}/settings

Patch metadata or config, such as bindings or usage model.

workers.scripts.secrets

Methods

List Script Secrets -> SinglePage<{ name, text, type } | { algorithm, format, name, 4 more... }>
get/accounts/{account_id}/workers/scripts/{script_name}/secrets

List secrets bound to a script.

Get Secret Binding -> Envelope<{ name, text, type } | { algorithm, format, name, 4 more... }>
get/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}

Get a given secret binding (value omitted) on a script.

Add Script Secret -> Envelope<{ name, text, type } | { algorithm, format, name, 4 more... }>
put/accounts/{account_id}/workers/scripts/{script_name}/secrets

Add a secret to a script.

Delete Script Secret -> Envelope<unknown>
delete/accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}

Remove a secret from a script.

workers.scripts.settings

Methods

Get Script Settings -> Envelope<>
get/accounts/{account_id}/workers/scripts/{script_name}/script-settings

Get script-level settings when using Worker Versions. Includes Logpush and Tail Consumers.

Patch Script Settings -> Envelope<>
patch/accounts/{account_id}/workers/scripts/{script_name}/script-settings

Patch script-level settings when using Worker Versions. Including but not limited to Logpush and Tail Consumers.

workers.scripts.subdomain

Methods

Get Worker Subdomain -> Envelope<{ enabled, previews_enabled }>
get/accounts/{account_id}/workers/scripts/{script_name}/subdomain

Get if the Worker is available on the workers.dev subdomain.

Post Worker Subdomain -> Envelope<{ enabled, previews_enabled }>
post/accounts/{account_id}/workers/scripts/{script_name}/subdomain

Enable or disable the Worker on the workers.dev subdomain.

Delete Worker Subdomain -> Envelope<{ enabled, previews_enabled }>
delete/accounts/{account_id}/workers/scripts/{script_name}/subdomain

Disable all workers.dev subdomains for a Worker.

workers.scripts.tail

Methods

List Tails -> Envelope<{ id, expires_at, url }>
get/accounts/{account_id}/workers/scripts/{script_name}/tails

Get list of tails currently deployed on a Worker.

Start Tail -> Envelope<{ id, expires_at, url }>
post/accounts/{account_id}/workers/scripts/{script_name}/tails

Starts a tail that receives logs and exception from a Worker.

Delete Tail -> { errors, messages, success }
delete/accounts/{account_id}/workers/scripts/{script_name}/tails/{id}

Deletes a tail from a Worker.

Domain types

ConsumerScript = { service, environment, namespace }

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

workers.scripts.versions

Methods

List Versions -> V4PagePagination<{ id, metadata, number }>
get/accounts/{account_id}/workers/scripts/{script_name}/versions

List of Worker Versions. The first version in the list is the latest version.

Get Version Detail -> Envelope<{ resources, id, metadata, 1 more... }>
get/accounts/{account_id}/workers/scripts/{script_name}/versions/{version_id}

Get Version Detail

Upload Version -> Envelope<{ resources, id, metadata, 2 more... }>
post/accounts/{account_id}/workers/scripts/{script_name}/versions

Upload a Worker Version without deploying to Cloudflare's network. You can find more about the multipart metadata on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/.

Workers

Subdomains

workers.subdomains

Methods

Get Subdomain -> Envelope<{ subdomain }>
get/accounts/{account_id}/workers/subdomain

Returns a Workers subdomain for an account.

Create Subdomain -> Envelope<{ subdomain }>
put/accounts/{account_id}/workers/subdomain

Creates a Workers subdomain for an account.

Delete Subdomain ->
delete/accounts/{account_id}/workers/subdomain

Deletes a Workers subdomain for an account.