PHP Client for Cloudflare API
Workers

Versions

Versions endpoint reference.

List

List of Worker Versions. The first version in the list is the latest version.

ParamTypeRequiredDefaultDescription
accountIdstringYesAccount identifier.
scriptNamestringYesName of the script, used in URLs and route configuration.
paramsarrayNo[]Array containing the necessary params.
php
$response = $client->workers()->versions()->list('ACCOUNT_ID', 'SCRIPT_NAME', []);
View this operation on the Cloudflare API Reference

Upload

Upload a Worker Version without deploying it to Cloudflare's network.

The request is a multipart upload: a JSON metadata part describing the Worker, and one part per module holding its source. Deploy the version afterwards with $client->workers()->deployments()->create().

$client->workers()->versions()->upload('ACCOUNT_ID', 'my-worker', [
    ['name' => 'worker.js', 'content' => file_get_contents('dist/worker.js')],
], [
    'compatibility_date' => '2026-01-01',
    'bindings' => [
        ['type' => 'plain_text', 'name' => 'MESSAGE', 'text' => 'Hello, world!'],
    ],
]);
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.
php
$response = $client->workers()->versions()->upload('ACCOUNT_ID', 'SCRIPT_NAME', [], []);
View this operation on the Cloudflare API Reference

Get

Get Version Details.

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