# Creating and Restoring Management Zones

**URL:** <https://community.dynatrace.com/t/creating-and-restoring-management-zones/43293>\
**Category:** Open Q&A\
**Tags:** management-zones, dynatrace-saas, documentation\
**Created:** [December 19, 2023, 3:50pm UTC](https://community.dynatrace.com/t/creating-and-restoring-management-zones/43293 "2023-12-19T15:50:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![HeadScratcher](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@HeadScratcher](https://community.dynatrace.com/u/HeadScratcher)\
**Post date:** [December 19, 2023, 3:50pm UTC](https://community.dynatrace.com/t/creating-and-restoring-management-zones/43293/1 "2023-12-19T15:50:13Z")

</div>

In our tenant we have approx 400 management zones, many created in error.&nbsp; My job is to to remove the unnecessary ones.&nbsp; I have prepared my list to delete (those with no hosts, no processes etc) which I can delete manually (boring) or via the API (preferred as I am lazy programmer type).

However, I wanted like to know if it is possible, to restore a deleted management zone in case I make a mistake and I can, again using the API.&nbsp; However in the API docs [Management zones API - POST a management zone - Dynatrace Docs](https://docs.dynatrace.com/docs/dynatrace-api/configuration-api/management-zones-api/post-mz)&nbsp;it says that the MZ ID field is optional but actually if I create the MZ with the previously used ID, then the API complains about a constraint violation and if I remove that ID field then it gets created fine.&nbsp; So I think optional means that the value should not be there… and perhaps ID can be there but with a blank value.

So maybe the docs could do with a correction…&nbsp; &nbsp;but that aside, my question is really whether it is possible to re-create the same MZ config on a tenant somehow?&nbsp; &nbsp;I want to use the same ID in case it is referenced somewhere else that&nbsp; I forgot to check before I deleted in the first place.

Hope my question is clear…

---

<div class="post-metadata">

**Author:** ![Mohamed\_Hamdy](https://avatars.discourse-cdn.com/v4/letter/m/7ab992/32.png) [@Mohamed\_Hamdy](https://community.dynatrace.com/u/Mohamed_Hamdy)\
**Post date:** [December 20, 2023, 4:52am UTC](https://community.dynatrace.com/t/creating-and-restoring-management-zones/43293/2 "2023-12-20T04:52:05Z")

</div>

Hi&nbsp;[@HeadScratcher](https://community.dynatrace.com/user/69708)&nbsp;,

You can use Monaco, for more details please check the following Link

> **[Configuration as Code via Monaco overview](https://docs.dynatrace.com/docs/deliver/configuration-as-code/monaco)**
>
> Manage your Dynatrace environment using Dynatrace Configuration as Code via Monaco.

Best Regards,

Mohamed

---

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [December 20, 2023, 10:10am UTC](https://community.dynatrace.com/t/creating-and-restoring-management-zones/43293/3 "2023-12-20T10:10:15Z")

</div>

Exactly that is the best way to go:blush:

---

<div class="post-metadata">

**Author:** ![HeadScratcher](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@HeadScratcher](https://community.dynatrace.com/u/HeadScratcher)\
**Post date:** [December 20, 2023, 2:49pm UTC](https://community.dynatrace.com/t/creating-and-restoring-management-zones/43293/4 "2023-12-20T14:49:00Z")

</div>

Monaco is just an alternative way to call the API I believe…

---

<div class="post-metadata">

**Author:** ![HeadScratcher](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@HeadScratcher](https://community.dynatrace.com/u/HeadScratcher)\
**Post date:** [December 20, 2023, 2:49pm UTC](https://community.dynatrace.com/t/creating-and-restoring-management-zones/43293/5 "2023-12-20T14:49:41Z")

</div>

I am not sure that it is… see above reply.

---

<div class="post-metadata">

**Author:** ![HeadScratcher](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@HeadScratcher](https://community.dynatrace.com/u/HeadScratcher)\
**Post date:** [December 21, 2023, 11:42am UTC](https://community.dynatrace.com/t/creating-and-restoring-management-zones/43293/6 "2023-12-21T11:42:23Z")

</div>

I had some suggestions from live support chat to suggest alternative API methods etc… posting the findings in case anyone finds useful in the future.

Assuming original MZ ID number of&nbsp; ‘-2800715523779578223’ and this management zone is deleted.

- Using post to create (including previous id) response=400 “Constraints violated.” "The payload must not have an id set.
- Using Put as suggested by Dynatrace Live Chat response=405 ‘Method Not Allowed’ “Not allowed HTTP method, expected one of [POST, GET, OPTIONS]”
- Using post (including tag but no value)&nbsp;response=400 “Constraints violated.” "The payload must not have an id set
- Using post (with id tag but value set to blank string ie no id value present)&nbsp;response=400, Constraints violated Not a valid 64-bit number.
- Using post (without id key / value present) response=201 Created&nbsp;id: -1185889278300505254 name:blah (OK MZ recreated with a new ID number)

Conclusion is that post works fine for creating a new MZ but with a proviso that DT will not allow re-use of ID numbers. With this in mind it is not possible to back up management zones fully, just the names/config.

In my scenario If I need to back up I will need to fix any dependent resources like alert profiles  
Others have suggested Monaco but I don’t think that will help any differently since that is just the API behind a different interface (confirmed by DT Live support).
