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

# Create a cron schedule

> Creates a new cron schedule for a group of workspaces. Schedules define automated power operations (START, STOP, RESTART) executed at specified schedules according to cron expressions and time zone. START schedules may optionally include an intermediate device Workspace ID for Wake on LAN operations in secure networks. If intermediate_device is provided, it indicates an intermediate device must be used. The system validates no conflicting schedule exists (same type, time, and day after time zone conversion).



## OpenAPI

````yaml /en/api-reference/openapi.en-v1.json post /v1/organizations/{organization_id}/workspace-groups/{workspace_group_id}/schedules
openapi: 3.0.3
info:
  title: Public Portal API
  version: 1.0.0
  description: Public REST API for portal
servers:
  - url: https://api.staging.flxwvdexternal.com
    description: Staging API server.
security:
  - bearerAuth: []
tags: []
paths:
  /v1/organizations/{organization_id}/workspace-groups/{workspace_group_id}/schedules:
    post:
      tags:
        - Workspace groups
      summary: Create a cron schedule
      description: >-
        Creates a new cron schedule for a group of workspaces. Schedules define
        automated power operations (START, STOP, RESTART) executed at specified
        schedules according to cron expressions and time zone. START schedules
        may optionally include an intermediate device Workspace ID for Wake on
        LAN operations in secure networks. If intermediate_device is provided,
        it indicates an intermediate device must be used. The system validates
        no conflicting schedule exists (same type, time, and day after time zone
        conversion).
      operationId: createWorkspaceGroupSchedule
      parameters:
        - name: organization id
          in: path
          required: true
          schema:
            type: string
            maxLength: 24
            pattern: ^[0-9a-f]{24}$
          description: The unique identifier of the organization
          example: 507f1f77bcf86cd799439011
        - name: workspace_group_id
          in: path
          required: true
          schema:
            type: string
            maxLength: 24
            pattern: ^[0-9a-f]{24}$
          description: The unique identifier of the workspace group
          example: 507f1f77bcf86cd799439020
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateWorkspaceGroupScheduleRequestV1'
            examples:
              create-start-schedule:
                summary: Create a START schedule for weekdays at 8 AM
                value:
                  cron_expression: 0 8 * * 1-5
                  time_zone: Eastern Standard Time
                  type: start
              create-start-schedule-with-intermediate-device:
                summary: >-
                  Create a START schedule with an intermediate device for
                  Wake-on-LAN
                value:
                  cron_expression: 0 8 * * 1-5
                  time_zone: Eastern Standard Time
                  type: start
                  intermediate_device: 507f1f77bcf86cd799439050
              create-stop-schedule:
                summary: Create a STOP schedule for weekdays at 6 PM
                value:
                  cron_expression: 0 18 * * 1-5
                  time_zone: UTC
                  type: stop
              create-restart-schedule:
                summary: Create a RESTART schedule for weekends at midnight
                value:
                  cron_expression: 0 0 * * 0,6
                  time_zone: Pacific Standard Time
                  type: restart
      responses:
        '201':
          description: >-
            Schedule successfully created. The response contains the created
            schedule resource.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkspaceGroupScheduleV1'
        '400':
          $ref: '#/components/responses/BadRequest'
          description: >-
            Invalid request. Common causes: - Mandatory fields are missing
            (cron_expression, time_zone, type) - Invalid cron expression format
            - Invalid time zone value - Invalid scheduling type (must be START,
            STOP, or RESTART) - Invalid intermediate_device Workspace ID format
        '401':
          $ref: '#/components/responses/Unauthorized'
          description: >-
            Unauthorized: user does not have access to the organization or the
            organization does not exist
        '404':
          $ref: '#/components/responses/NotFound'
          description: >-
            Workspace group not found or workspace group belongs to a different
            organization (after authorization)
        '409':
          $ref: '#/components/responses/Conflict'
          description: >-
            Conflict: scheduling with the same type, time, and day already
            exists (after time zone conversion)
        '422':
          $ref: '#/components/responses/UnprocessableEntity'
          description: >-
            Unprocessable entity. Common causes: - Intermediate_device Workspace
            ID does not exist or does not belong to the organization
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    CreateWorkspaceGroupScheduleRequestV1:
      type: object
      properties:
        cron_expression:
          type: string
          description: >-
            Cron expression defining when the schedule should run. Format:
            minute hour day-of-month month day-of-week. Examples: '0 8 * * 1-5'
            (8 AM on weekdays), '0 0 * * 0' (midnight on Sunday), '30 14 * * *'
            (2:30 PM daily). Day-of-week: 0=Sunday, 1=Monday, ..., 6=Saturday.
            Supports ranges (1-5), lists (1,3,5), and wildcards (*). Must be a
            valid cron expression format with 5 space-separated fields.
          example: 0 8 * * 1-5
        time_zone:
          type: string
          description: >-
            Timezone for the execution of the schedule. Supports IANA
            identifiers (e.g., 'America/New_York') and Windows identifiers
            (e.g., 'Pacific Standard Time').
          example: Eastern Standard Time
        type:
          type: string
          enum:
            - start
            - stop
            - restart
          description: >-
            Type of power operation to perform. START: Turns on the group's
            Workspaces. STOP: Turns off the group's Workspaces. RESTART:
            Restarts the group's Workspaces.
          example: start
        intermediate_device:
          type: string
          maxLength: 24
          pattern: ^[0-9a-f]{24}$
          description: >-
            Optional. The unique identifier of the intermediate device
            Workspace. If provided, indicates an intermediate device must be
            used for Wake on LAN operations. Only applicable for START
            schedules. Used for Wake on LAN actions in secure networks. The
            Workspace must exist and belong to the organization.
          example: 507f1f77bcf86cd799439050
      required:
        - cron_expression
        - time_zone
        - type
    WorkspaceGroupScheduleV1:
      type: object
      required:
        - id
        - cron_expression
        - time_zone
        - type
      properties:
        id:
          type: string
          pattern: ^[0-9a-f]{24}$
          description: The unique identifier of the schedule
          example: 507f1f77bcf86cd799439060
        cron_expression:
          type: string
          description: >-
            Cron expression defining when the schedule runs. Format: minute hour
            day-of-month month day-of-week.
          example: 0 8 * * 1-5
        time_zone:
          type: string
          description: >-
            Timezone for the execution of the schedule. Supports IANA
            identifiers (e.g., 'America/New_York') and Windows identifiers
            (e.g., 'Pacific Standard Time').
          example: Eastern Standard Time
        type:
          type: string
          enum:
            - start
            - stop
            - restart
          description: >-
            Power operation type: START (switch on), STOP (switch off), RESTART
            (restart Workspaces)
        intermediate_device:
          type: string
          pattern: ^[0-9a-f]{24}$
          nullable: true
          description: >-
            The unique identifier of the intermediate device Workspace, if
            configured. Used for Wake on LAN actions in secure networks.
          example: 507f1f77bcf86cd799439050
        created_by:
          type: string
          pattern: ^[0-9a-f]{24}$
          nullable: true
          description: User ID who created the schedule
          example: 507f1f77bcf86cd799439070
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
            details:
              type: string
          required:
            - message
            - code
      required:
        - error
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Conflict:
      description: Conflict
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UnprocessableEntity:
      description: Unprocessable Entity
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    TooManyRequests:
      description: Too Many Requests
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````