How to query the API to get a list of all hostnames that are in pending_validation status?

I’m using Postman to query the Clouflare API. Looking for some doc or an example showing how to get a list of all custom_hostnames where the status is “pending_validation”.

You can use zones/:zone_identifier/custom_hostnames call to get all pending hostname.

curl -X GET “https://api.cloudflare.com/client/v4/zones/023e105f4ecef8ad9ca31a8372d0c353/custom_hostnames?hostname=app.example.com&id=0d89c70d-ad9f-4843-b99f-6cc0252067e9&page=1&per_page=20&order=ssl&direction=desc&ssl=0
-H “X-Auth-Email: [email protected]
-H “X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41”
-H “Content-Type: application/json”

Response would be -

{
“success”: true,
“errors”: ,
“messages”: ,
“result”: [
{
“id”: “0d89c70d-ad9f-4843-b99f-6cc0252067e9”,
“hostname”: “app.example.com”,
“ssl”: {
“status”: “pending_validation”,
“method”: “http”,
“type”: “dv”,
“cname_target”: “dcv.digicert.com”,
“cname”: “810b7d5f01154524b961ba0cd578acc2.app.example.com
}
}
]
}

1 Like

Thanks for the reply. I tried this, but it doesn’t give me only pending hostnames. Rather, it gives all custom hostnames. For my case, i have over 6k custom hostnames and most are not active. So I’m trying to write a script to delete the pending or expired host names. So for that, I want to get the list of all pending hostnames without having to inspect the status of each.