Listing zones for only a specific account I'm a member of

Using the API, I need to list only those zones that belongs to a specific account and not all the accounts that I’m a member of.
How do I specify that match?

1 Like

Hi there,

I’m looking for a method to do a list_zones in the API that will only show a specific account/membership’s list of zones and not all the membership/accounts?

1 Like

I believe the API key is per Profile. The returned list of zones will be those the profile has access to. So if you go to your dashboard, that’s the same list of zones.

Nope @Jules, you are wrong.

My login/profile, have access to 4 “accounts”, my “own”, two of my clients’ accounts/profiles, and a friend’s profile/account. I’m a “member” that was granted access to those accounts.

When I do this API call/script:

#!/bin/bash

curl -v -H X-Auth-Key:`cat global-api.key` -H X-Auth-Email:`cat global.email` -X GET https://api.cloudflare.com/client/v4/zones/

I see in the output, zones of all four those accounts/profiles, not just mine. So, my issue, is I want to limit/match only (for example) my friend’s zones, or my own zones.

That is the question Jules ;(

Like I said, the API key is per profile. And your profile has access to multiple accounts and all zones therein.
You’re going to have to post process the API’s return to filter on the zones you want to concentrate on.

A Login is a Profile. But a Profile is not an Account. A Member is Profile that access to Accounts. It’s pretty confusing and not many people are fond of the way Cloudflare has it set up currently.

2 Likes

Ah, found the secret sauce… eventually:

Request URL:
https://dash.cloudflare.com/api/v4/zones?per_page=20&account.id=

Getting only the zones I’m interested in now, no need for post processing @Jules :slight_smile:

3 Likes

That’s great! Thank you for sharing the solution!