To add multiple sites to Cloudflare at once and more efficiently, you can do so via the Cloudflare API.
- Create an
.env
file in the root directory containing Cloudflare API Key information. You can copy the content from the.env.example
file.
CLOUDFLARE_EMAIL=YOUR_EMAIL
# Ref: https://developers.cloudflare.com/fundamentals/api/get-started/keys/
CLOUDFLARE_API_KEY=YOUR_API_KEY
# Ref: https://developers.cloudflare.com/fundamentals/setup/find-account-and-zone-ids/
ACCOUNT_ID=YOUR_ACCOUNT_ID
# IMPORTANT: Last line must be empty
- Create a
domains.txt
file in the root directory that includes the domains that need to be added to Cloudflare, each domain name on a separate line (newline separated). For example:
example.com
example.net
example.org
Please read the Limitations section carefully.
- Open Terminal and run the following command:
./add-multiple-zones.sh