Skip to main content

scripts

Creates, updates, deletes, gets or lists a scripts resource.

Overview

Namescripts
TypeResource
Idcloudflare.workers_for_platforms.scripts

Fields

The following fields are returned by SELECT queries:

Worker Details Response (Workers for Platforms).

NameDatatypeDescription
created_onstring (date-time)When the script was created. (example: 2017-01-01T00:00:00Z)
dispatch_namespacestringName of the Workers for Platforms dispatch namespace. (example: my-dispatch-namespace)
modified_onstring (date-time)When the script was last modified. (example: 2017-01-01T00:00:00Z)
scriptobject

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectaccount_id, dispatch_namespace, script_nameFetch information about a script uploaded to a Workers for Platforms namespace.
updatereplaceaccount_id, dispatch_namespace, script_namebindings_inheritUpload a worker module to a Workers for Platforms namespace. You can find more about the multipart metadata on our docs: https://developers.cloudflare.com/workers/configuration/multipart-upload-metadata/.
deletedeleteaccount_id, dispatch_namespace, script_nameforceDelete a worker from a Workers for Platforms namespace. This call has no response body on a successful delete.
create_assets_upload_sessionexecaccount_id, dispatch_namespace, script_name, manifestStart 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.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
dispatch_namespacestringThe Workers-for-Platforms dispatch namespace.
script_namestringThe Worker script name.
bindings_inheritstringWhen set to "strict", the upload will fail if any inherit type bindings cannot be resolved against the previous version of the script. Without this, unresolvable inherit bindings are silently dropped.
forcebooleanIf 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.

SELECT examples

Fetch information about a script uploaded to a Workers for Platforms namespace.

SELECT
created_on,
dispatch_namespace,
modified_on,
script
FROM cloudflare.workers_for_platforms.scripts
WHERE account_id = '{{ account_id }}' -- required
AND dispatch_namespace = '{{ dispatch_namespace }}' -- required
AND script_name = '{{ script_name }}' -- required
;

REPLACE examples

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

REPLACE cloudflare.workers_for_platforms.scripts
SET
-- No updatable properties
WHERE
account_id = '{{ account_id }}' --required
AND dispatch_namespace = '{{ dispatch_namespace }}' --required
AND script_name = '{{ script_name }}' --required
AND bindings_inherit = '{{ bindings_inherit}}'
RETURNING
errors,
messages,
result,
success;

DELETE examples

Delete a worker from a Workers for Platforms namespace. This call has no response body on a successful delete.

DELETE FROM cloudflare.workers_for_platforms.scripts
WHERE account_id = '{{ account_id }}' --required
AND dispatch_namespace = '{{ dispatch_namespace }}' --required
AND script_name = '{{ script_name }}' --required
AND force = '{{ force }}'
;

Lifecycle Methods

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_for_platforms.scripts.create_assets_upload_session
@account_id='{{ account_id }}' --required,
@dispatch_namespace='{{ dispatch_namespace }}' --required,
@script_name='{{ script_name }}' --required
@@json=
'{
"manifest": "{{ manifest }}"
}'
;