I can’t find the exact documentation for this. I know you can get a worker script, but can you POST to create a new worker with a specific wrangler.toml?
You can use the API, but it is not as simple as using wrangler.
You need to upload the script Cloudflare API Documentation
and for the bindings you would use Cloudflare API Documentation
Thank you for the reply. I did look at that, but it’s confusing because it’s a PUT method, which suggests that the worker must already exist.
Edit: maybe this is an endpoint missing from the docs? Should be:
POST /accounts/{account_id}/workers/scripts
It’s also confusing because there is this, which is labeled as “Upload Worker Module”:
PUT
https://api.cloudflare.com/client/v4/accounts/{account_id}/workers/scripts/{script_name}
And the data
for that is the worker script. So this seems also to be able to “create” a worker.
If that is what’s going on here, then I would be inclined to suggest a few changes to clarify things:
- Make it POST, not PUT
- Call it “Create Worker”, not “Upload Worker Module”
- Edit the description to make it clear that this is creating a new worker with the provided name and script content.
Cloudflare are clearly dealing with the two hardest problems in programming
- cache invalidation
- naming things.
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.