Custom nameservers for the entire account

Couldn’t find a response to this elsewhere and support has been very slow so starting this thread here.

an authenticated request to /client/v4/accounts/MYACCOUNT/custom_ns/availability
(Get Eligible Zones for Account Custom Nameservers)
Returns to me that only one of my domains is available for custom DNS.

{'errors': [], 'messages': [], 'result': ['MYDOMAIN.COM'], 'success': True}

I assume if things were set up right it it should list all the zones (domains) in my account?
Cloudflare previously confirmed the custom nameserver feature was enabled for all zones in my account.
Its also a pity the API reference does not list what API Scopes are needed for each request.
I had to try a few until I found what Account Edit related API permissions are needed for /custom_ns

Here is the Python script:

import requests
import pprint

CF_API_TOKEN = 'MYAPITOKEN'
CF_ACCOUNT = 'MYACCOUNTNUMBER'

# Cloudflare API endpoint to list zones
CF_API_CUSTOMNS_URL = 'https://api.cloudflare.com/client/v4/accounts/' + CF_ACCOUNT + 'custom_ns/availability'

# Set the headers with your API token and content type
headers = {
    'Authorization': f'Bearer {CF_API_TOKEN}',
    'Content-Type': 'application/json'
}

response = requests.get(CF_API_CUSTOMNS_URL, headers=headers)

if response.status_code == 200:
    data = response.json()
    pprint.pprint(data)
else:
    print(response.status_code)

OK, had this tried with a zone and it works, regardless of what the API told me. So I think this is a bug as it should have listed all zones.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.