Add zone to cloudflare with API


down vote
I’m trying to add all my domains to cloudflare through the API (i’m using this lib:

Adding a zone works, but once added, I need to login to the cloudflare website to complete the setup wizard (I jump-start the domain, so cloudflare scans for dns-records).

I really would like to complete the wizard through the API, but I cannot find in the API how to do it. What I did find, is an error code “Could not promote zone to step 3”, and I suspect step 3 is the next step in the wizard. So i’m guessing it should be possible.

Does someone had the need to do the same thing and succeeded? Alle help is greatly appreciated.

PS: I already e-mailed cloudflare support, but with no response so far.


I think step 3 is select plan. Are you calling this section of the code you referenced and setting the plan type?

public function edit_plan($zone_identifier, $plan)
    $data = [
        'plan' => $plan,
    return $this->patch('zones/'.$zone_identifier, $data);


Thanks for your response!

Step 3 is indeed select plan. I did try to call edit_plan, but I get this error: “Invalid/Missing Zone plan ID”

This is the code i used:

$plan = new Cloudflare\Zone\Plan($client);
$plans = $plan->available($_GET['id']);

$zone = new Cloudflare\Zone($client);
$zone->edit_plan($_GET['id'], $plans->result[0]);

The plan i am passing through is the one i got from the $plan->available() function:

[0] => stdClass Object
                    [id] => free
                    [name] => Free Plan
                    [currency] => USD
                    [duration] => 1
                    [frequency] => months
                    [components] => Array
                            [0] => stdClass Object
                                    [name] => dedicated_certificates
                                    [default] => 0
                                    [unit_price] => 5

                            [1] => stdClass Object
                                    [name] => dedicated_certificates_custom
                                    [default] => 0
                                    [unit_price] => 10

                            [2] => stdClass Object
                                    [name] => page_rules
                                    [default] => 3
                                    [unit_price] => 1



But i’m not sure this edit_plan() is needed, as in my zone info, i have already a selecte plan:

[plan] => stdClass Object
                    [id] => 0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee
                    [name] => Free Website
                    [price] => 0
                    [currency] => USD
                    [frequency] => 
                    [is_subscribed] => 1
                    [can_subscribe] => 
                    [legacy_id] => free
                    [legacy_discount] => 
                    [externally_managed] => 


Are you initially setting jump_start to true and “status”: “active” as well?


I did set jump_start to true, but the ‘status:active’ is for an organization, and you have to have an enterprise account to be able to use it.

But, something changed now. I removed the domain that was stuck at ‘initializing’, and re-added it. Now, instead of ‘initializing’ it says pending, and when i change the name servers, it works (altough, jump_start is not always working correctly, sadly).

So, I don’t really know what the issue was, but it seems to be resolved (for now?)

Thank you very much for your help, I really appriciate it!