# Edit maintenance

`PATCH https://evohub.io/api/v1/pages/{pageID}/maintenances/{id}`

Part of the [Status API](https://docs-dev.evohub.io/status.md) reference · operationId `updateMaintenance`.

Edits the window; a field left out (or empty) keeps its value, so `body` cannot
be cleared here. Moving it to `completed` also closes the timeline with "This
maintenance has been completed.", once. Nobody is mailed.

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

## Authorization

Any one of:

- `bearerAuth` (status:maintenance:write)
- `apiKeyHeader` (status: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_…`).

## Path parameters

- `pageID` (string (uuid), required, example `3f6c2a1e-8b4d-4f7a-9c21-5d0e7a9b1c42`): The status page's id (a UUID).
- `id` (string (uuid), required): The incident's, maintenance window's or subscriber's id (a UUID).

## Request body (required)

Content type: `application/json`

Type: `MaintenanceWrite`

- `title` (string)
- `body` (string)
- `status` (MaintenanceStatus, one of `scheduled`, `in_progress`, `completed`)
- `scheduled_start` (string (date-time))
- `scheduled_end` (string (date-time))
- `affected_component_ids` (array of string (uuid)): Create only; ignored on update. Components of this page; any other id is skipped.
- `managed_in` (ManagedIn, one of `oncall`, `status_page`): Create only; ignored on update.

## Responses

### 200 — The window.

Content type: `application/json`

Type: `object`

- `data` (Maintenance, required)
  - `id` (string (uuid), required)
  - `org_id` (string, required)
  - `page_id` (string (uuid), required)
  - `title` (string, required)
  - `body` (string, required)
  - `status` (MaintenanceStatus, required, one of `scheduled`, `in_progress`, `completed`)
  - `scheduled_start` (string (date-time), required)
  - `scheduled_end` (string (date-time), required)
  - `created_at` (string (date-time), required)
  - `updated_at` (string (date-time), required)
  - `managed_in` (ManagedIn, required, one of `oncall`, `status_page`)
  - `affected_component_ids` (array of string (uuid), required)
  - `updates` (array of MaintenanceUpdate, required)
    - `id` (string (uuid))
    - `maintenance_id` (string (uuid))
    - `status` (MaintenanceStatus, one of `scheduled`, `in_progress`, `completed`)
    - `body` (string)
    - `created_at` (string (date-time))
- `success` (boolean, required, value `true`)

### 400 — A field is missing or invalid (`VALIDATION_ERROR`); the message names it, or the body is not valid (`INVALID_BODY`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required): Machine-readable code. Branch on this.
  - `message` (string, required): Human-readable explanation.
  - `request_id` (string): This request's id, also in `X-Request-ID`.

### 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.
  - `request_id` (string): This request's id, also in `X-Request-ID`.

### 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.
  - `request_id` (string): This request's id, also in `X-Request-ID`.

### 404 — No such page or maintenance window, or one on another page (`NOT_FOUND`).

Content type: `application/json`

Type: `Error`

- `error` (object, required)
  - `code` (string, required): Machine-readable code. Branch on this.
  - `message` (string, required): Human-readable explanation.
  - `request_id` (string): This request's id, also in `X-Request-ID`.

### 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.
  - `request_id` (string): This request's id, also in `X-Request-ID`.

### 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.
  - `request_id` (string): This request's id, also in `X-Request-ID`.

## Example request

```bash
curl -X PATCH 'https://evohub.io/api/v1/pages/3f6c2a1e-8b4d-4f7a-9c21-5d0e7a9b1c42/maintenances/00000000-0000-0000-0000-000000000000' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer <TOKEN>' \
  -d '{
  "status": "completed"
}'
```
