Batch add domain name API

request →
for domain in $(cat domains.txt); do curl -X POST -H “X-Auth-Key: $CF_API_KEY” -H “X-Auth-Email: $CF_API_EMAIL” -H “Content-Type: application/json” “https://api.cloudflare.com/client/v4/zones” --data ‘{“account”: {“id”: $id}, “name”:"’$domain’",“jump_start”:true}'; done

response →
{“success”:false,“errors”:[{“code”:1068,“message”:“Permission denied”}],“messages”:,“result”:null}

The result of the request is not authorized. I don’t know what went wrong. Please take a look at the big guys, thank you very much!

I’m not quite sure what this means, but do any other API requests work for you?

Is this your own account, or is this a Multi-User account?

step 1:
https://support.cloudflare.com/hc/en-us/articles/360000841472-Adding-Multiple-Sites-to-Cloudflare-via-Automation

This url document is the function I need to implement。

step 2:

I created and operated the token according to the instructions of this document, and returned the result {“code”:1068,“message”:“Permission denied”}

step 3:

My account is a single account, free user, why is Permission denied, can you understand my intention? thank you!

sdayman via Cloudflare Community <[email protected]> 于2020年12月16日周三 下午11:18写道:

Ok. If you’re using a Token instead of a Key, you need to use:
“Authorization: Bearer $CF_API_KEY”

for domain in $(cat domains.txt); do \

curl -X POST -H “Authorization: Bearer $CF_API_KEY” -H “X-Auth-Email: $CF_API_EMAIL” \

-H “Content-Type: application/json” \

https://api.cloudflare.com/client/v4/zones” \

–data ‘{“account”: {“id”: “4e35d5fad229820b28a41ba21fb7e03f”}, “name”:"’$domain’",“jump_start”:true}'; done

response:

{“account”: {“id”: “4e35d5fad229820b28a41ba21fb7e03f”}, “name”:“‘$domain’”,“jump_start”:true}'; done

{“success”:false,“errors”:[{“code”:6003,“message”:“Invalid request headers”,“error_chain”:[{“code”:6111,“message”:“Invalid format for Authorization header”}]}],“messages”:,“result”:null}

Invalid request headers,I don’t know if I’m doing this right.

Can you give me a correct demo, thank you very much!

sdayman via Cloudflare Community <[email protected]> 于2020年12月17日周四 上午12:39写道: