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

# Create a new schedule

> Creates a new schedule with a defined set of recurring time slots. Upon creation, the schedule's `active` status is automatically calculated based on the current time and the provided slots.



## OpenAPI

````yaml /api/en/schedules.yaml post /chrono/schedules
openapi: 3.0.3
info:
  title: Altostrat Schedules API
  version: 1.0.0
  description: >-
    The Altostrat Schedules API provides a time-based scheduling engine to
    control when automation policies and network configurations are active.


    It is a key component of the Altostrat SDX platform, enabling developers to
    implement time-of-day routing, enforce bandwidth limits during business
    hours, or activate specific security policies on a recurring basis for their
    MikroTik networks.


    This API allows you to programmatically manage:

    - **Schedules:** The top-level containers for a set of time-based rules,
    each with a specific timezone.

    - **Time Slots:** The recurring weekly time ranges (e.g., Monday
    09:00-17:00) during which a schedule is considered 'active'.

    - **Metadata:** Custom key-value pairs that can be attached to a schedule to
    integrate with other automation systems.


    Developers use this API to create and manage the temporal logic that governs
    how and when their network automation and AI-driven policies are applied.
servers:
  - url: https://v1.api.altostrat.io
security:
  - BearerAuth: []
tags:
  - name: Schedules
    description: Manage schedules, their time slots, and associated metadata.
paths:
  /chrono/schedules:
    post:
      tags:
        - Schedules
      summary: Create a new schedule
      description: >-
        Creates a new schedule with a defined set of recurring time slots. Upon
        creation, the schedule's `active` status is automatically calculated
        based on the current time and the provided slots.
      operationId: createSchedule
      requestBody:
        description: The details of the schedule to create.
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ScheduleRequest'
      responses:
        '201':
          description: The schedule was created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Schedule'
        '400':
          description: Bad Request - The request was malformed or failed validation.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Authentication information is missing or invalid.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal Server Error - An unexpected error occurred on the server.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ScheduleRequest:
      type: object
      description: The request body for creating or updating a schedule.
      required:
        - name
        - hours
      properties:
        name:
          type: string
          description: The name of the schedule. Must be unique within your workspace.
          example: Weekend Maintenance Window
          maxLength: 200
        timezone:
          type: string
          description: >-
            An IANA Time Zone Database name, e.g., `America/New_York` or `UTC`.
            If not provided, the workspace default will be used.
          example: America/New_York
        hours:
          type: array
          description: >-
            An array of time slot objects. This array will completely replace
            any existing time slots on an update.
          items:
            $ref: '#/components/schemas/SlotRequest'
          maxItems: 50
        metadata:
          type: array
          description: >-
            An array of key-value pairs. On update, provide a key with a `null`
            value to delete it. New keys will be added, and existing keys will
            be updated.
          items:
            $ref: '#/components/schemas/MetadataRequest'
          maxItems: 50
    Schedule:
      type: object
      description: >-
        Represents a schedule object that defines when a policy or configuration
        is active.
      properties:
        id:
          type: string
          format: uuid
          description: The unique identifier for the schedule.
          example: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
        name:
          type: string
          description: A human-readable name for the schedule.
          example: Business Hours Policy
        timezone:
          type: string
          description: >-
            The IANA timezone identifier that this schedule operates in. All
            `start` and `end` times are relative to this timezone.
          example: Australia/Sydney
        active:
          type: boolean
          description: >-
            A read-only flag indicating whether the schedule is currently within
            an active time slot. This is calculated by the system.
          example: true
        updated_at:
          type: string
          format: date-time
          description: The timestamp of when the schedule was last updated.
          example: '2025-10-29T01:43:31Z'
        created_at:
          type: string
          format: date-time
          description: The timestamp of when the schedule was created.
          example: '2025-10-29T01:43:31Z'
        hours:
          type: array
          description: >-
            A list of time slots that define the active periods for this
            schedule.
          items:
            $ref: '#/components/schemas/Slot'
        metadata:
          type: array
          description: >-
            A list of key-value pairs that can be used to store additional
            information about the schedule.
          items:
            $ref: '#/components/schemas/Metadata'
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          description: A broad category for the error (e.g., 'invalid_request_error').
          example: invalid_request_error
        code:
          type: string
          description: A short, unique string identifying the specific error.
          example: parameter_invalid
        message:
          type: string
          description: A human-readable description of what went wrong.
          example: The 'timezone' parameter must be a valid IANA Time Zone.
        doc_url:
          type: string
          description: >-
            A direct link to the documentation page for this specific error
            code.
          example: https://docs.altostrat.io/errors/parameter_invalid
    SlotRequest:
      type: object
      description: Defines a time slot for a schedule request.
      required:
        - day
        - start
        - end
      properties:
        day:
          type: string
          description: The day of the week.
          enum:
            - sunday
            - monday
            - tuesday
            - wednesday
            - thursday
            - friday
            - saturday
          example: saturday
        start:
          type: string
          description: The start time in `HH:mm` format.
          example: '22:00'
        end:
          type: string
          description: The end time in `HH:mm` format. Must be after the start time.
          example: '23:59'
    MetadataRequest:
      type: object
      description: Defines a metadata entry for a schedule request.
      required:
        - key
        - value
      properties:
        key:
          type: string
          description: >-
            The metadata key. Maximum 50 characters, must be unique within the
            schedule's metadata.
          example: ticket_ref
          maxLength: 50
        value:
          type: string
          nullable: true
          description: >-
            The metadata value. Maximum 200 characters. Providing `null` for an
            existing key will delete the metadata entry.
          example: JIRA-456
          maxLength: 200
    Slot:
      type: object
      description: A specific time range on a given day of the week.
      properties:
        day:
          type: string
          description: The day of the week for this time slot.
          enum:
            - sunday
            - monday
            - tuesday
            - wednesday
            - thursday
            - friday
            - saturday
          example: monday
        start:
          type: string
          description: The start time of the slot in `HH:mm` format (24-hour clock).
          example: '09:00'
        end:
          type: string
          description: The end time of the slot in `HH:mm` format (24-hour clock).
          example: '17:00'
    Metadata:
      type: object
      description: A key-value pair for storing custom data.
      properties:
        key:
          type: string
          description: The metadata key. Maximum 50 characters.
          example: policy_id
        value:
          type: string
          description: The metadata value. Maximum 200 characters.
          example: pol_12345
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'Enter your API key in the format: Bearer {key}'

````