API request change rate_plan to domain

Hi, we have purchased an enterprise plan for 25 domains, commercially the arrangement made by my superior with Cloudflare commercial agents.

I need to automate the creation to new domains, for them we have to create a plan of the type “Free” and then change it to the plan “Enterprise” Plan.

I read the Cloudflare API v4 Documentation documentation but I don’t understand it.

I need an example through the curl command of how to change the plan from a Free domain to Enterprise.

Can you help me?

You can probably do something like this

curl --location --request POST 'https://api.cloudflare.com/client/v4/zones/<zone id>/subscription' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <API Token>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "rate_plan": {"id": "enterprise"}

I did this at one point in time:

curl -X GET "https://api.cloudflare.com/client/v4/zones/ZONE_ID/available_plans" -H "X-Auth-Email: [email protected]" -H "X-Auth-Key: API_KEY" -H "Content-Type: application/json"
curl -s -X PATCH 'https://api.cloudflare.com/client/v4/zones/ZONE_ID' \
     -H "X-Auth-Email: [email protected]" \
     -H "X-Auth-Key: MY_API_KEY" \
-H 'Content-Type: application/json' \
--data-raw '{