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

# Set the maintenance window

> Set the database's weekly one-hour maintenance window, in UTC, or let Raff pick it.

- **Your own window**: send `day` (0 = Sunday to 6 = Saturday) and `hour` (0 to 23), the start of the hour in UTC.
- **Let Raff pick**: send `{"auto": true}`. Raff picks the quietest hour of the database's week from its traffic, or Sunday 07:00 UTC until it has a week of traffic.

A planned update moves to the first time in the new window at or after its planned time. It never moves earlier, does not use a postpone, and stays where it is when the new window falls after its `last_date`. An update you started with [Run the planned update now](/api-reference/databases/update-database-maintenance-now) does not move.

Free databases are updated in a window Raff picks (`window_raff_only` is `true`): setting it returns `400`.

## Errors

- `400`: `day` or `hour` is missing or out of range, or the database is on the free plan.




## OpenAPI

````yaml PUT /api/v1/databases/{database_id}/maintenance/window
openapi: 3.0.3
info:
  title: Raff API
  description: >
    REST API for managing cloud infrastructure on Raff.


    ## Authentication

    Most endpoints require authentication via API key. Catalog endpoints under
    `/api/v1/public/` are open and require no authentication.


    ### API Key Authentication

    Include your API key in the `X-API-Key` header:
      ```
      curl -H "X-API-Key: YOUR_API_KEY" https://api.rafftechnologies.com/api/v1/vms
      ```

    ## Catalog

    Use the public catalog endpoints to discover available regions, OS
    templates, and pricing plans before creating resources:

    - `GET /api/v1/public/regions` — list available regions

    - `GET /api/v1/public/templates` — list OS templates (use the `id` as
    `template_id` when creating a VM)

    - `GET /api/v1/public/pricing/vm` — list VM pricing plans (use the `id` as
    `pricing_id` when creating a VM)

    - `GET /api/v1/public/pricing/volume` — volume storage pricing

    - `GET /api/v1/public/pricing/snapshot` — snapshot storage pricing

    - `GET /api/v1/public/pricing/backup` — backup storage pricing

    - `GET /api/v1/public/pricing/ip` — IP address pricing

    - `GET /api/v1/public/pricing/vpn` — VPN gateway and site-to-site tunnel
    pricing

    - `GET /api/v1/public/pricing/database` — managed database pricing (plans,
    high availability, read replicas, extra storage)

    - `GET /api/v1/public/pricing/kubernetes` — managed Kubernetes pricing
    (worker node plans, HA control plane, storage nodes)
  version: 1.0.0
  contact:
    name: Raff Technologies
    url: https://rafftechnologies.com
servers:
  - url: https://api.rafftechnologies.com
    description: Production
security:
  - ApiKeyAuth: []
tags:
  - name: Catalog
    description: >-
      Discover available regions, OS templates, and pricing plans. No
      authentication required.
  - name: Health
    description: Health check endpoints
  - name: Projects
    description: Organize resources into projects for billing and access control
  - name: Virtual Machines
  - name: Kubernetes
    description: >-
      Managed Kubernetes clusters — HA control planes, autoscaling node pools,
      kubeconfig access
  - name: Functions
    description: Deploy and manage serverless functions
  - name: Raff Apps
    description: >-
      Push-to-deploy web services, private services, workers, cron jobs, and
      one-off jobs on the Raff PaaS — with custom domains, environment
      variables, autoscaling, and per-second billing with spend caps
  - name: Managed Databases
    description: >-
      Managed PostgreSQL, MySQL, Valkey, ClickHouse and Kafka with backups, high
      availability, private VPC networking, optional public access over TLS, and
      metrics
  - name: Networking
    description: >-
      Attach and detach VPCs, floating IPs, and security groups to VM network
      interfaces
  - name: Snapshots
    description: Point-in-time copies of VMs and volumes for quick rollback or cloning
  - name: Backups
    description: Scheduled and on-demand VM backups with restore capability
  - name: Backup Schedules
    description: Recurring daily or weekly backup schedules attached to a VM
  - name: SSH Keys
    description: Manage account-level SSH keys for VM provisioning
  - name: Members
    description: Account-level members — invite, list, update role, remove
  - name: Project Members
    description: Members of a specific project — same model as Members but project-scoped
  - name: Roles
    description: Custom roles bundling account or project permissions
  - name: Permissions
    description: List the catalog of permission strings used by roles
  - name: API Keys
    description: Create and manage API keys for programmatic access
  - name: Invitations
    description: Create and cancel email-based invitations to join the account or a project
