# Management Zone list through API

**URL:** <https://community.dynatrace.com/t/management-zone-list-through-api/47862>\
**Category:** Dynatrace API\
**Tags:** dynatrace-api\
**Created:** [September 20, 2024, 4:50pm UTC](https://community.dynatrace.com/t/management-zone-list-through-api/47862 "2024-09-20T16:50:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CrazyHarry](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@CrazyHarry](https://community.dynatrace.com/u/CrazyHarry)\
**Post date:** [September 20, 2024, 4:50pm UTC](https://community.dynatrace.com/t/management-zone-list-through-api/47862/1 "2024-09-20T16:50:06Z")

</div>

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

Another option would be from the GUI.&nbsp; 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.&nbsp; &nbsp;I would like to get a list of those.

Thanks all

---

<div class="post-metadata">

**Author:** ![PedroSantos](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pedrosantos/32/28150_2.png) [@PedroSantos](https://community.dynatrace.com/u/PedroSantos)\
**Post date:** [September 20, 2024, 5:18pm UTC](https://community.dynatrace.com/t/management-zone-list-through-api/47862/2 "2024-09-20T17:18:34Z")

</div>

Hello.  
You can either use the&nbsp;[Management Zone API (V1)](https://docs.dynatrace.com/docs/dynatrace-api/configuration-api/management-zones-api) or, in the new API v2, the **builtin:management-zones** schema Id, you can find info about it [here.](https://docs.dynatrace.com/docs/dynatrace-api/environment-api/settings/schemas)

---

<div class="post-metadata">

**Author:** ![CrazyHarry](https://avatars.discourse-cdn.com/v4/letter/c/bbce88/32.png) [@CrazyHarry](https://community.dynatrace.com/u/CrazyHarry)\
**Post date:** [September 20, 2024, 6:12pm UTC](https://community.dynatrace.com/t/management-zone-list-through-api/47862/3 "2024-09-20T18:12:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PedroSantos](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/pedrosantos/32/28150_2.png) [@PedroSantos](https://community.dynatrace.com/u/PedroSantos)\
**Post date:** [September 23, 2024, 11:05am UTC](https://community.dynatrace.com/t/management-zone-list-through-api/47862/4 "2024-09-23T11:05:34Z")

</div>

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

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_1-1727089494450.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/6/c619589591e6fcfb0978aa1f13ac6597408c8069.png)

![PedroSantos_2-1727089519891.png](https://global.discourse-cdn.com/dynatrace/original/3X/9/5/95d3ce006da37b749bd601e3b648f8a821cec29e.png)

![PedroSantos_0-1727089294786.png](https://global.discourse-cdn.com/dynatrace/original/3X/b/0/b0e6cb1cb0ae046be8fdc5341c173e834c6bd117.png)

```python
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](https://community.dynatrace.com/user/80990)
