Skip to content

Commit 05f0b9b

Browse files
committed
cleans up text
1 parent b28f9e1 commit 05f0b9b

File tree

2 files changed

+53
-17
lines changed

2 files changed

+53
-17
lines changed
-2.23 KB
Loading

src/content/changelog/workers/2025-09-03-new-workers-api.mdx

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ This new API is supported in the [Cloudflare Terraform provider](https://registr
1717

1818
## Before: Eight+ endpoints with mixed responsibilities
1919
![**Before**](~/assets/images/workers/platform/api-before.png)
20-
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:
2123

2224
```sh
2325
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
3436

3537
This API worked for creating a basic Worker, uploading all of its code, and deploying it immediately — but came with challenges:
3638

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.
3840

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.
4042

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.
4246

4347
## After: Three resources with clear boundaries
4448
![**After**](~/assets/images/workers/platform/api-after.png)
4549
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/).
4650

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.
5252
- **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.
5353

5454
- **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.
5555

5656
- **Deployment**: An explicit action that directs traffic to a specific version.
5757

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+
5862
## Why this matters
5963

60-
### Separation of concerns
64+
### You can now create Workers before uploading code
6165

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.
6367

6468
#### Example: Typescript SDK
6569
```ts
@@ -112,8 +116,40 @@ resource "cloudflare_worker" "my_worker" {
112116
# resource "cloudflare_workers_deployment" "my_worker_deployment" {}
113117
```
114118

115-
### No more confusing `/settings` API endpoints
116-
Configuration now has an obvious home. Worker settings persist across all versions of the Worker, and Version settings are specific to a code snapshot.
119+
### Deployments are always explicit, never implicit
120+
121+
Creating a version and deploying it are now always explicit, separate actions - never implicit side effects. To update version-specific settings (like bindings), you create a new version with those changes. The existing deployed version remains unchanged until you explicitly deploy the new one.
122+
123+
```sh
124+
# Step 1: Create a new version with updated settings (doesn't affect live traffic)
125+
POST /workers/workers/{id}/versions
126+
{
127+
"compatibility_date": "$today",
128+
"bindings": [
129+
{
130+
"name": "MY_NEW_ENV_VAR",
131+
"text": "new_value",
132+
"type": "plain_text"
133+
}
134+
],
135+
"modules": [...]
136+
}
137+
138+
# Step 2: Explicitly deploy when ready (now affects live traffic)
139+
POST /workers/scripts/{script_name}/deployments
140+
{
141+
"strategy": "percentage",
142+
"versions": [
143+
{
144+
"percentage": 100,
145+
"version_id": "new_version_id"
146+
}
147+
]
148+
}
149+
```
150+
151+
### Settings are clearly organized by scope
152+
Configuration is now logically divided: [**Worker settings**](/api/resources/workers/subresources/beta/subresources/workers/) (like `name` and `tags`) persist across all versions, while [**Version settings**](/api/resources/workers/subresources/beta/subresources/workers/subresources/versions/) (like `bindings` and `compatibility_date`) are specific to each code snapshot.
117153

118154
```sh
119155
# Worker settings (the parent resource)
@@ -146,7 +182,7 @@ GET /workers/workers/payment-service # Name (convenient for hum
146182
```
147183
This dual approach means:
148184
- Developers can use readable names for debugging.
149-
- Automation can rely on stable UUIDs to prevent errors when Workers are renamed
185+
- Automation can rely on stable UUIDs to prevent errors when Workers are renamed.
150186
- Terraform can rename Workers without destroying and recreating them.
151187

152188

@@ -157,6 +193,6 @@ This dual approach means:
157193

158194
## Technical notes
159195

160-
- The preexisting Workers REST API remains fully supported. Once the new API exits beta, we'll provide a migration timeline with ample notice and comprehensive migration guides.
161-
- Legacy Terraform resources and SDK methods will continue to work through the current major version. When deprecated in a future major version, we'll provide migration guides and plenty of notice.
162-
- While the Deployments API currently remains on the `/scripts/` endpoint, we plan to introduce a new Deployments endpoint under `/workers/` to match the new API structure. Both endpoints will coexist, allowing you to choose which to use.
196+
- The pre-existing Workers REST API remains fully supported. Once the new API exits beta, we'll provide a migration timeline with ample notice and comprehensive migration guides.
197+
- Existing Terraform resources and SDK methods will continue to be fully supported through the current major version.
198+
- While the Deployments API currently remains on the `/scripts/` endpoint, we plan to introduce a new Deployments endpoint under `/workers/` to match the new API structure.

0 commit comments

Comments
 (0)