Upload Worker Module
client.workers.scripts.update(stringscriptName, ScriptUpdateParams { account_id, metadata, bindings_inherit, files } params, RequestOptionsoptions?): ScriptUpdateResponse { startup_time_ms, id, compatibility_date, 20 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/.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Accepted Permissions (at least one required)
Upload Worker Module
import Cloudflare from 'cloudflare';
const client = new Cloudflare({
apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted
});
const script = await client.workers.scripts.update('this-is_my_script-01', {
account_id: '023e105f4ecef8ad9ca31a8372d0c353',
metadata: {},
});
console.log(script.id);{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"startup_time_ms": 10,
"id": "this-is_my_script-01",
"compatibility_date": "2021-01-01",
"compatibility_flags": [
"nodejs_compat"
],
"created_on": "2022-05-05T05:15:11.602148Z",
"entry_point": "index.js",
"etag": "777f24a43bef5f69174aa69ceaf1dea67968d510a31d1vw3e49d34a0187c06d1",
"handlers": [
"fetch"
],
"has_assets": false,
"has_modules": false,
"last_deployed_from": "wrangler",
"logpush": false,
"migration_tag": "v1",
"modified_on": "2022-05-20T19:02:56.446492Z",
"named_handlers": [
{
"handlers": [
"class"
],
"name": "MyDurableObject"
}
],
"observability": {
"enabled": true,
"head_sampling_rate": 0.1,
"logs": {
"enabled": true,
"invocation_logs": true,
"destinations": [
"cloudflare"
],
"head_sampling_rate": 0.1,
"persist": true
},
"traces": {
"destinations": [
"cloudflare"
],
"enabled": true,
"head_sampling_rate": 0.1,
"persist": true
}
},
"placement": {
"mode": "smart",
"last_analyzed_at": "2025-01-01T00:00:00Z",
"status": "SUCCESS"
},
"placement_mode": "smart",
"placement_status": "SUCCESS",
"tag": "e8f70fdbc8b1fb0b8ddb1af166186758",
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"service": "my-log-consumer",
"environment": "production",
"namespace": "my-namespace"
}
],
"usage_model": "standard"
},
"success": true
}Returns Examples
{
"errors": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"messages": [
{
"code": 1000,
"message": "message",
"documentation_url": "documentation_url",
"source": {
"pointer": "pointer"
}
}
],
"result": {
"startup_time_ms": 10,
"id": "this-is_my_script-01",
"compatibility_date": "2021-01-01",
"compatibility_flags": [
"nodejs_compat"
],
"created_on": "2022-05-05T05:15:11.602148Z",
"entry_point": "index.js",
"etag": "777f24a43bef5f69174aa69ceaf1dea67968d510a31d1vw3e49d34a0187c06d1",
"handlers": [
"fetch"
],
"has_assets": false,
"has_modules": false,
"last_deployed_from": "wrangler",
"logpush": false,
"migration_tag": "v1",
"modified_on": "2022-05-20T19:02:56.446492Z",
"named_handlers": [
{
"handlers": [
"class"
],
"name": "MyDurableObject"
}
],
"observability": {
"enabled": true,
"head_sampling_rate": 0.1,
"logs": {
"enabled": true,
"invocation_logs": true,
"destinations": [
"cloudflare"
],
"head_sampling_rate": 0.1,
"persist": true
},
"traces": {
"destinations": [
"cloudflare"
],
"enabled": true,
"head_sampling_rate": 0.1,
"persist": true
}
},
"placement": {
"mode": "smart",
"last_analyzed_at": "2025-01-01T00:00:00Z",
"status": "SUCCESS"
},
"placement_mode": "smart",
"placement_status": "SUCCESS",
"tag": "e8f70fdbc8b1fb0b8ddb1af166186758",
"tags": [
"my-team",
"my-public-api"
],
"tail_consumers": [
{
"service": "my-log-consumer",
"environment": "production",
"namespace": "my-namespace"
}
],
"usage_model": "standard"
},
"success": true
}