Hanzo AI
OpenapiCloudflare

Replace scripts

Uploads or replaces a module Worker script.

PUT /v1/cloudflare/workers/scripts/{script}

Addresshttps://api.hanzo.ai/v1/cloudflare/workers/scripts/{script}
MethodPUT
Operationput_cloudflare_workers_scripts_by_script
AuthAuthorization: Bearer $HANZO_API_KEY

Uploads or replaces a module Worker script. It publishes to the org's OWN Cloudflare account under the name in the path, replacing whatever was there, and relays Cloudflare's result. The compatibility date, compatibility flags and bindings are packed into the multipart upload Cloudflare expects, beside the module source.

Requires ORG ADMIN — a Worker is arbitrary code on the org's own account and domains — so a caller who is only an org member is refused 403. An empty source is 400, as is a mainModule that is not a plain file name; 503 if the org has never connected a Cloudflare token.

Request

6 fields, body application/json (required).

FieldInTypeRequiredDescription
scriptpathstringyesScript means two things on this route, and the document says so in both places it appears: the PATH segment names the Worker to publish, and the BODY field…
bindingsbodyanyBindings are the resources the script can reach (KV, D1, R2, secrets, …), in Cloudflare's own binding vocabulary, passed through as written: this plane…
compatibilityDatebodystringCompatibilityDate pins which Workers runtime behaviour the script runs under, as a plain calendar date ("2024-01-01").
compatibilityFlagsbodystring[]CompatibilityFlags turn individual runtime behaviours on or off around that date ("nodejs_compat"), in Cloudflare's own flag vocabulary.
mainModulebodystringMainModule is the module file the runtime starts at.
scriptbodystringScript means two things on this route, and the document says so in both places it appears: the PATH segment names the Worker to publish, and the BODY field…

Response

StatusBodyMeaning
200ok

200 body — 1 field.

FieldInTypeAlwaysDescription
(body)bodyanyyes

Failure carries the platform error shape — see Errors.

Examples

hanzo cloudflare workers scripts set <script>

Cloudflare API · All Hanzo APIs · Interactive reference

How is this guide?

On this page