# The organization's maintenance windows

> GET /v1/maintenance-windows. .

Source: https://legion.ambient.xyz/docs/api/hosts/list-maintenance-windows

`GET https://api.legion.ambient.xyz/v1/maintenance-windows`

Authenticate with an API key: `Authorization: Bearer $LEGION_API_KEY`.

. The maintenance windows of the organization's hosts, latest start first, with their state, notice and
penalty-free outcome. `host_id`, `id` and `state` (both repeatable) filter. An unknown host or one of another
organization is 404; an `id` that is unknown or another organization's is simply not listed. Needs the
`hosts.manage` permission (an organization owner).

## Query parameters

- `host_id`, string (uuid): Only this host's windows.
- `id`, array of string (uuid): Only these windows (`?id=<window>&id=<window>`, up to 100), for a script or a confirmation that names windows.
- `state`, array of MaintenanceState: Only windows in these states (`?state=scheduled&state=active`).
- `cursor`, string: Opaque cursor from a previous page's `next_cursor`.
- `limit`, integer

## Responses

### 200

A page of windows.

- `items`, array of MaintenanceWindow, required
  - `id`, string (uuid), required: The window.
  - `host_id`, string (uuid), required: The host it takes down.
  - `host_name`, string, required: The host's name (or hostname), as the provider sees it.
  - `batch_id`, string (uuid), required: The `scheduleMaintenance` request that created it, shared by the windows of one bulk schedule.
  - `state`, MaintenanceState, required: . `scheduled` (announced, renters told), `closing` (the last 5 minutes before the start: the penalty-free outcome is decided, nothing can start, rentals in their notice), `active` (the host is in maintenance, its rentals stopped), `overrun` (the planned end passed and the host has not synced back), `completed`, `cancelled`. The list grows: accept a value you do not know.
  - `reason`, MaintenanceReason, required: . Why a provider takes a host down, shown to the renters of rentals on it. The list grows: accept a value you do not know.
  - `note`, string: The provider's own note, cleaned (no control characters, 280 characters). Only the provider sees it; it is in no email and no renter's view.
  - `start`, string (date-time), required: The planned start (what renters were told). The actual start is `started_at`.
  - `planned_end`, string (date-time), required: The planned end. Never edited by an early end or an overrun; the actual end is `ended_at`.
  - `ended_at`, string (date-time): When the window actually ended: "done with maintenance" with the host online, the planned end with the host online, or the host's return (after an overrun, or after "done with maintenance" while the host was still away). Absent while it is open. The plan is `start` and `planned_end`; what happened is `started_at` and `ended_at`.
  - `end_requested_at`, string (date-time): When "done with maintenance" (`endMaintenance`, or Legion's end) was asked for. The uptime excuse stops here. While the host is still away the window stays open (`overrun`) until it is back, and `ended_at` is that return.
  - `scheduled_at`, string (date-time), required: When it was scheduled (it counts toward the host's 4 windows per 30 days from then).
  - `scheduled_by`, string (uuid): The person who scheduled it; absent when an API key did.
  - `notice_from`, string (date-time), required: Where the notice counts from: when it was scheduled, or when a reschedule moved it earlier or made it longer.
  - `reschedules_left`, integer, required: How many more times its start or end may be changed (a reason or note change does not count).
  - `penalty_free`, boolean, required: While `scheduled`, a forecast from the rentals now on the host; from `closing`, the decided outcome (`penalty_free_final` true).
  - `penalty_free_final`, boolean, required: Whether `penalty_free` is decided (from `closing` on) rather than a forecast. A window cancelled before closing is never decided: `false`.
  - `required_notice_seconds`, integer, required: 72 hours if any rental the window stops is on-demand, 1 hour if all are interruptible, 0 for none (and for a window cancelled before it was decided).
  - `notice_seconds`, integer, required: What the renters have, the start minus `notice_from`.
  - `earliest_penalty_free_start`, string (date-time): While `scheduled`, the earliest start that would be penalty-free for the rentals now on the host.
  - `rentals`, MaintenanceTierCounts, required: The rentals the window stops (decided at `closing`, a forecast before), by tier. Counts only: never a renter.
  - `may_restart`, integer, required: Stopped rentals with files that their renters could still start before the window closes. A forecast, not in `rentals`: if one is started, it counts at closing, and a window that is penalty-free now may not be then (an on-demand rental needs 72 hours). 0 for a completed or cancelled window.
  - `renters_notified`, integer, required: The renter organizations with a rental on the host now: told of the window, and told again if it is changed or cancelled. Counts only, never a renter; 0 for a completed or cancelled window.
  - `started_at`, string (date-time): When it actually became `active` (the sweep, at or just after `start`). Absent before.
  - `cancelled_at`, string (date-time): When it was cancelled. Absent unless `cancelled`.
  - `cancel_cause`, MaintenanceCancelCause: Who cancelled it: the provider, Legion, or the host's removal.
  - `end_cause`, MaintenanceEndCause: How it ended: at its planned end, ended early by the provider, by the host's return after an overrun, by the host's removal, or by Legion.
  - `overrun_seconds`, integer: How long after the planned end the host stayed away.
  - `excused_seconds`, integer, required: The host's uptime-score minutes this window excused so far, in seconds.
- `next_cursor`, string

Example:

```json
{
  "items": [
    {
      "id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
      "host_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
      "host_name": "string",
      "batch_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
      "state": "scheduled",
      "reason": "hardware",
      "note": "string",
      "start": "2026-10-15T12:00:00Z",
      "planned_end": "2026-10-15T12:00:00Z",
      "ended_at": "2026-10-15T12:00:00Z",
      "end_requested_at": "2026-10-15T12:00:00Z",
      "scheduled_at": "2026-10-15T12:00:00Z",
      "scheduled_by": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
      "notice_from": "2026-10-15T12:00:00Z",
      "reschedules_left": 0,
      "penalty_free": false,
      "penalty_free_final": false,
      "required_notice_seconds": 0,
      "notice_seconds": 0,
      "earliest_penalty_free_start": "2026-10-15T12:00:00Z",
      "rentals": {
        "on_demand": 0,
        "interruptible": 0
      },
      "may_restart": 0,
      "renters_notified": 0,
      "started_at": "2026-10-15T12:00:00Z",
      "cancelled_at": "2026-10-15T12:00:00Z",
      "cancel_cause": "provider",
      "end_cause": "on_time",
      "overrun_seconds": 0,
      "excused_seconds": 0
    }
  ],
  "next_cursor": "string"
}
```

### 400

The request is malformed or fails validation. An image reference that
is not a container image reference answers `invalid_image_reference`.

### 401

Missing, unknown, expired or revoked credentials.

### 403

The caller lacks the permission this operation requires (`forbidden`),
or signed in without having joined an organization yet
(`no_organization`; `getOnboarding` and the invitation and
organization operations under it work), or could not sign in
(`email_unverified`, `account_conflict`, and `domain_not_allowed`). `not_invited` is no longer returned to
session tokens.

`access_not_approved`: a signed-in person who is not approved
for the beta yet. Every operation that takes a credential answers it to
them, except `getMe` and `joinMyWaitlist`; the problem carries
`access` (`waitlisted` or `not_requested`, and the email). Approved
means a member of an organization, holding a pending invitation, or Legion; an API key always belongs to a member.

`oauth_token_mcp_only`: the caller sent an OAuth access token (`lgo_`), which is accepted
only by `mcpMessage` and the tool calls it dispatches. Every other operation answers it, whatever
the token's scope. Use an API key or the Legion web app.

`org_suspended`: the caller's organization is suspended. Every operation that takes a
credential answers it, by session or API key, except `getMe` (which shows `org.suspended_at` and
`org.suspension_reason`) and the support operations under `/v1/support/`.

`terms_not_accepted`: an approved caller who has not accepted
the current version of the Terms of Use and the Acceptable Use Policy. Every operation that takes a credential answers it, except `getMe`,
`acceptLegalDocuments`, `joinMyWaitlist` and the wind-down operations
(`listRentals`, `stopRental`, `deleteRental`, `listHosts`,
`updateListing` with `listed` false, `removeHost`); the problem
carries `legal`. An API key acts for the person who created it, so it
is refused until that person accepts. Terminal
operations also return
`session_required` (called with an API key) and `step_up_required`
(neither a sign-in nor a step-up challenge within the step-up window).

### 404

The resource does not exist or belongs to another organization.

### 500

An unexpected server error. Safe to retry.

## Errors

- 400 [`invalid_cursor`](https://legion.ambient.xyz/docs/errors#invalid_cursor)
- 403 [`no_organization`](https://legion.ambient.xyz/docs/errors#no_organization)

## Example request

```sh
curl -s "https://api.legion.ambient.xyz/v1/maintenance-windows" \
  -H "Authorization: Bearer $LEGION_API_KEY"
```
