Create a maintenance window
https://api.datadoghq.com/api/v2/maintenance_windowshttps://api.us3.datadoghq.com/api/v2/maintenance_windowshttps://api.us5.datadoghq.com/api/v2/maintenance_windowshttps://api.datadoghq.eu/api/v2/maintenance_windowshttps://api.ap1.datadoghq.com/api/v2/maintenance_windowshttps://api.ap2.datadoghq.com/api/v2/maintenance_windowshttps://api.uk1.datadoghq.com/api/v2/maintenance_windowshttps://api.ddog-gov.com/api/v2/maintenance_windowshttps://api.us2.ddog-gov.com/api/v2/maintenance_windowsPrésentation
Creates a maintenance window for event management work items with a name, work item filter query, and time range (start and end).
OAuth apps require the event_correlation_config_write authorization scope to access this endpoint.
Requête
Body Data (required)
Maintenance window payload.
data [required]Data object for creating a maintenance window.
attributes [required]Attributes required to create a maintenance window.
end_at [required]The end time of the maintenance window.
name [required]The name of the maintenance window.
query [required]The query to filter event management work items for this maintenance window.
start_at [required]The start time of the maintenance window.
type [required]JSON:API resource type for maintenance windows.
maintenance_windowmaintenance_window{
"data": {
"attributes": {
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z"
},
"type": "maintenance_window"
}
}Réponse
Created
Response containing a single maintenance window.
data [required]A maintenance window that defines a scheduled time period during which notifications and automation rules related to work items are suppressed. Each maintenance window applies to work items matching a specified query.
attributes [required]Attributes of a maintenance window, including its schedule and the query that determines which work items are affected.
created_byThe UUID of the user who created this maintenance window. Read-only.
end_at [required]The ISO 8601 timestamp when the maintenance window ends and normal notification behavior resumes.
name [required]A human-readable name for the maintenance window (for example, Database migration - Dec 15).
query [required]A work item search query that determines which work items are affected during the maintenance window. Uses the same syntax as the Work Management search bar.
start_at [required]The ISO 8601 timestamp when the maintenance window begins and notifications start being suppressed.
updated_byThe UUID of the user who last modified this maintenance window. Read-only.
id [required]The maintenance window's identifier.
type [required]JSON:API resource type for maintenance windows.
maintenance_windowmaintenance_window{
"data": {
"attributes": {
"created_by": "string",
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z",
"updated_by": "string"
},
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"type": "maintenance_window"
}
}Bad Request
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Unauthorized
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Forbidden
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Not Found
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Exemple de code
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/maintenance_windows" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z"
},
"type": "maintenance_window"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/maintenance_windows" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z"
},
"type": "maintenance_window"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/maintenance_windows" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z"
},
"type": "maintenance_window"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/maintenance_windows" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z"
},
"type": "maintenance_window"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/maintenance_windows" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z"
},
"type": "maintenance_window"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/maintenance_windows" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z"
},
"type": "maintenance_window"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/maintenance_windows" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z"
},
"type": "maintenance_window"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/maintenance_windows" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z"
},
"type": "maintenance_window"
}
}
EOF# Set your Datadog site and credentials
export DD_SITE="us2.ddog-gov.com"
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"
curl -X POST "https://api.${DD_SITE}/api/v2/maintenance_windows" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
"data": {
"attributes": {
"end_at": "2026-06-01T06:00:00Z",
"name": "Weekly maintenance",
"query": "project:SEC",
"start_at": "2026-06-01T00:00:00Z"
},
"type": "maintenance_window"
}
}
EOF// Create a maintenance window 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"
)
func main() {
body := datadogV2.MaintenanceWindowCreateRequest{
Data: datadogV2.MaintenanceWindowCreate{
Attributes: datadogV2.MaintenanceWindowCreateAttributes{
EndAt: time.Date(2026, 6, 1, 6, 0, 0, 0, time.UTC),
Name: "Weekly maintenance",
Query: "project:SEC",
StartAt: time.Date(2026, 6, 1, 0, 0, 0, 0, time.UTC),
},
Type: datadogV2.MAINTENANCEWINDOWRESOURCETYPE_MAINTENANCE_WINDOW,
},
}
ctx := datadog.NewDefaultContext(context.Background())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
configuration := datadog.NewConfiguration()
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewCaseManagementApi(apiClient)
resp, r, err := api.CreateMaintenanceWindow(ctx, body)
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `CaseManagementApi.CreateMaintenanceWindow`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `CaseManagementApi.CreateMaintenanceWindow`:\n%s\n", responseContent)
}
Instructions
First install the library and its dependencies and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// Create a maintenance window returns "Created" response
import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.CaseManagementApi;
import com.datadog.api.client.v2.model.MaintenanceWindowCreate;
import com.datadog.api.client.v2.model.MaintenanceWindowCreateAttributes;
import com.datadog.api.client.v2.model.MaintenanceWindowCreateRequest;
import com.datadog.api.client.v2.model.MaintenanceWindowResourceType;
import com.datadog.api.client.v2.model.MaintenanceWindowResponse;
import java.time.OffsetDateTime;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
CaseManagementApi apiInstance = new CaseManagementApi(defaultClient);
MaintenanceWindowCreateRequest body =
new MaintenanceWindowCreateRequest()
.data(
new MaintenanceWindowCreate()
.attributes(
new MaintenanceWindowCreateAttributes()
.endAt(OffsetDateTime.parse("2026-06-01T06:00:00Z"))
.name("Weekly maintenance")
.query("project:SEC")
.startAt(OffsetDateTime.parse("2026-06-01T00:00:00Z")))
.type(MaintenanceWindowResourceType.MAINTENANCE_WINDOW));
try {
MaintenanceWindowResponse result = apiInstance.createMaintenanceWindow(body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling CaseManagementApi#createMaintenanceWindow");
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 and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create a maintenance window returns "Created" response
"""
from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.case_management_api import CaseManagementApi
from datadog_api_client.v2.model.maintenance_window_create import MaintenanceWindowCreate
from datadog_api_client.v2.model.maintenance_window_create_attributes import MaintenanceWindowCreateAttributes
from datadog_api_client.v2.model.maintenance_window_create_request import MaintenanceWindowCreateRequest
from datadog_api_client.v2.model.maintenance_window_resource_type import MaintenanceWindowResourceType
from datetime import datetime
from dateutil.tz import tzutc
body = MaintenanceWindowCreateRequest(
data=MaintenanceWindowCreate(
attributes=MaintenanceWindowCreateAttributes(
end_at=datetime(2026, 6, 1, 6, 0, tzinfo=tzutc()),
name="Weekly maintenance",
query="project:SEC",
start_at=datetime(2026, 6, 1, 0, 0, tzinfo=tzutc()),
),
type=MaintenanceWindowResourceType.MAINTENANCE_WINDOW,
),
)
configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
api_instance = CaseManagementApi(api_client)
response = api_instance.create_maintenance_window(body=body)
print(response)
Instructions
First install the library and its dependencies and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create a maintenance window returns "Created" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::CaseManagementAPI.new
body = DatadogAPIClient::V2::MaintenanceWindowCreateRequest.new({
data: DatadogAPIClient::V2::MaintenanceWindowCreate.new({
attributes: DatadogAPIClient::V2::MaintenanceWindowCreateAttributes.new({
end_at: "2026-06-01T06:00:00Z",
name: "Weekly maintenance",
query: "project:SEC",
start_at: "2026-06-01T00:00:00Z",
}),
type: DatadogAPIClient::V2::MaintenanceWindowResourceType::MAINTENANCE_WINDOW,
}),
})
p api_instance.create_maintenance_window(body)
Instructions
First install the library and its dependencies and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// Create a maintenance window returns "Created" response
use chrono::{DateTime, Utc};
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_case_management::CaseManagementAPI;
use datadog_api_client::datadogV2::model::MaintenanceWindowCreate;
use datadog_api_client::datadogV2::model::MaintenanceWindowCreateAttributes;
use datadog_api_client::datadogV2::model::MaintenanceWindowCreateRequest;
use datadog_api_client::datadogV2::model::MaintenanceWindowResourceType;
#[tokio::main]
async fn main() {
let body = MaintenanceWindowCreateRequest::new(MaintenanceWindowCreate::new(
MaintenanceWindowCreateAttributes::new(
DateTime::parse_from_rfc3339("2026-06-01T06:00:00+00:00")
.expect("Failed to parse datetime")
.with_timezone(&Utc),
"Weekly maintenance".to_string(),
"project:SEC".to_string(),
DateTime::parse_from_rfc3339("2026-06-01T00:00:00+00:00")
.expect("Failed to parse datetime")
.with_timezone(&Utc),
),
MaintenanceWindowResourceType::MAINTENANCE_WINDOW,
));
let configuration = datadog::Configuration::new();
let api = CaseManagementAPI::with_config(configuration);
let resp = api.create_maintenance_window(body).await;
if let Ok(value) = resp {
println!("{:#?}", value);
} else {
println!("{:#?}", resp.unwrap_err());
}
}
Instructions
First install the library and its dependencies 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 runDD_SITE="us3.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run/**
* Create a maintenance window returns "Created" response
*/
import { client, v2 } from "@datadog/datadog-api-client";
const configuration = client.createConfiguration({
authMethods: {
AuthZ: {
accessToken: process.env.DD_BEARER_TOKEN as string,
},
},
});
const apiInstance = new v2.CaseManagementApi(configuration);
const params: v2.CaseManagementApiCreateMaintenanceWindowRequest = {
body: {
data: {
attributes: {
endAt: new Date(2026, 6, 1, 6, 0, 0, 0),
name: "Weekly maintenance",
query: "project:SEC",
startAt: new Date(2026, 6, 1, 0, 0, 0, 0),
},
type: "maintenance_window",
},
},
};
apiInstance
.createMaintenanceWindow(params)
.then((data: v2.MaintenanceWindowResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
Instructions
First install the library and its dependencies and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"