> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fly.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Update Maintenance Window

> Update a cluster's weekly maintenance window. Give at least one of `day`, `start_hour` and `duration_hours`; omitted fields keep their current value. `start_hour` is in the cluster's timezone, which is derived from its region and cannot be changed. Changes are accepted only while the cluster is ready and no maintenance is running.



## OpenAPI

````yaml /api/machines/openapi.json patch /v1/postgres/{postgres_cluster_id}/maintenance_window
openapi: 3.1.0
info:
  title: Machines API
  description: >-
    This site hosts documentation generated from the Fly.io Machines API OpenAPI
    specification. Visit our complete [Machines API
    docs](https://fly.io/docs/machines/api/) for how to get started, more
    information about each endpoint, parameter descriptions, and examples.
  contact: {}
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: '1.0'
servers:
  - url: https://api.machines.dev
security:
  - FlyBearerAuth: []
tags:
  - name: Apps
    description: >-
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/apps-resource/) for details about
      using the Apps resource.
  - name: Machines
    description: >-
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/machines-resource/) for details
      about using the Machines resource.
  - name: TLS Certificates
    description: >
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/certificates-resource/) for details
      about using the TLS Certificates resource.
  - name: Volumes
    description: >-
      This site hosts documentation generated from the Fly.io Machines API
      OpenAPI specification. Visit our complete [Machines API
      docs](https://fly.io/docs/machines/api/volumes-resource/) for details
      about using the Volumes resource.
  - name: Postgres Clusters
    description: >-
      Create and manage Postgres clusters, including databases, users,
      extensions, backups, and app attachments.
externalDocs:
  url: https://fly.io/docs/machines/working-with-machines/
paths:
  /v1/postgres/{postgres_cluster_id}/maintenance_window:
    patch:
      tags:
        - Postgres Clusters
      summary: Update Maintenance Window
      description: >-
        Update a cluster's weekly maintenance window. Give at least one of
        `day`, `start_hour` and `duration_hours`; omitted fields keep their
        current value. `start_hour` is in the cluster's timezone, which is
        derived from its region and cannot be changed. Changes are accepted only
        while the cluster is ready and no maintenance is running.
      operationId: Postgres_maintenance_window_update
      parameters:
        - name: postgres_cluster_id
          in: path
          description: Managed Postgres Cluster ID
          required: true
          schema:
            type: string
      requestBody:
        description: Maintenance window fields to change
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/updatePostgresMaintenanceWindowRequest'
        required: true
      responses:
        '200':
          description: Updated maintenance window
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/showPostgresMaintenanceWindowResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostgresErrorResponse'
        '404':
          description: Cluster not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostgresErrorResponse'
        '409':
          description: The cluster is not ready or a maintenance is running
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostgresErrorResponse'
        '410':
          description: '''This cluster has been deleted'' or ''This cluster is being deleted'''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostgresErrorResponse'
        '422':
          description: No fields given, or a value is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostgresErrorResponse'
        '500':
          description: Failed to update maintenance window
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostgresErrorResponse'
components:
  schemas:
    updatePostgresMaintenanceWindowRequest:
      type: object
      properties:
        day:
          type: string
          description: Day of the week the window starts on.
          example: tuesday
          enum:
            - sunday
            - monday
            - tuesday
            - wednesday
            - thursday
            - friday
            - saturday
        duration_hours:
          maximum: 8
          minimum: 3
          type: integer
          description: Length of the window in hours.
          example: 3
        start_hour:
          maximum: 23
          minimum: 0
          type: integer
          description: Hour of the day the window starts, in the cluster's timezone.
          example: 4
    showPostgresMaintenanceWindowResponse:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/PostgresMaintenanceWindow'
    PostgresErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
        status:
          type: string
          description: Optional machine-readable error status.
          example: sessions_not_terminated
    PostgresMaintenanceWindow:
      type: object
      properties:
        day:
          type: string
          description: Day of the week the window starts on.
          example: sunday
          enum:
            - sunday
            - monday
            - tuesday
            - wednesday
            - thursday
            - friday
            - saturday
        duration_hours:
          maximum: 8
          minimum: 3
          type: integer
          description: Length of the window in hours.
          example: 3
        start_hour:
          maximum: 23
          minimum: 0
          type: integer
          description: Hour of the day the window starts, in the cluster's timezone.
          example: 1
        timezone:
          type: string
          description: >-
            IANA timezone the window is expressed in, derived from the cluster's
            region.
          example: America/New_York
  securitySchemes:
    FlyBearerAuth:
      type: http
      scheme: bearer
      description: >-
        A Fly API token with access to the requested organization or resource.
        Send it as `Authorization: Bearer <Fly API token>`.

````