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)

DNS View Write DNS View Read Load Balancers Account Write Load Balancers Account Read Cloudflare 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

Parameters
account_id: string
(maxLength: 32)

Identifier

Response fields
errors: Array<>
messages: Array<>
success: true

Whether the API call was successful

result: { default_usage_model, green_compute }
Optional
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

Domains

workers.domains

Methods

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

Detaches a Worker from a zone and hostname.

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

Gets a Worker domain.

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

Lists all Worker Domains for an account.

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

Attaches a Worker to a zone and hostname.

Domain types

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

Routes

workers.routes

Methods

Create Route -> { errors, messages, success }
post/zones/{zone_id}/workers/routes

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

Delete Route -> { errors, messages, success }
delete/zones/{zone_id}/workers/routes/{route_id}

Deletes a route.

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

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

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

Returns routes for a zone.

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

Updates the URL pattern or Worker associated with a route.

Workers

Scripts

workers.scripts

Methods

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

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

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.

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

Fetch a list of uploaded workers.

Upload Worker Module -> Envelope<{ id, created_on, etag, 10 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/.

Domain types

Script = { id, created_on, etag, 9 more... }
ScriptSetting = { logpush, observability, tail_consumers }

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

Create Deployment -> Envelope<{ strategy, versions, id, 4 more... }>
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.

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.

Domain types

Deployment = { workers/message }

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.

Domain types

Schedule = { created_on, cron, modified_on }

workers.scripts.settings

Methods

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.

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.

workers.scripts.subdomain

Methods

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

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

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

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

workers.scripts.tail

Methods

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.

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.

Domain types

ConsumerScript = { service, environment, namespace }

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

workers.scripts.versions

Methods

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/.

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

Get Version Detail

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.

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.