Worker Script
Upload Assets
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/.
Responses
201 Upload Assets response.
Data is at
body["result"]
{
"jwt": "*string*"
}202 Upload Assets response.
Data is at
body["result"]
{}4XX Upload Assets response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}List Workers
GET /accounts/{account_id}/workers/scripts
Fetch a list of uploaded workers.
Responses
200 List Workers response.
Data is at
body["result"]
[
{
"compatibility_date": "*string*",
"compatibility_flags": [
null
],
"created_on": "*string*",
"etag": "*string*",
"handlers": [
"*string*"
],
"has_assets": "*boolean*",
"has_modules": "*boolean*",
"id": "*string*",
"last_deployed_from": "*string*",
"logpush": "*boolean*",
"migration_tag": "*string*",
"modified_on": "*string*",
"named_handlers": [
{
"handlers": [
null
],
"name": "*string*"
}
],
"observability": {
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"logs": {
"destinations": null,
"enabled": null,
"head_sampling_rate": null,
"invocation_logs": null,
"persist": null
}
},
"placement": {
"last_analyzed_at": "*string*",
"status": null
},
"placement_mode": "*string*",
"placement_status": "*string*",
"routes": [
{
"id": null,
"pattern": null,
"script": null
}
],
"tag": "*string*",
"tags": [
null
],
"tail_consumers": [
null
],
"usage_model": "*string*"
}
]4XX List Workers response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Search Workers
GET /accounts/{account_id}/workers/scripts-search
Search for Workers in an account.
Responses
200 Search Workers success.
Data is at
body["result"]
[
{
"created_on": "*string*",
"environment_is_default": "*boolean*",
"environment_name": "*string*",
"id": "*string*",
"modified_on": "*string*",
"script_name": "*string*",
"service_name": "*string*"
}
]4XX Search Workers failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Upload Worker Module
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/.
Responses
200 Upload Worker Module response.
Data is at
body["result"]
{
"compatibility_date": "*string*",
"compatibility_flags": [
"*string*"
],
"created_on": "*string*",
"entry_point": "*string*",
"etag": "*string*",
"handlers": [
"*string*"
],
"has_assets": "*boolean*",
"has_modules": "*boolean*",
"id": "*string*",
"last_deployed_from": "*string*",
"logpush": "*boolean*",
"migration_tag": "*string*",
"modified_on": "*string*",
"named_handlers": [
{
"handlers": [
"*string*"
],
"name": "*string*"
}
],
"observability": {
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"logs": {
"destinations": [
"*string*"
],
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"invocation_logs": "*boolean*",
"persist": "*boolean*"
}
},
"placement": {
"last_analyzed_at": "*string*",
"status": "*string*"
},
"placement_mode": "*string*",
"placement_status": "*string*",
"startup_time_ms": "*integer*",
"tag": "*string*",
"tags": [
"*string*"
],
"tail_consumers": [
{
"environment": "*string*",
"namespace": "*string*",
"service": "*string*"
}
],
"usage_model": "*string*"
}4XX Upload Worker Module response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Download Worker
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.
Responses
200 Worker successfully downloaded. Returns script content as a multipart form, with no metadata part and no JSON encoding applied.
Data is at
body["result"]
4XX Download Worker response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Delete Worker
DELETE /accounts/{account_id}/workers/scripts/{script_name}
Delete your worker. This call has no response body on a successful delete.
Responses
200 Delete Worker response.
Data is at
body["result"]
{}4XX Delete Worker response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Create Assets Upload Session
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/.
Responses
200 Create Assets Upload Session response.
Data is at
body["result"]
{
"buckets": [
[
"*string*"
]
],
"jwt": "*string*"
}4XX Create Assets Upload Session response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Put script content
PUT /accounts/{account_id}/workers/scripts/{script_name}/content
Put script content without touching config or metadata.
Responses
200 Put script content.
Data is at
body["result"]
null4XX Put script content failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Get script content
GET /accounts/{account_id}/workers/scripts/{script_name}/content/v2
Fetch script content only.
Responses
200 Fetch script content.
Data is at
body["result"]
4XX Fetch script content failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Patch Script Settings
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.
Responses
200 Patch script settings.
Data is at
body["result"]
{
"logpush": "*boolean*",
"observability": {
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"logs": {
"destinations": [
"*string*"
],
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"invocation_logs": "*boolean*",
"persist": "*boolean*"
}
},
"tags": [
"*string*"
],
"tail_consumers": [
{
"environment": "*string*",
"namespace": "*string*",
"service": "*string*"
}
]
}4XX Patch script settings failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Get Script Settings
GET /accounts/{account_id}/workers/scripts/{script_name}/script-settings
Get script-level settings when using Worker Versions. Includes Logpush and Tail Consumers.
Responses
200 Fetch script settings.
Data is at
body["result"]
{
"logpush": "*boolean*",
"observability": {
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"logs": {
"destinations": [
"*string*"
],
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"invocation_logs": "*boolean*",
"persist": "*boolean*"
}
},
"tags": [
"*string*"
],
"tail_consumers": [
{
"environment": "*string*",
"namespace": "*string*",
"service": "*string*"
}
]
}4XX Fetch script settings failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Add script secret
PUT /accounts/{account_id}/workers/scripts/{script_name}/secrets
Add a secret to a script.
Responses
200 Put script secret binding success.
Data is at
body["result"]
{}4XX Put script secret binding failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}List script secrets
GET /accounts/{account_id}/workers/scripts/{script_name}/secrets
List secrets bound to a script.
Responses
200 List script secrets.
Data is at
body["result"]
[
{}
]4XX List script secrets failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Get secret binding
GET /accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}
Get a given secret binding (value omitted) on a script.
Responses
200 Get script secret binding.
Data is at
body["result"]
{}4XX Get script secret failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Delete script secret
DELETE /accounts/{account_id}/workers/scripts/{script_name}/secrets/{secret_name}
Remove a secret from a script.
Responses
200 Delete script secret binding.
Data is at
body["result"]
{}4XX Delete script secret failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Patch Settings
PATCH /accounts/{account_id}/workers/scripts/{script_name}/settings
Patch metadata or config, such as bindings or usage model.
Responses
200 Patch settings.
Data is at
body["result"]
{
"bindings": [
{}
],
"compatibility_date": "*string*",
"compatibility_flags": [
"*string*"
],
"limits": {
"cpu_ms": "*integer*"
},
"logpush": "*boolean*",
"migrations": null,
"observability": {
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"logs": {
"destinations": [
"*string*"
],
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"invocation_logs": "*boolean*",
"persist": "*boolean*"
}
},
"placement": {},
"tags": [
"*string*"
],
"tail_consumers": [
{
"environment": "*string*",
"namespace": "*string*",
"service": "*string*"
}
],
"usage_model": "*string*"
}4XX Patch settings failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Get Settings
GET /accounts/{account_id}/workers/scripts/{script_name}/settings
Get metadata and config, such as bindings or usage model.
Responses
200 Fetch settings.
Data is at
body["result"]
{
"bindings": [
{}
],
"compatibility_date": "*string*",
"compatibility_flags": [
"*string*"
],
"limits": {
"cpu_ms": "*integer*"
},
"logpush": "*boolean*",
"migrations": null,
"observability": {
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"logs": {
"destinations": [
"*string*"
],
"enabled": "*boolean*",
"head_sampling_rate": "*number*",
"invocation_logs": "*boolean*",
"persist": "*boolean*"
}
},
"placement": {},
"tags": [
"*string*"
],
"tail_consumers": [
{
"environment": "*string*",
"namespace": "*string*",
"service": "*string*"
}
],
"usage_model": "*string*"
}4XX Fetch settings failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Post Worker subdomain
POST /accounts/{account_id}/workers/scripts/{script_name}/subdomain
Enable or disable the Worker on the workers.dev subdomain.
Responses
200 Post subdomain response.
Data is at
body["result"]
{
"enabled": "*boolean*",
"previews_enabled": "*boolean*"
}4XX Post subdomain response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Get Worker subdomain
GET /accounts/{account_id}/workers/scripts/{script_name}/subdomain
Get if the Worker is available on the workers.dev subdomain.
Responses
200 Get subdomain response.
Data is at
body["result"]
{
"enabled": "*boolean*",
"previews_enabled": "*boolean*"
}4XX Get subdomain response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Delete Worker subdomain
DELETE /accounts/{account_id}/workers/scripts/{script_name}/subdomain
Disable all workers.dev subdomains for a Worker.
Responses
200 Delete subdomain response.
Data is at
body["result"]
{
"enabled": "*boolean*",
"previews_enabled": "*boolean*"
}4XX Delete subdomain response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Update Usage Model
PUT /accounts/{account_id}/workers/scripts/{script_name}/usage-model
Updates the Usage Model for a given Worker. Requires a Workers Paid subscription.
Responses
200 Update Usage Model response.
Data is at
body["result"]
{
"usage_model": "*string*",
"user_limits": {
"cpu_ms": "*integer*"
}
}4XX Update Usage Model response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}Fetch Usage Model
GET /accounts/{account_id}/workers/scripts/{script_name}/usage-model
Fetches the Usage Model for a given Worker.
Responses
200 Fetch Usage Model response.
Data is at
body["result"]
{
"usage_model": "*string*",
"user_limits": {
"cpu_ms": "*integer*"
}
}4XX Fetch Usage Model response failure.
{
"errors": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"messages": [
{
"code": "*integer*",
"documentation_url": "*string*",
"message": "*string*",
"source": {
"pointer": "*string*"
}
}
],
"result": {},
"success": "*boolean*"
}
Summary
Functions
@spec client(Restlax.Resource.action_options()) :: module()
@spec delete(id :: term(), opts :: Restlax.Resource.action_options()) :: {:ok, map()} | {:error, term()}
@spec delete!(id :: term(), opts :: Restlax.Resource.action_options()) :: map() | no_return()
@spec index(opts :: Restlax.Resource.action_options()) :: {:ok, map()} | {:error, term()}
@spec index!(opts :: Restlax.Resource.action_options()) :: map() | no_return()
@spec show(id :: term(), opts :: Restlax.Resource.action_options()) :: {:ok, map()} | {:error, term()}
@spec show!(id :: term(), opts :: Restlax.Resource.action_options()) :: map() | no_return()
@spec update( id :: term(), body :: Restlax.Resource.action_body(), opts :: Restlax.Resource.action_options() ) :: {:ok, map()} | {:error, term()}
@spec update!( id :: term(), body :: Restlax.Resource.action_body(), opts :: Restlax.Resource.action_options() ) :: map() | no_return()