Using my Workers account to deploy to domains owned by another account

I just started playing with Cloudflare workers.

I’m not being allowed access to our company’s Cloudflare account so that I can test independently. I’ll have to work with someone who has access to the actual account.

Can I write my worker using my worker account and then deploy using the company account’s credentials and have my worker run on the company account’s domains?

Or does the company account need to establish a worker account to test with, and then I will have to just transfer code to them so that it can be deployed to where it should be tested?


At my work I’ve automated the building and deploying of a worker script. We automatically deploy new workers to our company account by making use of Cloudflare’s API.
I make use of the following curl command to deploy the new worker via Cloudflare’s API:

curl -X PUT "${CF_ACCOUNT_ID}/workers/scripts/${CF_WORKER_ID}" \
  -H "X-Auth-Key: ${CF_API_TOKEN}" \
  -H "X-Auth-Email: ${CF_API_EMAIL}" \
  -H "Content-Type: application/javascript" \
  -T ./dist/worker.js \
  --write-out 'Status: %{http_code}' \
  --output /dev/null \
  --fail \
  --show-error \

You can modify the above command to fit your scenario. In this case I grab the API key, account email and account id from the environment variables CF_API_TOKEN / CF_API_EMAIL / CF_ACCOUNT_ID, and the Worker’s ID/name from CF_WORKER_ID, and then the worker script is grabbed from the ./dist/worker.js location.

You can read here more information about this specific API endpoint that’s being called in the snippet above.

That’s interesting you use -T, which I hadn’t tried. I use --data-binary “@file.ext

I believe I went with that because I have some special characters in the file.