Adding Multiple Sites to Cloudflare via Automation

Learn how to add multiple sites (10+) to Cloudflare at once using the Cloudflare API, or Cloudflare's CLI tool, flarectl.


If you need to add multiple sites (10+) to Cloudflare at once, you can do so via the Cloudflare API. Adding multiple sites can be useful when you:

If you attempt to add more than 50 domains at a time, any additional domains will be blocked until they are processed.

  • Have multiple domains mapping back to a single, canonical domain - e.g. domains in different countries (,, etc) that you want to have protected by Cloudflare
  • Are an agency or IT consultancy, and manage multiple domains on behalf of your customers (note: you should consider the Cloudflare Partner program)
  • You're moving an existing set of sites over to Cloudflare

Using the API will allow you to add multiple sites quickly & efficiently, especially if you are already familiar with how to change your name-servers or add a DNS record.


You cannot have more pending sites than active sites associated with your Cloudflare account. We recommend waiting until your pending sites have been processed before adding additional domains.

To add multiple sites to Cloudflare via Automation, you'll need:

  • An existing account on Cloudflare (sign up / log-in))
  • Basic familiarity with the command line
  • curl installed (by default on macOS & Linux)
  • Your Cloudflare API key at hand
  • A list of domains you want to add, each on a separate line (newline separated) - e.g. "domains.txt"

Add domains via the API

Cloudflare has a fully featured API (documentation) that allows you to automate the creation of new domains, as well as configure DNS records, Page Rules and our many security settings. We'll be using this API to automate adding multiple domains at once.

Open your terminal application (e.g. Terminal, or and set your API key & email :

export CF_API_KEY=abc123def456ghi789

Then, we'll write a simple for-loop that takes each domain name 

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" \
"" \
--data '{"account": {"id": "id_of_that_account"}, "name":"'$domain'","jump_start":true}'; done

The "jump_start" key will have Cloudflare automatically attempt to scan for common DNS records—e.g. "www", "mail", "blog" and many others—so that you don't have to configure them by hand (you should still confirm we found them all).  id_of_that_account is found on the Cloudflare Overview app under Account ID.

The API will return a response, including the nameservers you'll need to change at your registrar (where you registered the domain).

"result": {
"id": "abc123def456ghi789",
"name": "",
"status": "pending",
"paused": false,
"type": "full",
"development_mode": 0,
"name_servers": [
"original_name_servers": [
"original_registrar": null,
"original_dnshost": null,
"modified_on": "2018-02-12T01:42:13.827149Z",
"created_on": "2018-02-12T01:42:13.827149Z",
"meta": {
"step": 4,
"wildcard_proxiable": false,
"custom_certificate_quota": 0,
"page_rule_quota": 3,
"phishing_detected": false,
"multiple_railguns_allowed": false
"owner": {
"id": "abc123def456ghi789",
"type": "user",
"email": ""
"account": {
"id": "abc123def456ghi789",
"name": ""
"permissions": [
"plan": {
"id": "0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
"name": "Free Website",
"price": 0,
"currency": "USD",
"frequency": "",
"is_subscribed": true,
"can_subscribe": false,
"legacy_id": "free",
"legacy_discount": false,
"externally_managed": false
"success": true,
"errors": [],
"messages": []

Note the "name_servers" key in the response. These will be the same unique pair for all sites you add under your account - e.g.

"name_servers": [

Copy your values (not the ones above!) and update the nameservers at your registrar.

Add domains via flarectl (Cloudflare's CLI tool)

You can also add domains using flarectl, Cloudflare's official CLI. You can download a pre-built package for your operating system (Windows, macOS/Darwin, Linux) and create domains using it.

You'll need to set your API credentials first:

export CF_API_KEY=abc123def456ghi789

... and then run the following command in flarectl:

for domain in $(cat domains.txt); do flarectl zone create --zone=$domain --jumpstart=false; done

After this, you can get the name-servers for each domain via "flarectl zone list":

for domain in $(cat domains.txt); do flarectl zone info --zone=$domain; done

Search for help or tips within the Cloudflare Community.

Common issues

If any errors were returned in this process, the domain may not be registered (or only just registered), be a subdomain, or otherwise been invalid. The following articles cover the most common cases: 

Not finding what you need?

95% of questions can be answered using the search tool. This is the quickest way to get a response.