Host Partner Partial Zone Set Up (CNAME) API Instructions

Use Case: Basic Cloudflare provisioning without control panel access. Applicable for providers that can’t leverage pre-built Cloudflare plugins such as website builders, ecommerce and platform providers.

Start by creating a user using the `user_create` action on the Host API: https://www.cloudflare.com/docs/host-api.html#s3.2.1

The response will actually look something like this:

{
   "request": {
      "act": "user_create"
   },
   "response": {
       "cloudflare_email": "[email protected]",
       "user_key": "d5b67c0e77fd54482859be8ac7266ac2",
       unique_id": "test_account_id",
       "user_api_key": "dc1fe5280bdd96f9acf08cd232f18f462a599"
   },
   "result": "success",
   "msg": null
}

Be sure to save both the `user_key` and `user_api_key`. The `user_key` will be used in all the cases outlined below, for some additional services, the other key is needed.

Now that the user is registered with Cloudflare and is part of your account, you need to register the zone with Cloudflare.

The action should work like this curl request:

curl https://api.cloudflare.com/host-gw.html \
 -d 'act=zone_set' \
 -d 'host_key=8afbe6dea02407989af4dd4c97bb6e25' \
 -d 'user_key=57bd6ab7536daa87cab966ad723f014a' \
 -d 'zone_name=someexample.com' \
 -d 'resolve_to=cloudflare-resolve-to.someexample.com' \
 -d 'subdomains=www,blog,wordpress:cloudflare-rs2.someexample.com'

Additional information on this request is available here: https://www.cloudflare.com/docs/host-api.html#s3.2.2

The response from this call should be like the following JSON response:

{
    request: {
        act: "zone_set"
    },
    response: {
        zone_name: "someexample.com",
        resolving_to: "cloudflare-resolve-to.someexample.com",
        hosted_cnames: {
            www.someexample.com: "cloudflare-resolve-to.someexample.com",
            blog.someexample.com: "cloudflare-resolve-to.someexample.com",
            wordpress.someexample.com: "cloudflare-rs2.someexample.com"
        },
        forward_tos: {
            www.someexample.com: "www.someexample.com.cdn.cloudflare.net",
            blog.someexample.com: "blog.someexample.com.cdn.cloudflare.net",
            wordpress.someexample.com: "wordpress.someexample.com.cdn.cloudflare.net"
        }
    },
    result: "success",
    msg: null
}

Note: The CNAME and resolve to address should be updated in the local DNS as well.

 

 

Still not finding what you need?

The Cloudflare team is here to help. 95% of questions can be answered using the search tool, but if you can’t find what you need, submit a support request.

Powered by Zendesk