How to update Worker secrets via REST API (or TS SDK)?

I found such undocumented endpoints in
wrangler
's source code
:
  • To create and update Worker's secret:
    https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/workers/scripts/<WORKER_NAME>/secrets
  • To delete Worker's secret:
    https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/workers/scripts/<WORKER_NAME>/secrets/<SECRET_KEY>
Unfortunately they are not working. The update one fails with error saying that the key is already in use - of course it is:
{
  code: 10053,
  message: "Binding name 'INSTAGRAM_ACCESS_TOKEN' already in use. Please use a different name and try again."
}

So I tried to delete it first. And the delete one doesn't work as well saying the binding not found when it's already there:
 {
  code: 10056,
  message: "Binding 'INSTAGRAM_ACCESS_TOKEN' not found. Please use a different name and try again."
}


The API access token I'm using has full read/write previlages in the scope of the worker's zone.

I'm completely out of ideas. Please help.
GitHub
⛅️ Home to Wrangler, the CLI for Cloudflare Workers® - cloudflare/workers-sdk
Was this page helpful?