Workers

workers

Domain types

D1Binding = { id, binding, name, 1 more... }
DispatchNamespaceBinding = { name, namespace, type, 1 more... }
DurableObjectBinding = { class_name, name, type, 3 more... }
KVNamespaceBinding = { name, namespace_id, type }
MigrationStep = { deleted_classes, new_classes, new_sqlite_classes, 2 more... }
MTLSCERTBinding = { certificate_id, name, type }
PlacementConfiguration = { mode }
R2Binding = { bucket_name, name, type }
ServiceBinding = { environment, name, service, 1 more... }
SingleStepMigration = { deleted_classes, new_classes, new_sqlite_classes, 4 more... }
WorkerMetadata = { body_part, main_module }
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.

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.

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.

Security

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

Example: Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY

Accepted Permissions (at least one required)

Workers Scripts Write Workers Scripts Read

Parameters
account_id: string

Identifer of the account.

environment: string
Optional

Worker environment associated with the zone and hostname.

hostname: string
Optional

Hostname of the Worker Domain.

service: string
Optional

Worker service associated with the zone and hostname.

zone_id: string
Optional

Identifier of the zone.

zone_name: string
Optional

Name of the zone.

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

Whether the API call was successful

result: Array<>
Optional
Request example
200Example
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 -> unknown
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, 8 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, 7 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.

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 }

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.