---
title: Schedule maintenance
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Status Pages
---

# Schedule maintenance{% #schedule-maintenance %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                                                 |
| ----------------- | ---------------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/statuspages/{page_id}/maintenances |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/statuspages/{page_id}/maintenances |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/statuspages/{page_id}/maintenances      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/statuspages/{page_id}/maintenances      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/statuspages/{page_id}/maintenances  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/statuspages/{page_id}/maintenances     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/statuspages/{page_id}/maintenances |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/statuspages/{page_id}/maintenances |

### Overview

Schedules a new maintenance. This endpoint requires the `status_pages_incident_write` permission.

OAuth apps require the `status_pages_incident_write` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#status-pages) to access this endpoint.



### Arguments

#### Path Parameters

| Name                      | Type   | Description                |
| ------------------------- | ------ | -------------------------- |
| page_id [*required*] | string | The ID of the status page. |

#### Query Strings

| Name               | Type    | Description                                                                                                          |
| ------------------ | ------- | -------------------------------------------------------------------------------------------------------------------- |
| notify_subscribers | boolean | Whether to notify page subscribers of the maintenance.                                                               |
| include            | string  | Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field        | Field                                     | Type      | Description                                                                 |
| ------------------- | ----------------------------------------- | --------- | --------------------------------------------------------------------------- |
|                     | data                                      | object    | The data object for creating a maintenance.                                 |
| data                | attributes [*required*]              | object    | The supported attributes for creating a maintenance.                        |
| attributes          | completed_date [*required*]          | date-time | Timestamp of when the maintenance was completed.                            |
| attributes          | completed_description [*required*]   | string    | The description shown when the maintenance is completed.                    |
| attributes          | components_affected                       | [object]  | The components affected by the maintenance.                                 |
| components_affected | id [*required*]                      | uuid      | The ID of the component. Must be a component of type `component`.           |
| components_affected | name                                      | string    | The name of the component.                                                  |
| components_affected | status [*required*]                  | enum      | The status of the component. Allowed enum values: `operational,maintenance` |
| attributes          | in_progress_description [*required*] | string    | The description shown while the maintenance is in progress.                 |
| attributes          | scheduled_description [*required*]   | string    | The description shown when the maintenance is scheduled.                    |
| attributes          | start_date [*required*]              | date-time | Timestamp of when the maintenance is scheduled to start.                    |
| attributes          | title [*required*]                   | string    | The title of the maintenance.                                               |
| data                | type [*required*]                    | enum      | Maintenances resource type. Allowed enum values: `maintenances`             |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "title": "API Maintenance",
      "scheduled_description": "We will be performing maintenance on the API to improve performance.",
      "in_progress_description": "We are currently performing maintenance on the API to improve performance.",
      "completed_description": "We have completed maintenance on the API to improve performance.",
      "start_date": "2021-11-11T12:11:11+00:00",
      "completed_date": "2021-11-11T13:11:11+00:00",
      "components_affected": [
        {
          "id": "4e9d3726-bdd7-0079-613c-e9aaba89eb01",
          "status": "operational"
        }
      ]
    },
    "type": "maintenances"
  }
}
```

{% /tab %}

### Response

{% tab title="201" %}
Created
{% tab title="Model" %}
Response object for a single maintenance.

| Parent field          | Field                       | Type            | Description                                                                                                                                             |
| --------------------- | --------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|                       | data                        | object          | The data object for a maintenance.                                                                                                                      |
| data                  | attributes                  | object          | The attributes of a maintenance.                                                                                                                        |
| attributes            | completed_date              | date-time       | Timestamp of when the maintenance was completed.                                                                                                        |
| attributes            | completed_description       | string          | The description shown when the maintenance is completed.                                                                                                |
| attributes            | components_affected         | [object]        | Components affected by the maintenance.                                                                                                                 |
| components_affected   | id [*required*]        | uuid            | The ID of the component. Must be a component of type `component`.                                                                                       |
| components_affected   | name                        | string          | The name of the component.                                                                                                                              |
| components_affected   | status [*required*]    | enum            | The status of the component. Allowed enum values: `operational,maintenance`                                                                             |
| attributes            | in_progress_description     | string          | The description shown while the maintenance is in progress.                                                                                             |
| attributes            | is_backfilled               | boolean         | Whether the maintenance was backfilled.                                                                                                                 |
| attributes            | modified_at                 | date-time       | Timestamp of when the maintenance was last modified.                                                                                                    |
| attributes            | published_date              | date-time       | Timestamp of when the maintenance was published.                                                                                                        |
| attributes            | scheduled_description       | string          | The description shown when the maintenance is scheduled.                                                                                                |
| attributes            | start_date                  | date-time       | Timestamp of when the maintenance is scheduled to start.                                                                                                |
| attributes            | status                      | enum            | The status of the maintenance. Allowed enum values: `scheduled,in_progress,completed`                                                                   |
| attributes            | title                       | string          | Title of the maintenance.                                                                                                                               |
| attributes            | updates                     | [object]        | Past updates made to the maintenance.                                                                                                                   |
| updates               | components_affected         | [object]        | The components affected at the time of the update.                                                                                                      |
| components_affected   | id [*required*]        | uuid            | Identifier of the component affected at the time of the update.                                                                                         |
| components_affected   | name                        | string          | The name of the component affected at the time of the update.                                                                                           |
| components_affected   | status [*required*]    | enum            | The status of the component affected at the time of the update. Allowed enum values: `operational,maintenance`                                          |
| updates               | created_at                  | date-time       | Timestamp of when the update was created.                                                                                                               |
| updates               | description                 | string          | Description of the update.                                                                                                                              |
| updates               | id                          | uuid            | Identifier of the update.                                                                                                                               |
| updates               | manual_transition           | boolean         | Whether the update was applied manually by a user (true) or automatically by the system (false).                                                        |
| updates               | modified_at                 | date-time       | Timestamp of when the update was last modified.                                                                                                         |
| updates               | started_at                  | date-time       | Timestamp of when the update started.                                                                                                                   |
| updates               | status                      | string          | The status of the update.                                                                                                                               |
| data                  | id                          | uuid            | The ID of the maintenance.                                                                                                                              |
| data                  | relationships               | object          | The relationships of a maintenance.                                                                                                                     |
| relationships         | created_by_user             | object          | The Datadog user who created the maintenance.                                                                                                           |
| created_by_user       | data [*required*]      | object          | The data object identifying the Datadog user who created the maintenance.                                                                               |
| data                  | id [*required*]        | uuid            | The ID of the Datadog user who created the maintenance.                                                                                                 |
| data                  | type [*required*]      | enum            | Users resource type. Allowed enum values: `users`                                                                                                       |
| relationships         | last_modified_by_user       | object          | The Datadog user who last modified the maintenance.                                                                                                     |
| last_modified_by_user | data [*required*]      | object          | The data object identifying the Datadog user who last modified the maintenance.                                                                         |
| data                  | id [*required*]        | uuid            | The ID of the Datadog user who last modified the maintenance.                                                                                           |
| data                  | type [*required*]      | enum            | Users resource type. Allowed enum values: `users`                                                                                                       |
| relationships         | status_page                 | object          | The status page the maintenance belongs to.                                                                                                             |
| status_page           | data [*required*]      | object          | The data object identifying the status page associated with a maintenance.                                                                              |
| data                  | id [*required*]        | uuid            | The ID of the status page.                                                                                                                              |
| data                  | type [*required*]      | enum            | Status pages resource type. Allowed enum values: `status_pages`                                                                                         |
| data                  | type [*required*]      | enum            | Maintenances resource type. Allowed enum values: `maintenances`                                                                                         |
|                       | included                    | [ <oneOf>] | The included related resources of a maintenance. Client must explicitly request these resources by name in the `include` query parameter.               |
| included              | Option 1                    | object          | The included Datadog user resource.                                                                                                                     |
| Option 1              | attributes                  | object          | Attributes of the Datadog user.                                                                                                                         |
| attributes            | email                       | string          | The email of the Datadog user.                                                                                                                          |
| attributes            | handle                      | string          | The handle of the Datadog user.                                                                                                                         |
| attributes            | icon                        | string          | The icon of the Datadog user.                                                                                                                           |
| attributes            | name                        | string          | The name of the Datadog user.                                                                                                                           |
| attributes            | uuid                        | string          | The UUID of the Datadog user.                                                                                                                           |
| Option 1              | id                          | uuid            | The ID of the Datadog user.                                                                                                                             |
| Option 1              | type [*required*]      | enum            | Users resource type. Allowed enum values: `users`                                                                                                       |
| included              | Option 2                    | object          | The included status page resource.                                                                                                                      |
| Option 2              | attributes                  | object          | The attributes of a status page.                                                                                                                        |
| attributes            | company_logo                | string          | The base64-encoded image data displayed in the company logo.                                                                                            |
| attributes            | components                  | [object]        | Components displayed on the status page.                                                                                                                |
| components            | components                  | [object]        | If the component is of type `group`, the components within the group.                                                                                   |
| components            | id                          | uuid            | The ID of the grouped component.                                                                                                                        |
| components            | name                        | string          | The name of the grouped component.                                                                                                                      |
| components            | position                    | int64           | The zero-indexed position of the grouped component. Relative to the other components in the group.                                                      |
| components            | status                      | enum            | The status of the component. Allowed enum values: `operational,degraded,partial_outage,major_outage,maintenance`                                        |
| components            | type                        | enum            | The type of the component. Allowed enum values: `component`                                                                                             |
| components            | id                          | uuid            | The ID of the component.                                                                                                                                |
| components            | name                        | string          | The name of the component.                                                                                                                              |
| components            | position                    | int64           | The zero-indexed position of the component.                                                                                                             |
| components            | status                      | enum            | The status of the component. Allowed enum values: `operational,degraded,partial_outage,major_outage,maintenance`                                        |
| components            | type                        | enum            | The type of the component. Allowed enum values: `component,group`                                                                                       |
| attributes            | created_at                  | date-time       | Timestamp of when the status page was created.                                                                                                          |
| attributes            | custom_domain               | string          | If configured, the url that the status page is accessible at.                                                                                           |
| attributes            | custom_domain_enabled       | boolean         | Whether the custom domain is configured.                                                                                                                |
| attributes            | domain_prefix               | string          | The subdomain of the status page's url taking the form `https://{domain_prefix}.statuspage.datadoghq.com`. Globally unique across Datadog Status Pages. |
| attributes            | email_header_image          | string          | Base64-encoded image data included in email notifications sent to status page subscribers.                                                              |
| attributes            | enabled                     | boolean         | Whether the status page is enabled.                                                                                                                     |
| attributes            | favicon                     | string          | Base64-encoded image data displayed in the browser tab.                                                                                                 |
| attributes            | modified_at                 | date-time       | Timestamp of when the status page was last modified.                                                                                                    |
| attributes            | name                        | string          | The name of the status page.                                                                                                                            |
| attributes            | page_url                    | string          | The url that the status page is accessible at.                                                                                                          |
| attributes            | slack_app_icon              | string          | The Slack app icon URL for the status page.                                                                                                             |
| attributes            | slack_subscriptions_enabled | boolean         | Whether Slack subscriptions are enabled for the status page.                                                                                            |
| attributes            | subscriptions_enabled       | boolean         | Whether users can subscribe to the status page.                                                                                                         |
| attributes            | type                        | enum            | The type of the status page controlling how the status page is accessed. Allowed enum values: `public,internal`                                         |
| attributes            | visualization_type          | enum            | The visualization type of the status page. Allowed enum values: `bars_and_uptime_percentage,bars_only,component_name_only`                              |
| Option 2              | id                          | uuid            | The ID of the status page.                                                                                                                              |
| Option 2              | relationships               | object          | The relationships of a status page.                                                                                                                     |
| relationships         | created_by_user             | object          | The Datadog user who created the status page.                                                                                                           |
| created_by_user       | data [*required*]      | object          | The data object identifying the Datadog user who created the status page.                                                                               |
| data                  | id [*required*]        | string          | The ID of the Datadog user who created the status page.                                                                                                 |
| data                  | type [*required*]      | enum            | Users resource type. Allowed enum values: `users`                                                                                                       |
| relationships         | last_modified_by_user       | object          | The Datadog user who last modified the status page.                                                                                                     |
| last_modified_by_user | data [*required*]      | object          | The data object identifying the Datadog user who last modified the status page.                                                                         |
| data                  | id [*required*]        | string          | The ID of the Datadog user who last modified the status page.                                                                                           |
| data                  | type [*required*]      | enum            | Users resource type. Allowed enum values: `users`                                                                                                       |
| Option 2              | type [*required*]      | enum            | Status pages resource type. Allowed enum values: `status_pages`                                                                                         |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "completed_date": "2019-09-19T10:00:00.000Z",
      "completed_description": "string",
      "components_affected": [
        {
          "id": "1234abcd-12ab-34cd-56ef-123456abcdef",
          "name": "string",
          "status": "operational"
        }
      ],
      "in_progress_description": "string",
      "is_backfilled": false,
      "modified_at": "2019-09-19T10:00:00.000Z",
      "published_date": "2019-09-19T10:00:00.000Z",
      "scheduled_description": "string",
      "start_date": "2019-09-19T10:00:00.000Z",
      "status": "string",
      "title": "string",
      "updates": [
        {
          "components_affected": [
            {
              "id": "1234abcd-12ab-34cd-56ef-123456abcdef",
              "name": "string",
              "status": "operational"
            }
          ],
          "created_at": "2019-09-19T10:00:00.000Z",
          "description": "string",
          "id": "string",
          "manual_transition": false,
          "modified_at": "2019-09-19T10:00:00.000Z",
          "started_at": "2019-09-19T10:00:00.000Z",
          "status": "string"
        }
      ]
    },
    "id": "string",
    "relationships": {
      "created_by_user": {
        "data": {
          "id": "",
          "type": "users"
        }
      },
      "last_modified_by_user": {
        "data": {
          "id": "",
          "type": "users"
        }
      },
      "status_page": {
        "data": {
          "id": "",
          "type": "status_pages"
        }
      }
    },
    "type": "maintenances"
  },
  "included": [
    {
      "attributes": {
        "email": "string",
        "handle": "string",
        "icon": "string",
        "name": "string",
        "uuid": "string"
      },
      "id": "string",
      "type": "users"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                          \## default
# 
 \# Path parameters export page_id="CHANGE_ME" \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/statuspages/${page_id}/maintenances" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "completed_date": "2026-02-18T19:51:13.332360075Z",
      "completed_description": "We have completed maintenance on the API to improve performance.",
      "components_affected": [
        {
          "id": "1234abcd-12ab-34cd-56ef-123456abcdef",
          "status": "operational"
        }
      ],
      "in_progress_description": "We are currently performing maintenance on the API to improve performance.",
      "scheduled_description": "We will be performing maintenance on the API to improve performance.",
      "start_date": "2026-02-18T19:21:13.332360075Z",
      "title": "API Maintenance"
    },
    "type": "maintenances"
  }
}
EOF 
                        
