# Maintenance Window via API

**URL:** <https://community.dynatrace.com/t/maintenance-window-via-api/35297>\
**Category:** Dynatrace API\
**Tags:** maintenance-window\
**Created:** [May 29, 2022, 11:32am UTC](https://community.dynatrace.com/t/maintenance-window-via-api/35297 "2022-05-29T11:32:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malaik](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/malaik/32/32673_2.png) [@Malaik](https://community.dynatrace.com/u/Malaik)\
**Post date:** [May 29, 2022, 11:32am UTC](https://community.dynatrace.com/t/maintenance-window-via-api/35297/1 "2022-05-29T11:32:05Z")

</div>

Hi All,

Can some provide example for building maintenance window via API with the new mode?

The bellow way seems to be removed and routed to the second one, but not too easy to use:

![Malaik_0-1653823869447.png](https://global.discourse-cdn.com/dynatrace/original/2X/9/9468db7dc345fca01f9bb95a82b6472cc4b4e6fa.png)

Have a nice day.

---

<div class="post-metadata">

**Author:** ![mark\_bley](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mark_bley/32/20954_2.png) [@mark\_bley](https://community.dynatrace.com/u/mark_bley)\
**Post date:** [June 8, 2022, 2:20pm UTC](https://community.dynatrace.com/t/maintenance-window-via-api/35297/2 "2022-06-08T14:20:47Z")

</div>

Hi Malaik,

you can try following against the&nbsp;/api/v2/settings/objects endpoint

```markup
[
    {
        "schemaId": "builtin:alerting.maintenance-window",
        "scope": "environment",
        "value": {
            "enabled": true,
            "generalProperties": {
                "name": "Example Window",
                "description": "An example Maintenance window",
                "maintenanceType": "UNPLANNED",
                "suppression": "DETECT_PROBLEMS_AND_ALERT",
                "disableSyntheticMonitorExecution": true
            },
            "schedule": {
                "scheduleType": "MONTHLY",
                "monthlyRecurrence": {
                    "dayOfMonth": 1,
                    "timeWindow": {
                        "startTime": "13:45:00",
                        "endTime": "14:45:00",
                        "timeZone": "Europe/Vienna"
                    },
                    "recurrenceRange": {
                        "scheduleStartDate": "2022-04-01",
                        "scheduleEndDate": "2022-05-26"
                    }
                }
            },
            "filters": [
                {
                    "entityType": "HOST",
                    "entityTags": [
                        "[AWS]testkey:testvalue"
                    ]
                },
                {
                    "entityType": "HOST",
                    "entityId": "HOST-0A7500C12EB9471D",
                    "entityTags": [],
                    "managementZones": []
                }
            ]
        }
    }
]

```

Make sure the version defined in the payload matches the one you also see in your environment

 ![mark_bley_1-1654698033498.png](https://global.discourse-cdn.com/dynatrace/original/3X/c/d/cd2a004c6f76fcd177d6937d4e4782457e893480.png)

Hope this helps.

Best,

Mark

---

<div class="post-metadata">

**Author:** ![techean](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/techean/32/227_2.png) [@techean](https://community.dynatrace.com/u/techean)\
**Post date:** [June 8, 2022, 4:28pm UTC](https://community.dynatrace.com/t/maintenance-window-via-api/35297/3 "2022-06-08T16:28:34Z")

</div>

[@mark\_bley](https://community.dynatrace.com/user/13072)&nbsp; is right

similar thread marked closed already&nbsp;[Solved: Re: When will maintenance windows via the API for OneAgents will be available ? - Dynatrace Community](https://community.dynatrace.com/post/170270#M1487)

---

<div class="post-metadata">

**Author:** ![Malaik](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/malaik/32/32673_2.png) [@Malaik](https://community.dynatrace.com/u/Malaik)\
**Post date:** [June 9, 2022, 5:26am UTC](https://community.dynatrace.com/t/maintenance-window-via-api/35297/4 "2022-06-09T05:26:29Z")

</div>

Thanks&nbsp;[@mark\_bley](https://community.dynatrace.com/user/13072)

Solution found last time, thanks for your comment.

Just a comment, where can I get the view for schema version.
