PHP Client for Cloudflare API
Workers

Scripts

Scripts endpoint reference.

List

Fetch a list of uploaded workers.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
paramsarrayNo[]Query Parameters: `tags`, to filter by script tag.
php
$response = $client->workers()->scripts()->list('ACCOUNT_ID', []);
View this operation on the Cloudflare API Reference

Download

Fetch raw script content for your worker. Note this is the original script content, not JSON encoded.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
php
$response = $client->workers()->scripts()->download('ACCOUNT_ID', 'SCRIPT_NAME');
View this operation on the Cloudflare API Reference

Upload

Upload a Worker, replacing the deployed script and its configuration.

The request is a multipart upload: a JSON metadata part describing the Worker, and one part per module holding its source. Bindings and settings come from the metadata, so anything left out of it is dropped — send the whole configuration, not just what changed. To replace only the code, use updateContent(); to stage a Worker without deploying it, upload a version instead.

$client->workers()->scripts()->upload('ACCOUNT_ID', 'my-worker', [
    ['name' => 'worker.js', 'content' => file_get_contents('dist/worker.js')],
], [
    'compatibility_date' => '2026-01-01',
    'bindings' => [
        ['type' => 'kv_namespace', 'name' => 'KV', 'namespace_id' => 'NAMESPACE_ID'],
    ],
]);
ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
modulesarrayYesThe modules making up the Worker. Each one is `['name' => 'worker.js', 'content' => '…']`, optionally with `'type'` to override the default `application/javascript+module`.
metadataarrayNo[]Multipart metadata: `compatibility_date`, `bindings`, `migrations`, `placement`, and so on. `main_module` defaults to the first module.
paramsarrayNo[]Query Parameters, such as `['bindings_inherit' => 'strict']` to fail rather than silently drop bindings that cannot be inherited.
php
$response = $client->workers()->scripts()->upload('ACCOUNT_ID', 'SCRIPT_NAME', [], [], []);
View this operation on the Cloudflare API Reference

Update Content

Replace a Worker's code, leaving its configuration and metadata alone.

The counterpart of upload() for a code-only deploy: bindings, compatibility date and the rest of the Worker's settings are kept as they are.

$client->workers()->scripts()->updateContent('ACCOUNT_ID', 'my-worker', [
    ['name' => 'worker.js', 'content' => file_get_contents('dist/worker.js')],
]);
ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
modulesarrayYesThe modules making up the Worker. Each one is `['name' => 'worker.js', 'content' => '…']`, optionally with `'type'` to override the default `application/javascript+module`.
metadataarrayNo[]Multipart metadata naming the entry point. `main_module` defaults to the first module.
php
$response = $client->workers()->scripts()->updateContent('ACCOUNT_ID', 'SCRIPT_NAME', [], []);
View this operation on the Cloudflare API Reference

Get Content

Fetch script content only.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
php
$response = $client->workers()->scripts()->getContent('ACCOUNT_ID', 'SCRIPT_NAME');
View this operation on the Cloudflare API Reference

Get Script Settings

Get script-level settings when using Worker Versions. Includes Logpush and Tail Consumers.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
php
$response = $client->workers()->scripts()->getScriptSettings('ACCOUNT_ID', 'SCRIPT_NAME');
View this operation on the Cloudflare API Reference

Update Script Settings

Patch script-level settings when using Worker Versions. Includes Logpush and Tail Consumers.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
valuesarrayYesScript settings values.
php
$response = $client->workers()->scripts()->updateScriptSettings('ACCOUNT_ID', 'SCRIPT_NAME', []);
View this operation on the Cloudflare API Reference

Get Settings

Get metadata and config, such as bindings or usage model

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
php
$response = $client->workers()->scripts()->getSettings('ACCOUNT_ID', 'SCRIPT_NAME');
View this operation on the Cloudflare API Reference

Update Settings

Patch metadata or config, such as bindings or usage model

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
valuesarrayYesSettings values.
php
$response = $client->workers()->scripts()->updateSettings('ACCOUNT_ID', 'SCRIPT_NAME', []);
View this operation on the Cloudflare API Reference

Get Usage Model

Fetches the Usage Model for a given Worker.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
php
$response = $client->workers()->scripts()->getUsageModel('ACCOUNT_ID', 'SCRIPT_NAME');

Update Usage Model

Updates the Usage Model for a given Worker. Requires a Workers Paid subscription.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
usageModelstringYesUsage model.
php
$response = $client->workers()->scripts()->updateUsageModel('ACCOUNT_ID', 'SCRIPT_NAME', 'USAGE_MODEL');

Delete

Delete your worker. This call has no response body on a successful delete.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
forceboolNofalseIf 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.
php
$response = $client->workers()->scripts()->delete('ACCOUNT_ID', 'SCRIPT_NAME', true);
View this operation on the Cloudflare API Reference
Copyright © 2026