##### 

```go
// Create maintenance returns "Created" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"
	"time"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
	"github.com/google/uuid"
)

func main() {
	// there is a valid "status_page" in the system
	StatusPageDataAttributesComponents0Components0ID := uuid.MustParse(os.Getenv("STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID"))
	StatusPageDataID := uuid.MustParse(os.Getenv("STATUS_PAGE_DATA_ID"))

	body := datadogV2.CreateMaintenanceRequest{
		Data: &datadogV2.CreateMaintenanceRequestData{
			Attributes: datadogV2.CreateMaintenanceRequestDataAttributes{
				Title:                 "API Maintenance",
				ScheduledDescription:  "We will be performing maintenance on the API to improve performance.",
				InProgressDescription: "We are currently performing maintenance on the API to improve performance.",
				CompletedDescription:  "We have completed maintenance on the API to improve performance.",
				StartDate:             time.Now().Add(time.Hour * 1),
				CompletedDate:         time.Now().Add(time.Hour * 2),
				ComponentsAffected: []datadogV2.CreateMaintenanceRequestDataAttributesComponentsAffectedItems{
					{
						Id:     StatusPageDataAttributesComponents0Components0ID,
						Status: datadogV2.PATCHMAINTENANCEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_OPERATIONAL,
					},
				},
			},
			Type: datadogV2.PATCHMAINTENANCEREQUESTDATATYPE_MAINTENANCES,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewStatusPagesApi(apiClient)
	resp, r, err := api.CreateMaintenance(ctx, StatusPageDataID, body, *datadogV2.NewCreateMaintenanceOptionalParameters())

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.CreateMaintenance`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.CreateMaintenance`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Create maintenance returns "Created" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.StatusPagesApi;
import com.datadog.api.client.v2.model.CreateMaintenanceRequest;
import com.datadog.api.client.v2.model.CreateMaintenanceRequestData;
import com.datadog.api.client.v2.model.CreateMaintenanceRequestDataAttributes;
import com.datadog.api.client.v2.model.CreateMaintenanceRequestDataAttributesComponentsAffectedItems;
import com.datadog.api.client.v2.model.Maintenance;
import com.datadog.api.client.v2.model.PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus;
import com.datadog.api.client.v2.model.PatchMaintenanceRequestDataType;
import java.time.OffsetDateTime;
import java.util.Collections;
import java.util.UUID;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    StatusPagesApi apiInstance = new StatusPagesApi(defaultClient);

    // there is a valid "status_page" in the system
    UUID STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID = null;
    try {
      STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID =
          UUID.fromString(
              System.getenv("STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID"));
    } catch (IllegalArgumentException e) {
      System.err.println("Error parsing UUID: " + e.getMessage());
    }
    UUID STATUS_PAGE_DATA_ID = null;
    try {
      STATUS_PAGE_DATA_ID = UUID.fromString(System.getenv("STATUS_PAGE_DATA_ID"));
    } catch (IllegalArgumentException e) {
      System.err.println("Error parsing UUID: " + e.getMessage());
    }

    CreateMaintenanceRequest body =
        new CreateMaintenanceRequest()
            .data(
                new CreateMaintenanceRequestData()
                    .attributes(
                        new CreateMaintenanceRequestDataAttributes()
                            .title("API Maintenance")
                            .scheduledDescription(
                                "We will be performing maintenance on the API to improve"
                                    + " performance.")
                            .inProgressDescription(
                                "We are currently performing maintenance on the API to improve"
                                    + " performance.")
                            .completedDescription(
                                "We have completed maintenance on the API to improve performance.")
                            .startDate(OffsetDateTime.now().plusHours(1))
                            .completedDate(OffsetDateTime.now().plusHours(2))
                            .componentsAffected(
                                Collections.singletonList(
                                    new CreateMaintenanceRequestDataAttributesComponentsAffectedItems()
                                        .id(
                                            STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID)
                                        .status(
                                            PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus
                                                .OPERATIONAL))))
                    .type(PatchMaintenanceRequestDataType.MAINTENANCES));

    try {
      Maintenance result = apiInstance.createMaintenance(STATUS_PAGE_DATA_ID, body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling StatusPagesApi#createMaintenance");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```python
