#Is it possible to add custom tags/metadata to Zone objects and custom hostnames?

13 messages · Page 1 of 1 (latest)

jade geyser
#

Hello Cloudflare Support Team,

I am using the GET /zones endpoint to retrieve the list of domains associated with our account.

My Question: Is there a native way to attach custom metadata, tags, or labels to a specific Zone ID via the API? Also i would like to know if it is possible to do in the custom hostnames.

Use Case: I need to categorize domains by custom types (e.g., "Public", "Private", "Internal", etc) directly within Cloudflare, so that when I fetch the zones via the API, I can see these custom tags in the response object.

torpid tundraBOT
#
Support AI

You can attach custom metadata to a specific Zone ID via the Custom Hostnames API, not directly to the Zone ID. According to the documentation, you can add custom metadata to Cloudflare via the Custom Hostnames API by making a PATCH request to the specific hostname ID to set metadata for that hostname.

Here's an example of how to add custom metadata to a custom hostname:

curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/custom_hostnames/$CUSTOM_HOSTNAME_ID" \
--request PATCH \
--header "X-Auth-Email: $CLOUDFLARE_EMAIL" \
--header "X-Auth-Key: $CLOUDFLARE_API_KEY" \
--json'{
"ssl": {
  "method": "http",
  "type": "dv"
},
"custom_metadata": {
  "customer_id": "12345",
  "redirect_to_https": true,
  "security_tag": "low"
}'

You can include your custom tags or labels in the custom_metadata JSON blob. However, please note that these custom metadata will not be directly visible when fetching zones via the API. Instead, you can access the custom metadata associated with a custom hostname through the cf.hostname.metadata field in the WAF.

For more information, please refer to the documentation on Submitting custom metadata and Security tagging system.

jade geyser
#

is it possible to add the tags via UI?

graceful pond
jade geyser
#

Thanks for information!
But i wish to know if it possible to add the tags to categorize custom hostnames and zones.
I want to do it via UI and when i use the API to retreive the information i want to see the tags in the response

#

The AI support has not been able to answer my question for 2 days already.

I really appreciate if someone will help me.
I can help to better understand my problem.

graceful pond
#

Wouldn't be too hard to build something external though to tie zone ids to tags/etc in your own database, if you want that

jade geyser
#

Yeah, thanks a lot, i am still thinking about building that in my own DB.

So as i have understood - there is no way to categorize domains in CloudFlare.

As "domains" i mean Custom Hostnames and Zones.

graceful pond
#

Specifically for the Custom Hostnames pattern, it's very common to store info about the link/custom hostname including stuff like that/etc in your own database

#

CF has API Rate Limits (1200 req/5 minutes, although they can be raised for Enterprise), and is slower then your own database would be, espec for customer facing stuff, just makes much more sense to pull info from your own db and only update info from CF's side occasionally/as needed

jade geyser
#

Thank you!