# Move or change scheduled maintenance windows

> POST /v1/maintenance-windows/reschedule. .

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

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

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

. Changes `start`, `duration_minutes`, `reason` or `note` of up to 100 windows that are still `scheduled`, at
least one field. Renters are told of a new start or end once, in the same email as other changes (a change inside
the three minutes before the first email replaces it). A window's start and end may be changed 3 times; a move to
an earlier start or to a longer window restarts its notice from now, so it may stop being penalty-free. A change of
only `reason` or `note` does not count toward the 3, does not restart the notice, and is not emailed (renters see
the reason on their rental). Skipped windows, in `skipped`: `maintenance_started` (from 5 minutes before its start,
`closing`, `active` or `overrun`: cancel it while closing, or end it), `maintenance_not_open` (completed or
cancelled), `maintenance_reschedule_limit` and `invalid_maintenance_window` (the new start or duration breaks the
rules of `scheduleMaintenance`). An unknown window or one of another organization is 404 for the whole request. Setting the values a window already has changes nothing. A body the schema refuses is 400 `invalid_request`; a
`note` over 280 characters is 422 `maintenance_note_too_long`. Needs the `hosts.manage` permission.

## Request body

- `window_ids`, array of string (uuid), required: The organization's windows, 1 to 100. One the organization does not own makes the whole request 404.
- `start`, string (date-time): The new start: RFC 3339, on a whole minute, 5 minutes to 90 days from now. The planned length is kept unless `duration_minutes` is given.
- `duration_minutes`, integer: The new planned length in minutes, 15 to 4320, from the (new) start.
- `reason`, MaintenanceReason: . 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 new note, at most 280 characters after cleaning (longer is 422 `maintenance_note_too_long`); an empty one removes it. Renters never see it.

Example:

```json
{
  "window_ids": [
    "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b"
  ],
  "start": "2026-10-15T12:00:00Z",
  "duration_minutes": 15,
  "reason": "hardware",
  "note": "string"
}
```

## Responses

### 200

The windows as they are now and the windows skipped.

- `batch_id`, string (uuid): The batch `scheduleMaintenance` created.
- `windows`, array of MaintenanceWindow, required: The windows the request scheduled or acted on, as they are now, ordered by host id (schedule) or window id. Empty when every item was skipped (still 200).
  - `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.
- `skipped`, array of MaintenanceSkip, required: The owned hosts or windows the request left alone, with why.
  - `id`, string (uuid), required: The host (schedule, preview) or window (reschedule, cancel, end).
  - `code`, string, required: Why it was left alone. The list grows: accept a value you do not know. `host_removed`: the host was removed. `host_removing`: the host is being removed. `maintenance_exists`: the host already has an open window. `maintenance_quota`: the host had 4 windows in 30 days (cancelled ones count). `maintenance_reschedule_limit`: the window's start or end was changed 3 times. `maintenance_not_open`: the window is completed or cancelled. `maintenance_started`: the window is closing, active or in overrun (too late to change or cancel it). `maintenance_not_active`: the window has not started (cancel it instead of ending it). `invalid_maintenance_window`: the new start or duration breaks the rules of `scheduleMaintenance`. `maintenance_retry`: a cancel or end of this window could not be done now (each window is changed in its own transaction, so the others named are done); nothing of this window was written, try it again. `maintenance_failed`: a cancel or end of this window failed for another reason; nothing of it was written, the others named are done, and Legion logged the error (try again later or contact support).
  - `detail`, string: The reason in words, for a person.

Example:

```json
{
  "batch_id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
  "windows": [
    {
      "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
    }
  ],
  "skipped": [
    {
      "id": "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b",
      "code": "host_removed",
      "detail": "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.

### 422

The Idempotency-Key was already used with a different request body.

### 429

Rate limited (`code` is `rate_limited`), or the organization asked the
pull-through mirror to copy in too many different tags or digests of one
repository today (`mirror_quota_exceeded`). Retry after the `Retry-After`
seconds.

### 500

An unexpected server error. Safe to retry.

## Errors

- 400 [`invalid_maintenance_window`](https://legion.ambient.xyz/docs/errors#invalid_maintenance_window)
- 403 [`no_organization`](https://legion.ambient.xyz/docs/errors#no_organization)
- 422 [`maintenance_note_too_long`](https://legion.ambient.xyz/docs/errors#maintenance_note_too_long)
- 429 [`rate_limited`](https://legion.ambient.xyz/docs/errors#rate_limited)

## Example request

```sh
curl -s -X POST "https://api.legion.ambient.xyz/v1/maintenance-windows/reschedule" \
  -H "Authorization: Bearer $LEGION_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "window_ids": [
    "0192f1a2-7c3d-7e4f-8a9b-0c1d2e3f4a5b"
  ],
  "start": "2026-10-15T12:00:00Z",
  "duration_minutes": 15,
  "reason": "hardware",
  "note": "string"
}'
```
