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

# Create Schedule

> Create a new scheduled HTTP request with cron expression timing.



## OpenAPI

````yaml POST /schedules
openapi: 3.1.0
info:
  title: Cronhost API
  description: >-
    Schedule HTTP requests with cron expressions. Cronhost allows you to
    automate HTTP requests on a schedule using familiar cron syntax.
  license:
    name: MIT
  version: 1.0.0
  contact:
    name: Cronhost Support
    email: help@cronho.st
    url: https://cronho.st
servers:
  - url: https://cronho.st/api/v1
    description: Production API
security:
  - apiKeyAuth: []
tags:
  - name: Schedules
    description: Create, manage, and control scheduled HTTP requests
  - name: Jobs
    description: Monitor and retrieve job execution details
paths:
  /schedules:
    post:
      tags:
        - Schedules
      summary: Create Schedule
      description: Create a new scheduled HTTP request with cron expression timing.
      operationId: createSchedule
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateScheduleRequest'
            examples:
              getRequest:
                summary: GET request example
                value:
                  name: Daily Health Check
                  description: Check API health every day at 9 AM
                  cronExpression: 0 9 * * *
                  timezone: America/New_York
                  endpoint: https://api.example.com/health
                  httpMethod: GET
                  headers: '{"User-Agent": "Cronhost-Monitor"}'
                  maxRetries: 3
                  timeoutSeconds: 30
              postRequest:
                summary: POST request example
                value:
                  name: Weekly Report
                  description: Send weekly report every Monday at 8 AM
                  cronExpression: 0 8 * * 1
                  timezone: UTC
                  endpoint: https://api.example.com/reports
                  httpMethod: POST
                  body: '{"reportType": "weekly", "format": "json"}'
                  headers: >-
                    {"Content-Type": "application/json", "Authorization":
                    "Bearer token"}
                  maxRetries: 2
                  timeoutSeconds: 60
      responses:
        '201':
          description: Schedule created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/Schedule'
                  success:
                    type: boolean
                    example: true
                required:
                  - data
                  - success
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    CreateScheduleRequest:
      type: object
      required:
        - name
        - cronExpression
        - timezone
        - endpoint
        - httpMethod
      properties:
        name:
          type: string
          description: Human-readable schedule name
          example: Daily Health Check
          minLength: 1
          maxLength: 255
        description:
          type: string
          description: Optional description of what the schedule does
          example: Check API health every day at 9 AM
          maxLength: 1000
        cronExpression:
          type: string
          description: Valid cron expression defining when to run
          example: 0 9 * * *
        timezone:
          type: string
          description: IANA timezone identifier
          example: America/New_York
        endpoint:
          type: string
          format: uri
          description: Target HTTP endpoint URL
          example: https://api.example.com/health
        httpMethod:
          type: string
          enum:
            - GET
            - POST
            - PUT
            - DELETE
            - PATCH
          description: HTTP method to use for the request
          example: GET
        body:
          type: string
          description: Request body for POST/PUT/PATCH requests
          example: '{"key": "value"}'
        headers:
          type: string
          description: HTTP headers as JSON string
          example: >-
            {"User-Agent": "Cronhost-Monitor", "Content-Type":
            "application/json"}
        maxRetries:
          type: integer
          minimum: 0
          maximum: 10
          description: Maximum number of retry attempts
          example: 3
          default: 3
        timeoutSeconds:
          type: integer
          minimum: 1
          maximum: 300
          description: Request timeout in seconds
          example: 30
          default: 30
    Schedule:
      type: object
      required:
        - id
        - name
        - cronExpression
        - timezone
        - endpoint
        - httpMethod
        - isEnabled
        - nextRunAtUtc
        - createdAt
        - updatedAt
        - maxRetries
        - timeoutSeconds
      properties:
        id:
          type: string
          description: Unique schedule identifier
          example: schedule_123
        name:
          type: string
          description: Human-readable schedule name
          example: Daily Health Check
        description:
          type: string
          nullable: true
          description: Optional description of what the schedule does
          example: Check API health every day at 9 AM
        cronExpression:
          type: string
          description: Valid cron expression defining when to run
          example: 0 9 * * *
          pattern: >-
            ^\s*($|#|\w+\s*=|(\?|\*|(?:[0-5]?\d)(?:(?:-|\/|\,)(?:[0-5]?\d))?(?:,(?:[0-5]?\d)(?:(?:-|\/|\,)(?:[0-5]?\d))?)*)\s+(\?|\*|(?:[0-5]?\d)(?:(?:-|\/|\,)(?:[0-5]?\d))?(?:,(?:[0-5]?\d)(?:(?:-|\/|\,)(?:[0-5]?\d))?)*)\s+(\?|\*|(?:[01]?\d|2[0-3])(?:(?:-|\/|\,)(?:[01]?\d|2[0-3]))?(?:,(?:[01]?\d|2[0-3])(?:(?:-|\/|\,)(?:[01]?\d|2[0-3]))?)*)\s+(\?|\*|(?:0?[1-9]|[12]\d|3[01])(?:(?:-|\/|\,)(?:0?[1-9]|[12]\d|3[01]))?(?:,(?:0?[1-9]|[12]\d|3[01])(?:(?:-|\/|\,)(?:0?[1-9]|[12]\d|3[01]))?)*)\s+(\?|\*|(?:[1-9]|1[012])(?:(?:-|\/|\,)(?:[1-9]|1[012]))?(?:L|W)?(?:,(?:[1-9]|1[012])(?:(?:-|\/|\,)(?:[1-9]|1[012]))?(?:L|W)?)*|\?|\*|(?:JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(?:(?:-)(?:JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?(?:,(?:JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)(?:(?:-)(?:JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))?)*)\s+(\?|\*|(?:[0-6])(?:(?:-|\/|\,|#)(?:[0-6]))?(?:L)?(?:,(?:[0-6])(?:(?:-|\/|\,|#)(?:[0-6]))?(?:L)?)*|\?|\*|(?:MON|TUE|WED|THU|FRI|SAT|SUN)(?:(?:-)(?:MON|TUE|WED|THU|FRI|SAT|SUN))?(?:,(?:MON|TUE|WED|THU|FRI|SAT|SUN)(?:(?:-)(?:MON|TUE|WED|THU|FRI|SAT|SUN))?)*)(|\s)+(\?|\*|(?:|\d{4})(?:(?:-|\/|\,)(?:|\d{4}))?(?:,(?:|\d{4})(?:(?:-|\/|\,)(?:|\d{4}))?)*))$
        timezone:
          type: string
          description: IANA timezone identifier
          example: America/New_York
        endpoint:
          type: string
          format: uri
          description: Target HTTP endpoint URL
          example: https://api.example.com/health
        httpMethod:
          type: string
          enum:
            - GET
            - POST
            - PUT
            - DELETE
            - PATCH
          description: HTTP method to use for the request
          example: GET
        body:
          type: string
          nullable: true
          description: Request body for POST/PUT/PATCH requests
          example: '{"key": "value"}'
        headers:
          type: string
          nullable: true
          description: HTTP headers as JSON string
          example: >-
            {"User-Agent": "Cronhost-Monitor", "Content-Type":
            "application/json"}
        isEnabled:
          type: boolean
          description: Whether the schedule is currently active
          example: true
        nextRunAtUtc:
          type: string
          format: date-time
          nullable: true
          description: Next scheduled execution time in UTC
          example: '2024-01-15T14:00:00.000Z'
        lastRunAtUtc:
          type: string
          format: date-time
          nullable: true
          description: Last execution time in UTC
          example: '2024-01-14T14:00:00.000Z'
        createdAt:
          type: string
          format: date-time
          description: Schedule creation timestamp
          example: '2024-01-01T12:00:00.000Z'
        updatedAt:
          type: string
          format: date-time
          description: Last modification timestamp
          example: '2024-01-14T14:00:00.000Z'
        maxRetries:
          type: integer
          minimum: 0
          maximum: 10
          description: Maximum number of retry attempts
          example: 3
        timeoutSeconds:
          type: integer
          minimum: 1
          maximum: 300
          description: Request timeout in seconds
          example: 30
    ApiError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - code
          properties:
            message:
              type: string
              description: Human-readable error message
            code:
              type: string
              description: Error code for programmatic handling
            details:
              description: Additional error details
  responses:
    ValidationError:
      description: Validation error occurred
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          example:
            error:
              message: Validation error
              code: VALIDATION_ERROR
              details:
                fieldErrors:
                  cronExpression:
                    - Invalid cron expression
                  endpoint:
                    - Must be a valid URL
    UnauthorizedError:
      description: Authentication failed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          examples:
            missingApiKey:
              summary: Missing API key
              value:
                error:
                  message: API key is required
                  code: MISSING_API_KEY
            invalidApiKey:
              summary: Invalid API key
              value:
                error:
                  message: Invalid API key
                  code: INVALID_API_KEY
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
          example:
            error:
              message: Internal server error
              code: INTERNAL_ERROR
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: >-
        API key for authentication. Get your API key from the [Cronhost
        dashboard](https://cronho.st/settings).

````