# Schedule a maintenance window

`POST https://evohub.io/api/v1/maintenance-windows`

Part of the [On-Call API](https://docs-dev.evohub.io/oncall.md) reference · operationId `createMaintenanceWindow`.

Schedules a maintenance window of at most 30 days. While it runs, alerts are
still recorded but nobody is paged, unless `silence_oncall` is `false`.

Optionally it also fans out: `status_page_id` publishes a scheduled
maintenance (with `affected_component_ids` and `message`) on that status page,
and `uptime_monitor_ids` silences those uptime monitors for the window.
Deleting the window undoes both.

**Permission (API-key scope):** `oncall:maintenance:write`.

## Authorization

Any one of:

- `bearerAuth` (oncall:maintenance:write)
- `apiKeyHeader` (oncall:maintenance:write)

Where:

- `bearerAuth`: HTTP Bearer — An EvoHub API key (`evohub_…`) as a bearer token.
- `apiKeyHeader`: API key in the header `X-API-Key` — An EvoHub API key (`evohub_…`).

## Request body (required)

Content type: `application/json`

Type: `MaintenanceWindowCreate`

- `title` (string, required)
- `starts_at` (string (date-time), required)
- `ends_at` (string (date-time), required): After `starts_at`, at most 30 days later.
- `silence_oncall` (boolean, default `true`)
- `status_page_id` (string): Also publish a scheduled maintenance on this status page.
- `affected_component_ids` (array of string)
- `message` (string): The status-page maintenance text.
- `uptime_monitor_ids` (array of string)

## Responses

### 201 — The window.

Content type: `application/json`

Type: `object`

- `data` (MaintenanceWindow, required)
  - `id` (string)
  - `org_id` (string)
  - `title` (string)
  - `body` (string): What the maintenance does.
  - `starts_at` (string (date-time))
  - `ends_at` (string (date-time))
  - `created_by` (string)
  - `created_at` (string (date-time))
  - `ended_at` (string (date-time)): Set when the window was ended early.
  - `silence_oncall` (boolean): Whether paging is held back during the window.
- `success` (boolean, required, value `true`)

### 400 — The body is not JSON (`INVALID_BODY`); `title`, `starts_at` or `ends_at` is missing (`VALIDATION_FAILED`); or the window ends before it starts or is longer than 30 days (`INVALID_WINDOW`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required): Machine-readable code. Branch on this.
  - `message` (string, required): Human-readable explanation.

### 401 — No API key was sent, or it is unknown, revoked or expired (`UNAUTHORIZED`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required): Machine-readable code. Branch on this.
  - `message` (string, required): Human-readable explanation.

### 403 — The key lacks the scope this endpoint needs (`FORBIDDEN`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required): Machine-readable code. Branch on this.
  - `message` (string, required): Human-readable explanation.

### 429 — Too many requests (`RATE_LIMITED`). Wait `Retry-After` seconds.

Headers:

- `Retry-After` (integer): Seconds to wait.

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required): Machine-readable code. Branch on this.
  - `message` (string, required): Human-readable explanation.

### 500 — Something went wrong on EvoHub's side (`INTERNAL_ERROR`). Retry later.

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required): Machine-readable code. Branch on this.
  - `message` (string, required): Human-readable explanation.

## Example request

```bash
curl -X POST 'https://evohub.io/api/v1/maintenance-windows' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <TOKEN>' \
  -d '{
  "title": "Database upgrade",
  "ends_at": "2026-10-13T00:00:00Z",
  "message": "Expect a few minutes of read-only mode.",
  "starts_at": "2026-10-12T22:00:00Z",
  "status_page_id": "page_1f2e3d4c",
  "uptime_monitor_ids": [
    "mon_7a8b9c"
  ],
  "affected_component_ids": [
    "comp_api"
  ]
}'
```
