You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The existing API was originally designed for simple, one-shot script uploads.
20
+
21
+
22
+
The existing API was originally designed for simple, one-shot script uploads:
21
23
22
24
```sh
23
25
curl -X PUT "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/scripts/$SCRIPT_NAME" \
@@ -34,32 +36,34 @@ curl -X PUT "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/s
34
36
35
37
This API worked for creating a basic Worker, uploading all of its code, and deploying it immediately — but came with challenges:
36
38
37
-
-**A Worker couldn't exist without code**: To create a Worker, you had to upload its code in the same API request. This prevented platform teams in larger organizations from provisioning Workers with the proper settings, and then handing them off to development teams to deploy the actual code.
39
+
-**A Worker couldn't exist without code**: To create a Worker, you had to upload its code in the same API request. This meant platform teams couldn't provision Workers with the proper settings, and then hand them off to development teams to deploy the actual code.
38
40
39
-
-**Updating settings was confusing and fragmented**: With the existing API, configuration is scattered across eight different endpoints with overlapping responsibilities. This made it challenging for human developers (and even more difficult for AI agents) to reliably update a Worker's settings. You had to guess between [`/settings`](/api/resources/workers/subresources/scripts/subresources/schedules/methods/update/) and [`/script-settings`](/api/resources/workers/subresources/scripts/subresources/settings/methods/edit/), with not a lot of clarity about which endpoint updated all versions or a specific version of a Worker.
41
+
-**Several endpoints implicitly created deployments**: Simple updates like adding a secret or changing a script's content would implicitly create a new version and immediately deploy it.
40
42
41
-
-**Scripts used names as primary identifiers**: The existing API uses the Worker script name as the primary identifier for a Worker, which meant that if you wanted to rename a Worker via API, you needed to deploy an entirely new script and update every reference across your infrastructure. If you were using Terraform, renaming a Worker could inadvertently result in destroying the Worker altogether.
43
+
-**Updating a setting was confusing**: Configuration was scattered across eight endpoints with overlapping responsibilities. This ambiguity made it difficult for human developers (and even more so for AI agents) to reliably update a Worker via API.
44
+
45
+
-**Scripts used names as primary identifiers**: This meant simple renames could turn into a risky migration, requiring you to create a brand new Worker and update every reference. If you were using Terraform, this could inadvertently destroy your Worker altogether.
The new API introduces cleaner resource management with three core resources: [**Worker**](/api/resources/workers/subresources/beta/subresources/workers/methods/create/), [**Versions**](/api/resources/workers/subresources/beta/subresources/workers/models/worker/#(schema)), and [**Deployment**](/api/resources/workers/subresources/scripts/subresources/content/methods/update/).
46
50
47
-
:::note
48
-
[Workers](/api/resources/workers/subresources/beta/subresources/workers/) and [Versions](/api/resources/workers/subresources/beta/subresources/workers/subresources/versions/) use the new `/workers/` beta endpoints, while [Deployments](/api/resources/workers/subresources/scripts/subresources/deployments/) remain on the existing `/scripts/` endpoint. Pair the new endpoints with the existing Deployment API for a complete workflow.
49
-
:::
50
-
51
-
All endpoints now use simple JSON payloads, with script content embedded as `base64`-encoded strings —- a more consistent and reliable approach than the previous `multipart/form-data` format.
51
+
All endpoints now use simple JSON payloads, with script content embedded as `base64`-encoded strings -- a more consistent and reliable approach than the previous `multipart/form-data` format.
52
52
-**Worker**: The parent resource representing your application. It has a stable UUID and holds persistent settings like `name`, `tags`, and `logpush`. You can now create a Worker to establish its identity and settings **before** any code is uploaded.
53
53
54
54
-**Version**: An immutable snapshot of your code and its specific configuration, like bindings and `compatibility_date`. Creating a new version is a safe action that doesn't affect live traffic.
55
55
56
56
-**Deployment**: An explicit action that directs traffic to a specific version.
57
57
58
+
:::note
59
+
[Workers](/api/resources/workers/subresources/beta/subresources/workers/) and [Versions](/api/resources/workers/subresources/beta/subresources/workers/subresources/versions/) use the new `/workers/` beta endpoints, while [Deployments](/api/resources/workers/subresources/scripts/subresources/deployments/) remain on the existing `/scripts/` endpoint. Pair the new endpoints with the existing Deployment API for a complete workflow.
60
+
:::
61
+
58
62
## Why this matters
59
63
60
-
### Separation of concerns
64
+
### You can now create Workers before uploading code
61
65
62
-
The new API enables proper separation of concerns between infrastructure and application teams.
66
+
Workers are now standalone resources that can be created and configured without any code. Platform teams can provision Workers with the right settings, then hand them off to development teams for implementation.
-ThepreexistingWorkersRESTAPIremainsfullysupported. OncethenewAPIexitsbeta, we'll provide a migration timeline with ample notice and comprehensive migration guides.
161
-
-LegacyTerraformresourcesandSDKmethodswillcontinuetoworkthroughthecurrentmajorversion. Whendeprecatedinafuturemajorversion, we'll provide migration guides and plenty of notice.
-Thepre-existingWorkersRESTAPIremainsfullysupported. OncethenewAPIexitsbeta, we'll provide a migration timeline with ample notice and comprehensive migration guides.
0 commit comments