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

# Set run window

> Sets the workflow's run window, replacing any existing one. Queued runs outside the new window are held, and held runs inside it are released, right away. This does not create a workflow version.

Requires the Owner or Member workspace role.

An invalid window returns `400` with `error: "InvalidRunWindow"` and an `errors` array listing each problem with its `path`. A valid window may still return `warnings`, for example when `recurrence_start` does not match its recurrence rule.

See [Run Window](/concepts/run-window).



## OpenAPI

````yaml workflow-api/workflow-api.yaml put /workflows/{workflow_id}/run-window
openapi: 3.0.0
info:
  title: Workflow API
  version: 1.0.0
  description: API for managing workflows and their metadata
servers:
  - url: https://api.cloudcruise.com
    description: CloudCruise Platform Production API Server
security:
  - AuthScheme: []
paths:
  /workflows/{workflow_id}/run-window:
    put:
      summary: Set run window
      description: >-
        Sets the workflow's run window, replacing any existing one. Queued runs
        outside the new window are held, and held runs inside it are released,
        right away. This does not create a workflow version.


        Requires the Owner or Member workspace role.


        An invalid window returns `400` with `error: "InvalidRunWindow"` and an
        `errors` array listing each problem with its `path`. A valid window may
        still return `warnings`, for example when `recurrence_start` does not
        match its recurrence rule.


        See [Run Window](/concepts/run-window).
      operationId: setRunWindow
      parameters:
        - name: workflow_id
          in: path
          required: true
          schema:
            type: string
          description: The ID of the workflow
        - name: cc-key
          in: header
          required: false
          schema:
            type: string
          description: CloudCruise API key for authentication
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunWindow'
      responses:
        '200':
          description: The stored run window, whether it is open now, and any warnings
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/RunWindowResponse'
                  - type: object
                    properties:
                      warnings:
                        type: array
                        items:
                          $ref: '#/components/schemas/RunWindowIssue'
        '400':
          description: The run window is invalid
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: integer
                    example: 400
                  error:
                    type: string
                    example: InvalidRunWindow
                  message:
                    type: string
                    example: The run window is invalid
                  errors:
                    type: array
                    items:
                      $ref: '#/components/schemas/RunWindowIssue'
        '401':
          description: Unauthorized - Invalid or missing authentication
        '403':
          description: Your workspace role cannot edit workflows
        '404':
          description: Workflow not found
components:
  schemas:
    RunWindow:
      type: object
      description: >-
        A run window. For any date, dated special hours win over recurring
        special hours, which win over regular hours. Needs at least one regular
        period or one active special entry.
      required:
        - time_zone
        - regular_hours
      properties:
        time_zone:
          type: string
          example: America/Chicago
          description: IANA time zone the hours are evaluated in
        regular_hours:
          type: array
          items:
            $ref: '#/components/schemas/RunWindowRegularPeriod'
        special_hours:
          type: array
          items:
            $ref: '#/components/schemas/RunWindowSpecialHours'
    RunWindowResponse:
      type: object
      properties:
        run_window:
          allOf:
            - $ref: '#/components/schemas/RunWindow'
          nullable: true
        state:
          allOf:
            - $ref: '#/components/schemas/RunWindowState'
          nullable: true
    RunWindowIssue:
      type: object
      properties:
        path:
          type: string
          example: special_hours[0].recurrence_start
          description: Location of the problem in the submitted window
        message:
          type: string
    RunWindowRegularPeriod:
      type: object
      description: >-
        One weekly period. It belongs to the day it starts and may end on the
        next day.
      required:
        - active_start_day
        - active_start_time
        - active_end_day
        - active_end_time
      properties:
        active_start_day:
          $ref: '#/components/schemas/RunWindowDay'
        active_start_time:
          $ref: '#/components/schemas/RunWindowTime'
        active_end_day:
          $ref: '#/components/schemas/RunWindowDay'
        active_end_time:
          $ref: '#/components/schemas/RunWindowTime'
    RunWindowSpecialHours:
      type: object
      description: >-
        Overrides the weekly hours for particular dates. Provide either
        `start_date` (with optional `end_date`) or `recurrence` with
        `recurrence_start`, never both. When `active` is `true`,
        `active_start_time` and `active_end_time` are required and the end must
        be after the start.
      required:
        - active
      properties:
        label:
          type: string
          example: Thanksgiving
        start_date:
          $ref: '#/components/schemas/RunWindowDate'
        end_date:
          allOf:
            - $ref: '#/components/schemas/RunWindowDate'
          description: Last day of a dated entry. Defaults to `start_date`.
        recurrence:
          type: string
          example: FREQ=MONTHLY;BYDAY=1SA
          description: >-
            RFC 5545 rule. Only DAILY, WEEKLY, MONTHLY and YEARLY frequencies
            are supported.
        recurrence_start:
          $ref: '#/components/schemas/RunWindowDate'
        active:
          type: boolean
          description: >-
            `true` opens the hours on matching dates, `false` closes them for
            the whole date
        active_start_time:
          $ref: '#/components/schemas/RunWindowTime'
        active_end_time:
          $ref: '#/components/schemas/RunWindowTime'
    RunWindowState:
      type: object
      properties:
        open:
          type: boolean
          description: Whether runs may start right now
        nextOpenAt:
          type: string
          format: date-time
          nullable: true
          description: >-
            When the window next opens. `null` when it is open now, or when no
            opening falls within the next 400 days.
    RunWindowDay:
      type: string
      enum:
        - MONDAY
        - TUESDAY
        - WEDNESDAY
        - THURSDAY
        - FRIDAY
        - SATURDAY
        - SUNDAY
    RunWindowTime:
      type: object
      required:
        - hours
      properties:
        hours:
          type: integer
          minimum: 0
          maximum: 23
        minutes:
          type: integer
          minimum: 0
          maximum: 59
          description: Defaults to 0
    RunWindowDate:
      type: object
      required:
        - year
        - month
        - day
      properties:
        year:
          type: integer
        month:
          type: integer
          minimum: 1
          maximum: 12
        day:
          type: integer
          minimum: 1
          maximum: 31
  securitySchemes:
    AuthScheme:
      type: apiKey
      name: cc-key
      in: header
      description: >-
        API key-based authentication. Provide your CloudCruise API key in the
        cc-key header.

````

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