scripts
Creates, updates, deletes, gets or lists a scripts resource.
Overview
| Name | scripts |
| Type | Resource |
| Id | cloudflare.workers.scripts |
Fields
The following fields are returned by SELECT queries:
- list_by_dispatch_namespace
- get
- list
List scripts in namespace response.
| Name | Datatype | Description |
|---|---|---|
created_on | string (date-time) | When the script was created. (example: 2017-01-01T00:00:00Z) |
dispatch_namespace | string | Name of the Workers for Platforms dispatch namespace. (example: my-dispatch-namespace) |
modified_on | string (date-time) | When the script was last modified. (example: 2017-01-01T00:00:00Z) |
script | object |
Worker successfully downloaded. Returns script content as a multipart form, with no metadata part and no JSON encoding applied.
| Name | Datatype | Description |
|---|---|---|
contents | string |
List Workers response.
| Name | Datatype | Description |
|---|---|---|
id | string | The name used to identify the script. (example: my-workers-script) |
compatibility_date | string | Date indicating targeted support in the Workers runtime. Backwards incompatible fixes to the runtime following this date will not affect this Worker. (example: 2021-01-01) |
compatibility_flags | array | Flags that enable or disable certain features in the Workers runtime. Used to enable upcoming features or opt in or out of specific changes not included in a compatibility_date. (x-stainless-collection-type: set) |
created_on | string (date-time) | When the script was created. (example: 2017-01-01T00:00:00Z) |
etag | string | Hashed script content, can be used in a If-None-Match header when updating. (example: ea95132c15732412d22c1476fa83f27a) |
handlers | array | The names of handlers exported as part of the default export. |
has_assets | boolean | Whether a Worker contains assets. |
has_modules | boolean | Whether a Worker contains modules. |
last_deployed_from | string | The client most recently used to deploy this Worker. (example: wrangler) |
logpush | boolean | Whether Logpush is turned on for the Worker. |
migration_tag | string | The tag of the Durable Object migration that was most recently applied for this Worker. (example: v1) |
modified_on | string (date-time) | When the script was last modified. (example: 2017-01-01T00:00:00Z) |
named_handlers | array | Named exports, such as Durable Object class implementations and named entrypoints. |
observability | object | Observability settings for the Worker. |
placement | object | Configuration for Smart Placement. Specify mode='smart' for Smart Placement, or one of region/hostname/host. |
placement_mode | string | Configuration for Smart Placement. Specify mode='smart' for Smart Placement, or one of region/hostname/host. (smart, targeted) |
placement_status | string | Status of Smart Placement. (SUCCESS, UNSUPPORTED_APPLICATION, INSUFFICIENT_INVOCATIONS) |
routes | array | Routes associated with the Worker. |
tag | string | The immutable ID of the script. (example: e8f70fdbc8b1fb0b8ddb1af166186758) |
tags | array | Tags associated with the Worker. (x-stainless-collection-type: set) |
tail_consumers | array | List of Workers that will consume logs from the attached Worker. (x-stainless-collection-type: set) |
usage_model | string | Usage model for the Worker invocations. (standard, bundled, unbound) (default: standard, example: standard) |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
list_by_dispatch_namespace | select | account_id, dispatch_namespace | tags | Fetch a list of scripts uploaded to a Workers for Platforms namespace. |
get | select | account_id, script_name | Fetch raw script content for your worker. Note this is the original script content, not JSON encoded. | |
list | select | account_id | tags | Fetch a list of uploaded workers. |
update | replace | account_id, script_name | bindings_inherit | Upload a worker module. You can find more about the multipart metadata on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/. |
namespace_worker_delete_scripts | delete | account_id, dispatch_namespace | tags, limit | Delete multiple scripts from a Workers for Platforms namespace based on optional tag filters. |
delete | delete | account_id, script_name | force | Delete your worker. This call has no response body on a successful delete. |
search | exec | account_id | name, id, order_by, page, per_page | Search for Workers in an account. |
create_assets_upload_session | exec | account_id, script_name, manifest | 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/. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
account_id | string | The Cloudflare account ID. |
dispatch_namespace | string | The Workers-for-Platforms dispatch namespace. |
script_name | string | The Worker script name. |
bindings_inherit | string | When set to "strict", the upload will fail if any inherit type bindings cannot be resolved against the previous version of the Worker. Without this, unresolvable inherit bindings are silently dropped. |
force | boolean | If set to true, delete will not be stopped by associated service binding, durable object, or other binding. Any of these associated bindings/durable objects will be deleted along with the script. |
id | string | |
limit | integer | Limit the number of scripts to delete. |
name | string | |
order_by | string | |
page | integer | Current page. |
per_page | integer | Items per page. |
tags | string | Filter scripts by tags before deletion. Format: comma-separated list of tag:allowed pairs where allowed is 'yes' or 'no'. |
SELECT examples
- list_by_dispatch_namespace
- get
- list
Fetch a list of scripts uploaded to a Workers for Platforms namespace.
SELECT
created_on,
dispatch_namespace,
modified_on,
script
FROM cloudflare.workers.scripts
WHERE account_id = '{{ account_id }}' -- required
AND dispatch_namespace = '{{ dispatch_namespace }}' -- required
AND tags = '{{ tags }}'
;
Fetch raw script content for your worker. Note this is the original script content, not JSON encoded.
SELECT
contents
FROM cloudflare.workers.scripts
WHERE account_id = '{{ account_id }}' -- required
AND script_name = '{{ script_name }}' -- required
;
Fetch a list of uploaded workers.
SELECT
id,
compatibility_date,
compatibility_flags,
created_on,
etag,
handlers,
has_assets,
has_modules,
last_deployed_from,
logpush,
migration_tag,
modified_on,
named_handlers,
observability,
placement,
placement_mode,
placement_status,
routes,
tag,
tags,
tail_consumers,
usage_model
FROM cloudflare.workers.scripts
WHERE account_id = '{{ account_id }}' -- required
AND tags = '{{ tags }}'
;
REPLACE examples
- update
Upload a worker module. You can find more about the multipart metadata on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/.
REPLACE cloudflare.workers.scripts
SET
-- No updatable properties
WHERE
account_id = '{{ account_id }}' --required
AND script_name = '{{ script_name }}' --required
AND bindings_inherit = '{{ bindings_inherit}}'
RETURNING
errors,
messages,
result,
success;
DELETE examples
- namespace_worker_delete_scripts
- delete
Delete multiple scripts from a Workers for Platforms namespace based on optional tag filters.
DELETE FROM cloudflare.workers.scripts
WHERE account_id = '{{ account_id }}' --required
AND dispatch_namespace = '{{ dispatch_namespace }}' --required
AND tags = '{{ tags }}'
AND limit = '{{ limit }}'
;
Delete your worker. This call has no response body on a successful delete.
DELETE FROM cloudflare.workers.scripts
WHERE account_id = '{{ account_id }}' --required
AND script_name = '{{ script_name }}' --required
AND force = '{{ force }}'
;
Lifecycle Methods
- search
- create_assets_upload_session
Search for Workers in an account.
EXEC cloudflare.workers.scripts.search
@account_id='{{ account_id }}' --required,
@name='{{ name }}',
@id='{{ id }}',
@order_by='{{ order_by }}',
@page='{{ page }}',
@per_page='{{ per_page }}'
;
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/.
EXEC cloudflare.workers.scripts.create_assets_upload_session
@account_id='{{ account_id }}' --required,
@script_name='{{ script_name }}' --required
@@json=
'{
"manifest": "{{ manifest }}"
}'
;