paths:
  /api/v1/databases/{database_id}/maintenance/window:
    put:
      tags:
        - Managed Databases
      summary: Set the maintenance window
      description: >
        Set the database's weekly one-hour maintenance window, in UTC, or let
        Raff pick it.


        - **Your own window**: send `day` (0 = Sunday to 6 = Saturday) and
        `hour` (0 to 23), the start of the hour in UTC.

        - **Let Raff pick**: send `{"auto": true}`. Raff picks the quietest hour
        of the database's week from its traffic, or Sunday 07:00 UTC until it
        has a week of traffic.


        A planned update moves to the first time in the new window at or after
        its planned time. It never moves earlier, does not use a postpone, and
        stays where it is when the new window falls after its `last_date`. An
        update you started with [Run the planned update
        now](/api-reference/databases/update-database-maintenance-now) does not
        move.


        Free databases are updated in a window Raff picks (`window_raff_only` is
        `true`): setting it returns `400`.


        ## Errors


        - `400`: `day` or `hour` is missing or out of range, or the database is
        on the free plan.
      operationId: setDatabaseMaintenanceWindow
      parameters:
        - $ref: '#/components/parameters/DatabaseIDPath'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetDatabaseMaintenanceWindowRequest'
            examples:
              own:
                summary: Tuesdays, 02:00 to 03:00 UTC
                value:
                  day: 2
                  hour: 2
              auto:
                summary: Let Raff pick
                value:
                  auto: true
      responses:
        '200':
          description: The window was set. The response is the database's planned updates.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DatabaseMaintenanceResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    DatabaseIDPath:
      name: database_id
      in: path
      required: true
      description: >-
        Database ID (UUID) or short id (the `database_id` field, e.g.
        `a1b2c3d4`)
      schema:
        type: string
  schemas:
    SetDatabaseMaintenanceWindowRequest:
      type: object
      properties:
        day:
          type: integer
          minimum: 0
          maximum: 6
          description: >-
            Day of the window, UTC. 0 = Sunday, 6 = Saturday. Required unless
            `auto` is `true`.
          example: 2
        hour:
          type: integer
          minimum: 0
          maximum: 23
          description: Start hour of the window, UTC. Required unless `auto` is `true`.
          example: 2
        auto:
          type: boolean
          default: false
          description: >-
            Set to `true` to let Raff pick the window. `day` and `hour` are then
            ignored.
    DatabaseMaintenanceResponse:
      type: object
      properties:
        success:
          type: boolean
        maintenance:
          $ref: '#/components/schemas/DatabaseMaintenance'
    DatabaseMaintenance:
      type: object
      description: >-
        A database's planned updates to a newer build of its version, its weekly
        maintenance window, and the updates and upgrades that ran. When a
        version reaches the end of its support, the planned update moves the
        database to the next version instead; `moves_to` says so.
      properties:
        window_day:
          type: integer
          minimum: 0
          maximum: 6
          description: Day of the weekly window, UTC. 0 = Sunday, 6 = Saturday.
          example: 0
        window_hour:
          type: integer
          minimum: 0
          maximum: 23
          description: Start hour of the window, UTC. The window is one hour.
          example: 7
        window_auto:
          type: boolean
          description: >-
            Raff picks the window from the database's traffic. `false` when you
            set it.
        window_raff_only:
          type: boolean
          description: Free plan. Raff picks the window and it cannot be changed.
        upcoming:
          allOf:
            - $ref: '#/components/schemas/DatabaseMaintenanceUpdate'
          nullable: true
          description: >-
            The update that is planned (`scheduled`) or `running`, or null when
            none is planned.
        upcoming_note:
          type: string
          description: >-
            What the planned update brings, in plain words. Empty when none is
            planned.
          example: The latest fixes for PostgreSQL 18.
        history:
          type: array
          description: The most recent updates that ran, `done` or `failed`, newest first.
          items:
            $ref: '#/components/schemas/DatabaseMaintenanceUpdate'
        upgrades:
          type: array
          description: >-
            Upgrades to a newer major version that ended, newest first
            (PostgreSQL). Empty for other engines.
          items:
            $ref: '#/components/schemas/DatabaseVersionUpgrade'
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
    DatabaseMaintenanceUpdate:
      type: object
      description: One update of a database to a newer build of its version.
      properties:
        id:
          type: integer
          format: int64
          description: The update's ID
          example: 412
        from_version:
          type: string
          description: Version the database runs before the update
          example: '18.7'
        to_version:
          type: string
          description: >-
            Version after the update. The same as `from_version` when the update
            brings a newer build of the same version.
          example: '18.8'
        what:
          type: string
          description: >-
            What the update brings, in plain words, such as `PostgreSQL 18.8` or
            `A newer build of PostgreSQL 18.7 (security and operating-system
            fixes)`.
          example: PostgreSQL 18.8
        moves_to:
          type: string
          description: >-
            The version the update moves the database to, such as `8.4`, when
            the database's version has reached the end of its support (MySQL 8.0
            to 8.4). Empty for an update inside the version, which is every
            other update.
          example: ''
        state:
          type: string
          description: >
            One of `scheduled`, `running`, `done`, `failed`.


            - `scheduled`: planned for `scheduled_for`.

            - `running`: being applied. `step_note` says the step.

            - `done`: the database runs the new build.

            - `failed`: the update did not complete and the database went back
            to the build it ran before. `message` says what happened. After a
            failed move to another version (`moves_to`), the database can be
            back as it was when the move started; `message` then says the time.
        step_note:
          type: string
          description: >-
            While `running`, the step in plain words, such as `Taking a backup
            first. Nothing has changed yet.` Empty otherwise.
        scheduled_for:
          type: string
          format: date-time
          description: >-
            When the update starts, RFC 3339. It starts within the hour that
            begins then.
        first_date:
          type: string
          format: date-time
          description: The date first announced, RFC 3339
        last_date:
          type: string
          format: date-time
          description: The latest time the update can be postponed to, RFC 3339
        postponed_count:
          type: integer
          description: How many times it was postponed
        postpones_left:
          type: integer
          description: How many more times it can be postponed (3 in all). 0 once it runs.
        security:
          type: boolean
          description: >-
            A critical security fix. It is announced 24 hours ahead, runs at the
            window's hour on any day, and each postpone moves it a day.
        expected_seconds:
          type: integer
          description: >-
            How long the database is expected to refuse connections during the
            update, in seconds. 0 = no interruption expected.
          example: 30
        measured_ms:
          type: integer
          format: int64
          nullable: true
          description: >-
            How long the database refused connections during the update, in
            milliseconds. Null until measured.
        message:
          type: string
          description: >-
            What happened, in plain words, when the update did not go through.
            Can also describe an update that changed nothing the database runs.
            Often empty.
        started_by:
          type: string
          description: >
            Who started the update. One of `window`, `customer`, `resume`,
            `support`.


            - `window`: Raff, in the maintenance window.

            - `customer`: you, with [Run the planned update
            now](/api-reference/databases/update-database-maintenance-now).

            - `resume`: taken when you resumed a paused database.

            - `support`: Raff support.
          example: window
        started_at:
          type: string
          description: When the update started, RFC 3339. Empty until it starts.
        finished_at:
          type: string
          description: When the update ended, RFC 3339. Empty until it ends.
    DatabaseVersionUpgrade:
      type: object
      description: An upgrade of a database to a newer major version.
      properties:
        from_version:
          type: string
          description: Major version before the upgrade
          example: '18'
        to_version:
          type: string
          description: Major version the upgrade goes to
          example: '19'
        state:
          type: string
          enum:
            - backing_up
            - upgrading
            - finishing
            - analyzing
            - done
            - reverting
            - failed
            - undone
          description: >
            Where the upgrade stands.


            - `backing_up`: the backup before the upgrade is running. Nothing
            has changed yet.

            - `upgrading`: the database is offline and being upgraded.

            - `finishing`: up on the new version; extensions are being updated.

            - `analyzing`: running again; statistics are being refreshed.

            - `done`: the upgrade is complete.

            - `reverting`: the upgrade could not complete and the database is
            returning to its version.

            - `failed`: back on its version, unchanged. See `message`.

            - `undone`: it had succeeded and was later returned to the older
            version from a backup.
        message:
          type: string
          description: The reason when `state` is `failed`; empty otherwise
        started_at:
          type: string
          description: When the upgrade started, RFC 3339
        finished_at:
          type: string
          description: When the upgrade finished, RFC 3339 (empty while it runs)
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Authentication required
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: API key for authentication. Each key is bound to a specific account.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.