For AI agents: A markdown version of this page is available at https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/ja/api/latest/fleet-automation/create-a-schedule.md. A documentation index is available at /llms.txt.
Language
Datadog site

Create a schedule

警告This endpoint is in Preview and may introduce breaking changes. If you have any feedback, contact Datadog support.
POSThttps://api.datadoghq.com/api/unstable/fleet/scheduleshttps://api.us3.datadoghq.com/api/unstable/fleet/scheduleshttps://api.us5.datadoghq.com/api/unstable/fleet/scheduleshttps://api.datadoghq.eu/api/unstable/fleet/scheduleshttps://api.ap1.datadoghq.com/api/unstable/fleet/scheduleshttps://api.ap2.datadoghq.com/api/unstable/fleet/scheduleshttps://api.uk1.datadoghq.com/api/unstable/fleet/scheduleshttps://api.ddog-gov.com/api/unstable/fleet/scheduleshttps://api.us2.ddog-gov.com/api/unstable/fleet/schedules

概要

Create a new schedule for automated package upgrades.

Schedules define when and how often to automatically deploy package upgrades to a fleet of hosts. Each schedule includes:

  • A filter query to select target hosts
  • A recurrence rule defining maintenance windows
  • A version strategy (e.g., always latest, or N versions behind latest)

When the schedule triggers during a maintenance window, it automatically creates a deployment that upgrades the Datadog Agent to the specified version on all matching hosts.

This endpoint requires the agent_upgrade_write permission.

リクエスト

Body Data (required)

Request payload containing the schedule details.

フィールド
タイプ
説明
data [required]
object

Data for creating a new schedule.

応答

CREATED

Response containing a single schedule.

フィールド
タイプ
説明
data
object

A schedule that automatically creates deployments based on a recurrence rule.

コード例

Create a schedule
## Conservative staging updates (N-1 version)

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Staging Environment - Conservative Updates",
      "query": "env:staging",
      "rule": {
        "days_of_week": [
          "Fri"
        ],
        "maintenance_window_duration": 240,
        "start_maintenance_window": "22:00",
        "timezone": "UTC"
      },
      "status": "active",
      "version_to_latest": 1
    },
    "type": "schedule"
  }
}
EOF

## default

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF

## Weekly production agent updates

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF
## Conservative staging updates (N-1 version)

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Staging Environment - Conservative Updates",
      "query": "env:staging",
      "rule": {
        "days_of_week": [
          "Fri"
        ],
        "maintenance_window_duration": 240,
        "start_maintenance_window": "22:00",
        "timezone": "UTC"
      },
      "status": "active",
      "version_to_latest": 1
    },
    "type": "schedule"
  }
}
EOF

## default

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF

## Weekly production agent updates

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF
## Conservative staging updates (N-1 version)

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Staging Environment - Conservative Updates",
      "query": "env:staging",
      "rule": {
        "days_of_week": [
          "Fri"
        ],
        "maintenance_window_duration": 240,
        "start_maintenance_window": "22:00",
        "timezone": "UTC"
      },
      "status": "active",
      "version_to_latest": 1
    },
    "type": "schedule"
  }
}
EOF

## default

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF

## Weekly production agent updates

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF
## Conservative staging updates (N-1 version)

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Staging Environment - Conservative Updates",
      "query": "env:staging",
      "rule": {
        "days_of_week": [
          "Fri"
        ],
        "maintenance_window_duration": 240,
        "start_maintenance_window": "22:00",
        "timezone": "UTC"
      },
      "status": "active",
      "version_to_latest": 1
    },
    "type": "schedule"
  }
}
EOF

## default

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF

## Weekly production agent updates

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF
## Conservative staging updates (N-1 version)

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Staging Environment - Conservative Updates",
      "query": "env:staging",
      "rule": {
        "days_of_week": [
          "Fri"
        ],
        "maintenance_window_duration": 240,
        "start_maintenance_window": "22:00",
        "timezone": "UTC"
      },
      "status": "active",
      "version_to_latest": 1
    },
    "type": "schedule"
  }
}
EOF

## default

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF

## Weekly production agent updates

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF
## Conservative staging updates (N-1 version)

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Staging Environment - Conservative Updates",
      "query": "env:staging",
      "rule": {
        "days_of_week": [
          "Fri"
        ],
        "maintenance_window_duration": 240,
        "start_maintenance_window": "22:00",
        "timezone": "UTC"
      },
      "status": "active",
      "version_to_latest": 1
    },
    "type": "schedule"
  }
}
EOF

## default

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF

## Weekly production agent updates

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF
## Conservative staging updates (N-1 version)

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Staging Environment - Conservative Updates",
      "query": "env:staging",
      "rule": {
        "days_of_week": [
          "Fri"
        ],
        "maintenance_window_duration": 240,
        "start_maintenance_window": "22:00",
        "timezone": "UTC"
      },
      "status": "active",
      "version_to_latest": 1
    },
    "type": "schedule"
  }
}
EOF

## default

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF

## Weekly production agent updates

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF
## Conservative staging updates (N-1 version)

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Staging Environment - Conservative Updates",
      "query": "env:staging",
      "rule": {
        "days_of_week": [
          "Fri"
        ],
        "maintenance_window_duration": 240,
        "start_maintenance_window": "22:00",
        "timezone": "UTC"
      },
      "status": "active",
      "version_to_latest": 1
    },
    "type": "schedule"
  }
}
EOF

## default

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF

## Weekly production agent updates

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF
## Conservative staging updates (N-1 version)

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Staging Environment - Conservative Updates",
      "query": "env:staging",
      "rule": {
        "days_of_week": [
          "Fri"
        ],
        "maintenance_window_duration": 240,
        "start_maintenance_window": "22:00",
        "timezone": "UTC"
      },
      "status": "active",
      "version_to_latest": 1
    },
    "type": "schedule"
  }
}
EOF

## default

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF

## Weekly production agent updates

# 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/unstable/fleet/schedules" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "name": "Weekly Production Agent Updates",
      "query": "env:prod",
      "rule": {
        "days_of_week": [
          "Mon",
          "Wed"
        ],
        "maintenance_window_duration": 180,
        "start_maintenance_window": "02:00",
        "timezone": "America/New_York"
      },
      "status": "active",
      "version_to_latest": 0
    },
    "type": "schedule"
  }
}
EOF