"""
Create maintenance returns "Created" response
"""

from datetime import datetime
from dateutil.relativedelta import relativedelta
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.status_pages_api import StatusPagesApi
from datadog_api_client.v2.model.create_maintenance_request import CreateMaintenanceRequest
from datadog_api_client.v2.model.create_maintenance_request_data import CreateMaintenanceRequestData
from datadog_api_client.v2.model.create_maintenance_request_data_attributes import (
    CreateMaintenanceRequestDataAttributes,
)
from datadog_api_client.v2.model.create_maintenance_request_data_attributes_components_affected_items import (
    CreateMaintenanceRequestDataAttributesComponentsAffectedItems,
)
from datadog_api_client.v2.model.patch_maintenance_request_data_attributes_components_affected_items_status import (
    PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus,
)
from datadog_api_client.v2.model.patch_maintenance_request_data_type import PatchMaintenanceRequestDataType

# there is a valid "status_page" in the system
STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID = environ[
    "STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID"
]
STATUS_PAGE_DATA_ID = environ["STATUS_PAGE_DATA_ID"]

body = CreateMaintenanceRequest(
    data=CreateMaintenanceRequestData(
        attributes=CreateMaintenanceRequestDataAttributes(
            title="API Maintenance",
            scheduled_description="We will be performing maintenance on the API to improve performance.",
            in_progress_description="We are currently performing maintenance on the API to improve performance.",
            completed_description="We have completed maintenance on the API to improve performance.",
            start_date=(datetime.now() + relativedelta(hours=1)),
            completed_date=(datetime.now() + relativedelta(hours=2)),
            components_affected=[
                CreateMaintenanceRequestDataAttributesComponentsAffectedItems(
                    id=STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID,
                    status=PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus.OPERATIONAL,
                ),
            ],
        ),
        type=PatchMaintenanceRequestDataType.MAINTENANCES,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = StatusPagesApi(api_client)
    response = api_instance.create_maintenance(page_id=STATUS_PAGE_DATA_ID, body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Create maintenance returns "Created" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::StatusPagesAPI.new

# there is a valid "status_page" in the system
STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID = ENV["STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID"]
STATUS_PAGE_DATA_ID = ENV["STATUS_PAGE_DATA_ID"]

body = DatadogAPIClient::V2::CreateMaintenanceRequest.new({
  data: DatadogAPIClient::V2::CreateMaintenanceRequestData.new({
    attributes: DatadogAPIClient::V2::CreateMaintenanceRequestDataAttributes.new({
      title: "API Maintenance",
      scheduled_description: "We will be performing maintenance on the API to improve performance.",
      in_progress_description: "We are currently performing maintenance on the API to improve performance.",
      completed_description: "We have completed maintenance on the API to improve performance.",
      start_date: (Time.now + 1 * 3600),
      completed_date: (Time.now + 2 * 3600),
      components_affected: [
        DatadogAPIClient::V2::CreateMaintenanceRequestDataAttributesComponentsAffectedItems.new({
          id: STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID,
          status: DatadogAPIClient::V2::PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus::OPERATIONAL,
        }),
      ],
    }),
    type: DatadogAPIClient::V2::PatchMaintenanceRequestDataType::MAINTENANCES,
  }),
})
p api_instance.create_maintenance(STATUS_PAGE_DATA_ID, body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```rust
// Create maintenance returns "Created" response
use chrono::{DateTime, Utc};
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_status_pages::CreateMaintenanceOptionalParams;
use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI;
use datadog_api_client::datadogV2::model::CreateMaintenanceRequest;
use datadog_api_client::datadogV2::model::CreateMaintenanceRequestData;
use datadog_api_client::datadogV2::model::CreateMaintenanceRequestDataAttributes;
use datadog_api_client::datadogV2::model::CreateMaintenanceRequestDataAttributesComponentsAffectedItems;
use datadog_api_client::datadogV2::model::PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus;
use datadog_api_client::datadogV2::model::PatchMaintenanceRequestDataType;

#[tokio::main]
async fn main() {
    // there is a valid "status_page" in the system
    let status_page_data_attributes_components_0_components_0_id = uuid::Uuid::parse_str(
        &std::env::var("STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID").unwrap(),
    )
    .expect("Invalid UUID");
    let status_page_data_id = uuid::Uuid::parse_str(&std::env::var("STATUS_PAGE_DATA_ID").unwrap())
        .expect("Invalid UUID");
    let body = CreateMaintenanceRequest::new().data(CreateMaintenanceRequestData::new(
        CreateMaintenanceRequestDataAttributes::new(
            DateTime::parse_from_rfc3339("2021-11-11T13:11:11+00:00")
                .expect("Failed to parse datetime")
                .with_timezone(&Utc),
            "We have completed maintenance on the API to improve performance.".to_string(),
            vec![
                CreateMaintenanceRequestDataAttributesComponentsAffectedItems::new(
                    status_page_data_attributes_components_0_components_0_id.clone(),
                    PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus::OPERATIONAL,
                ),
            ],
            "We are currently performing maintenance on the API to improve performance."
                .to_string(),
            "We will be performing maintenance on the API to improve performance.".to_string(),
            DateTime::parse_from_rfc3339("2021-11-11T12:11:11+00:00")
                .expect("Failed to parse datetime")
                .with_timezone(&Utc),
            "API Maintenance".to_string(),
        ),
        PatchMaintenanceRequestDataType::MAINTENANCES,
    ));
    let configuration = datadog::Configuration::new();
    let api = StatusPagesAPI::with_config(configuration);
    let resp = api
        .create_maintenance(
            status_page_data_id.clone(),
            body,
            CreateMaintenanceOptionalParams::default(),
        )
        .await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Create maintenance returns "Created" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
const apiInstance = new v2.StatusPagesApi(configuration);

// there is a valid "status_page" in the system
const STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID = process.env
  .STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID as string;
const STATUS_PAGE_DATA_ID = process.env.STATUS_PAGE_DATA_ID as string;

const params: v2.StatusPagesApiCreateMaintenanceRequest = {
  body: {
    data: {
      attributes: {
        title: "API Maintenance",
        scheduledDescription:
          "We will be performing maintenance on the API to improve performance.",
        inProgressDescription:
          "We are currently performing maintenance on the API to improve performance.",
        completedDescription:
          "We have completed maintenance on the API to improve performance.",
        startDate: new Date(new Date().getTime() + 1 * 3600 * 1000),
        completedDate: new Date(new Date().getTime() + 2 * 3600 * 1000),
        componentsAffected: [
          {
            id: STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID,
            status: "operational",
          },
        ],
      },
      type: "maintenances",
    },
  },
  pageId: STATUS_PAGE_DATA_ID,
};

apiInstance
  .createMaintenance(params)
  .then((data: v2.Maintenance) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
