# Create Maintenance Window (API) for all hosts with a specific geoloc\_site

**URL:** <https://community.dynatrace.com/t/create-maintenance-window-api-for-all-hosts-with-a-specific-geoloc-site/18644>\
**Category:** Open Q&A\
**Tags:** maintenance-window\
**Created:** [March 2, 2020, 1:34pm UTC](https://community.dynatrace.com/t/create-maintenance-window-api-for-all-hosts-with-a-specific-geoloc-site/18644 "2020-03-02T13:34:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rene\_forstner](https://avatars.discourse-cdn.com/v4/letter/r/a88e57/32.png) [@rene\_forstner](https://community.dynatrace.com/u/rene_forstner)\
**Post date:** [March 2, 2020, 1:34pm UTC](https://community.dynatrace.com/t/create-maintenance-window-api-for-all-hosts-with-a-specific-geoloc-site/18644/1 "2020-03-02T13:34:48Z")

</div>

Hi,

I’d like to create a maintenance window for all hosts within a specific DC (GEOLOC\_Site) through API, however I’m not able to figure out the correct JSON to do this, beside quering for all entities prior the request and concatenate them within the entities.

I’d like to archive something like this:

```auto
"scope": {
        "entities": [],
      "matches": [
      {
        "type": "HOST",
        "managementZoneId": null,
        "tags": [
          {
            "context": "ENVIRONMENT",
            "key": "GEOLOC_SITE",
            "value": "GEOLOC_SITE-123456789abdcf"
          }
        ]
      }
    ]
  },

```

kind regards

René

---

<div class="post-metadata">

**Author:** ![michael\_bonner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/michael_bonner/32/36830_2.png) [@michael\_bonner](https://community.dynatrace.com/u/michael_bonner)\
**Post date:** [March 3, 2020, 3:25pm UTC](https://community.dynatrace.com/t/create-maintenance-window-api-for-all-hosts-with-a-specific-geoloc-site/18644/2 "2020-03-03T15:25:23Z")

</div>

Hi René

You are on the right track. However; we would use the **type** element in the **MonitoredEntityFilter** object to specify the geolocation. Documentation can be found on this here:

> **[Maintenance windows API - POST a maintenance window](https://docs.dynatrace.com/docs/dynatrace-api/configuration-api/maintenance-windows-api/post-mw)**
>
> Create a maintenance window via the Dynatrace API.

Such as:

1. “type”: “Geolocation”,
2. “managementZoneId”: example

If you navigate to your tenant. You can click the oneagent icon in the top right corner, you can navigate to configuration API to test a few queries 🙂

-Michael

---

<div class="post-metadata">

**Author:** ![Zanderfilet](https://avatars.discourse-cdn.com/v4/letter/z/a88e4f/32.png) [@Zanderfilet](https://community.dynatrace.com/u/Zanderfilet)\
**Post date:** [March 12, 2023, 12:28pm UTC](https://community.dynatrace.com/t/create-maintenance-window-api-for-all-hosts-with-a-specific-geoloc-site/18644/3 "2023-03-12T12:28:53Z")

</div>

Hi all,

i want to achieve nearly the same, but scope being limited to one management zone.

However using this

```markup
[
    {
        "schemaId": "builtin:alerting.maintenance-window",
        "scope": {
            "entities": [],
            "matches": [
                {
                    "type": "HOST",
                    "managementZoneId": "-89498072342349753701"
                }
            ]
        },

```

does give me a 400 in Postman (

“Could&nbsp;not&nbsp;map&nbsp;JSON&nbsp;at&nbsp;‘[0].scope’&nbsp;near&nbsp;line&nbsp;4&nbsp;column&nbsp;18”)

How do i define the scope here? Am i blind? 🙂

Many thanks,

Bjoern
