Management Zone list through API

Looking for a way to get a list of the Management Zones via the API.

Another option would be from the GUI.  If a path to that functionality can be provided.

There is a large numeric value that is used in query request to specify the MZ.   I would like to get a list of those.

Thanks all

Hello.
You can either use the Management Zone API (V1) or, in the new API v2, the builtin:management-zones schema Id, you can find info about it here.

I’m not seeing that option in the Docs.   Can you post an example of the api request here please?

You’ll find more information on the links I provided above :slightly_smiling_face:

Either way, here’s a quick example of a python script to list management zones from a given environment using V2 API. You’ll need to generate an access token with “Read Settings” v2 permissions:

PedroSantos_2-1727089519891.png

PedroSantos_0-1727089294786.png

import requests

# Dynatrace API endpoint and credentials
DT_API_TOKEN = '<Insert your token here>'

 # environment id looks similar to , for e.g., abc12345 (the part that comes before the .live.dynatrace.com on the link)
URL = f'https://{environmentid}.live.dynatrace.com/api/v2/settings/objects'

# Headers
headers = {
    'Authorization': f'Api-Token {DT_API_TOKEN}',
    'Content-Type': 'application/json'
}

# Query params for the Management Zones schema
params = {
    'schemaIds': 'builtin:management-zones',
    'pageSize': 100
}

# Fetch management zones
response = requests.get(URL, headers=headers, params=params)

# Check if the response was successful
if response.status_code == 200:
    management_zones = response.json().get('items', [])
    for zone in management_zones:
        print(f"Management Zone: {zone['value']['name']} (ID: {zone['objectId']})")
else:
    print(f"Error fetching management zones: {response.status_code} - {response.text}")

Let me know if this works for solving your problem @CrazyHarry