Resource Bindings API

Bindings are a way to expose external resources to a script that can be managed outside the script code (currently: text secrets, API keys, CryptoKeys - stay tuned for more!).

To upload bindings, the script upload endpoint has been extended to support POST requests with multipart/form-data bodies. The first part is a JSON representation of the worker’s metadata, including global variable bindings. This metadata may contain references to the other multipart parts, which may be of the following types:

  • text/javascript or application/javascript: a JavaScript file.
  • application/wasm: for WebAssembly module file

Since resources are tied to a script, you will be using the script endpoint to upload bindings.

If you are on a self-serve plan:

PUT /zones/:zone_id/workers/script

On an enterprise plan:

PUT /accounts/:account_id/workers/scripts/:script_name