WorkerWorkers for Platforms

Put Script Content (Workers for Platforms)

PUT
Put script content for a script uploaded to a Workers for Platforms namespace.

Path parameters

account_identifierstringRequired
Identifier
dispatch_namespacestringRequired
Name of the Workers for Platforms dispatch namespace.
script_namestringRequired
Name of the script, used in URLs and route configuration.

Headers

CF-WORKER-BODY-PARTstringOptional
The multipart name of a script upload part containing script content in service worker format. Alternative to including in a metadata part.
CF-WORKER-MAIN-MODULE-PARTstringOptional
The multipart name of a script upload part containing script content in es module format. Alternative to including in a metadata part.

Request

This endpoint expects an object.
<any part name>
list of stringsRequired

A module comprising a Worker script, often a javascript file. Multiple modules may be provided as separate named parts, but at least one module must be present. This should be referenced either in the metadata as main_module (esm)/body_part (service worker) or as a header CF-WORKER-MAIN-MODULE-PART (esm) /CF-WORKER-BODY-PART (service worker) by part name.

metadata
objectRequired
JSON encoded metadata about the uploaded parts and Worker configuration.

Response

This endpoint returns an object
created_on
datetimeOptional
When the script was created.
etag
stringOptional
Hashed script content, can be used in a If-None-Match header when updating.
id
stringOptional
The id of the script in the Workers system. Usually the script name.
logpush
booleanOptional
Whether Logpush is turned on for the Worker.
modified_on
datetimeOptional
When the script was last modified.
pipeline_hash
stringOptional
Deprecated. Deployment metadata for internal usage.
placement_mode
stringOptional
Specifies the placement mode for the Worker (e.g. 'smart').
tail_consumers
list of objectsOptional
List of Workers that will consume logs from the attached Worker.
usage_model
stringOptional
Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound').
PUT
1curl -X PUT https://api.cloudflare.com/client/v4/accounts/:account_identifier/workers/dispatch/namespaces/:dispatch_namespace/scripts/:script_name/content \
2 -H "X-Auth-Key: string" \
3 -H "X-Auth-User-Service-Key: string" \
4 -H "CF-WORKER-BODY-PART: string" \
5 -H "CF-WORKER-MAIN-MODULE-PART: string" \
6 -H "Authorization: Bearer <token>" \
7 -H "Content-Type: application/json" \
8 -d '{
9 "<any part name>": [
10 "string"
11 ],
12 "metadata": {}
13}'
200Updated
1{
2 "created_on": "2023-01-01T00:00:00Z",
3 "etag": "string",
4 "id": "string",
5 "logpush": true,
6 "modified_on": "2023-01-01T00:00:00Z",
7 "pipeline_hash": "string",
8 "placement_mode": "string",
9 "tail_consumers": [
10 {
11 "service": "string",
12 "environment": "string",
13 "namespace": "string"
14 }
15 ],
16 "usage_model": "string"
17}