Scripts
Cloudflare API docsList Workers
Fetch a list of uploaded workers.
$response = $client->workers()->scripts()->get('account_id');
Download Worker
Fetch raw script content for your worker. Note this is the original script content, not JSON encoded.
$response = $client->workers()->scripts()->get('account_id', 'script_name');
$content = $response->body();
Upload Worker Module
Upload a worker module. You can find more about the multipart metadata on CloudFlare docs.
//TODO
Get Content
Fetch script content only.
$response = $client->workers()->scripts()->getContent('account_id', 'script_name');
$content = $response->body();
Update Content
Put script content without touching config or metadata
//TODO
Get Script Settings
Get script-level settings when using Worker Versions. Includes Logpush and Tail Consumers.
$response = $client->workers()->scripts()->getScriptSettings('account_id', 'script_name');
Update Script Settings
Patch script-level settings when using Worker Versions. Includes Logpush and Tail Consumers.
$response = $client->workers()->scripts()->updateScriptSettings('account_id', 'script_name', [
'logpush' => false,
'tail_consumers' => [
[
'environment' => 'production'
]
]
]);
Get Settings
Get metadata and config, such as bindings or usage model
$response = $client->workers()->scripts()->getSettings('account_id', 'script_name');
Update Settings
Patch metadata or config, such as bindings or usage model
$response = $client->workers()->scripts()->updateSettings('account_id', 'script_name');
Get Usage Model
Fetches the Usage Model for a given Worker.
$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.
$response = $client->workers()->scripts()->updateUsageModel('account_id', 'script_name', 'usage_model');
Delete Worker
Delete your worker. This call has no response body on a successful delete.
$response = $client->workers()->scripts()->delete('account_id', 'script_name', true|false);