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

# Create a schedule

> Creates a new scheduled task that will automatically run the agent based on the specified schedule.

**Schedule Types:**
- **CRON (3)**: Use cronExpression to define a recurring schedule
- **RunOnce (1)**: Requires startTime (must be at least 1 minute in the future) - runs once at the specified date/time
- **RunEvery (2)**: Uses runEveryCount and runEveryPeriod (0=minutes, 1=hours, 2=days, 3=weeks, 4=months). Optional startTime for first run (must be in the future if provided).

**StartTime Validation:**
- For **RunOnce**: Required. Must be at least 1 minute in the future (UTC).
- For **RunEvery**: Optional. If provided, must be in the future (UTC). Determines when the first run occurs.
- For **CRON**: Not used. Schedule is determined by cronExpression.

**CRON Schedule Example:**
```json
{
    "name": "Daily Morning Run",
    "scheduleType": 3,
    "cronExpression": "0 9 * * 1,4",
    "timezone": "America/New_York",
    "isEnabled": true
}
```

**Run Once Example:**
```json
{
    "name": "One-time Run",
    "scheduleType": 1,
    "startTime": "2026-01-20T14:30:00Z",
    "timezone": "America/New_York",
    "isEnabled": true
}
```

**Run Every Example (every 30 minutes):**
```json
{
    "name": "Frequent Check",
    "scheduleType": 2,
    "runEveryCount": 30,
    "runEveryPeriod": 0,
    "startTime": "2026-01-17T10:00:00Z",
    "timezone": "America/Denver",
    "isEnabled": true
}
```

**Encrypted input parameters**

Prefix a parameter name with `?` to have its value encrypted at rest and hidden in
the Run log — for example `"?apiKey"` instead of `"apiKey"`. The name you send decides
this. Sending a name without the `?` prefix stores and logs the value in clear text,
**even when the Agent defines that parameter as encrypted**. Omitting a parameter
entirely leaves the Agent's own definition in effect, encryption included.

If you send both `"name"` and `"?name"`, the `?`-prefixed entry is used and the plain
one is discarded. The request still succeeds.

A Schedule stores its input parameters, so a clear-text value is also returned in
clear text by `GET /api/v1/agent/{agentId}/schedules` to any caller with an API key
and read access to the Agent's Space. Send `?name` for anything sensitive.

Call `GET /api/v1/agent/{agentId}/input-parameters` to see which parameters an Agent
defines as encrypted.



## OpenAPI

````yaml POST /api/v1/agent/{agentId}/schedules
openapi: 3.0.1
info:
  title: Sequentum Cloud API
  description: API endpoints for Sequentum Cloud
  version: v1
servers: []
security:
  - ApiKey: []
    Bearer: []
paths:
  /api/v1/agent/{agentId}/schedules:
    post:
      tags:
        - ApiAgent
      summary: Create a new schedule for an agent
      description: >-
        Creates a new scheduled task that will automatically run the agent based
        on the specified schedule.


        **Schedule Types:**

        - **CRON (3)**: Use cronExpression to define a recurring schedule

        - **RunOnce (1)**: Requires startTime (must be at least 1 minute in the
        future) - runs once at the specified date/time

        - **RunEvery (2)**: Uses runEveryCount and runEveryPeriod (0=minutes,
        1=hours, 2=days, 3=weeks, 4=months). Optional startTime for first run
        (must be in the future if provided).


        **StartTime Validation:**

        - For **RunOnce**: Required. Must be at least 1 minute in the future
        (UTC).

        - For **RunEvery**: Optional. If provided, must be in the future (UTC).
        Determines when the first run occurs.

        - For **CRON**: Not used. Schedule is determined by cronExpression.


        **CRON Schedule Example:**

        ```json

        {
            "name": "Daily Morning Run",
            "scheduleType": 3,
            "cronExpression": "0 9 * * 1,4",
            "timezone": "America/New_York",
            "isEnabled": true
        }

        ```


        **Run Once Example:**

        ```json

        {
            "name": "One-time Run",
            "scheduleType": 1,
            "startTime": "2026-01-20T14:30:00Z",
            "timezone": "America/New_York",
            "isEnabled": true
        }

        ```


        **Run Every Example (every 30 minutes):**

        ```json

        {
            "name": "Frequent Check",
            "scheduleType": 2,
            "runEveryCount": 30,
            "runEveryPeriod": 0,
            "startTime": "2026-01-17T10:00:00Z",
            "timezone": "America/Denver",
            "isEnabled": true
        }

        ```


        **Encrypted input parameters**


        Prefix a parameter name with `?` to have its value encrypted at rest and
        hidden in

        the Run log — for example `"?apiKey"` instead of `"apiKey"`. The name
        you send decides

        this. Sending a name without the `?` prefix stores and logs the value in
        clear text,

        **even when the Agent defines that parameter as encrypted**. Omitting a
        parameter

        entirely leaves the Agent's own definition in effect, encryption
        included.


        If you send both `"name"` and `"?name"`, the `?`-prefixed entry is used
        and the plain

        one is discarded. The request still succeeds.


        A Schedule stores its input parameters, so a clear-text value is also
        returned in

        clear text by `GET /api/v1/agent/{agentId}/schedules` to any caller with
        an API key

        and read access to the Agent's Space. Send `?name` for anything
        sensitive.


        Call `GET /api/v1/agent/{agentId}/input-parameters` to see which
        parameters an Agent

        defines as encrypted.
      parameters:
        - name: agentId
          in: path
          description: The ID of the agent
          required: true
          schema:
            type: integer
            format: int32
      requestBody:
        description: The schedule configuration
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateScheduleApiRequest'
          text/json:
            schema:
              $ref: '#/components/schemas/CreateScheduleApiRequest'
          application/*+json:
            schema:
              $ref: '#/components/schemas/CreateScheduleApiRequest'
      responses:
        '200':
          description: Returns the created schedule
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AgentScheduleApiModel'
        '400':
          description: If the request is invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BadRequestError'
        '401':
          description: If the API key is missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '404':
          description: If the agent is not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '429':
          description: Too Many Requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
components:
  schemas:
    CreateScheduleApiRequest:
      type: object
      properties:
        name:
          type: string
          description: Name of the schedule (required)
          nullable: true
        cronExpression:
          type: string
          description: >-
            Cron expression for the schedule (e.g., "0 9 * * 1,4" for Mon/Thu at
            9am)
          nullable: true
        localSchedule:
          type: string
          description: Local schedule expression (human readable)
          nullable: true
        timezone:
          type: string
          description: Timezone for the schedule (e.g., "America/New_York")
          nullable: true
        startTime:
          type: string
          description: "Start date/time for the schedule in UTC.\r\n- Required for RunOnce schedules (must be at least 1 minute in the future).\r\n- Optional for RunEvery schedules (if provided, must be in the future; determines when the first run occurs).\r\n- Not used for CRON schedules."
          format: date-time
          nullable: true
          example: '2026-01-20T14:30:00Z'
        inputParameters:
          type: string
          description: JSON string of input parameters for scheduled runs
          nullable: true
        scheduleType:
          $ref: '#/components/schemas/ScheduleType'
        isEnabled:
          type: boolean
          description: Whether the schedule is enabled
        runEveryCount:
          type: integer
          description: Run every N periods (used with RunEveryPeriod)
          format: int32
          nullable: true
        runEveryPeriod:
          type: integer
          description: >-
            Period unit for RunEveryCount (1=minutes, 2=hours, 3=days, 4=weeks,
            5=months)
          format: int32
          nullable: true
        parallelism:
          type: integer
          description: Parallelism level for the scheduled run
          format: int32
          nullable: true
        parallelMaxConcurrency:
          type: integer
          description: Max concurrency for parallel runs
          format: int32
          nullable: true
        parallelExport:
          $ref: '#/components/schemas/ParallelExport'
        proxyPoolId:
          type: integer
          description: Proxy pool ID to use for scheduled runs
          format: int32
          nullable: true
        serverGroupId:
          type: integer
          description: "Server group ID for scheduled runs (optional).\r\nWhen specified, the schedule will run on servers in this group."
          format: int32
          nullable: true
        logLevel:
          $ref: '#/components/schemas/LogLevel'
        logMode:
          $ref: '#/components/schemas/LogMode'
        isExclusive:
          type: boolean
          description: Whether to run exclusively (no concurrent runs)
        isWaitOnFailure:
          type: boolean
          description: Whether to wait on failure before retrying
      additionalProperties: false
      description: Request model for creating a new schedule
    AgentScheduleApiModel:
      type: object
      properties:
        id:
          type: integer
          format: int64
        configId:
          type: integer
          format: int32
        name:
          type: string
          nullable: true
        schedule:
          type: string
          nullable: true
        localSchedule:
          type: string
          nullable: true
        timezone:
          type: string
          nullable: true
        nextRunTime:
          type: string
          format: date-time
          nullable: true
        startTime:
          type: string
          format: date-time
          nullable: true
        scheduleType:
          $ref: '#/components/schemas/ScheduleType'
        isEnabled:
          type: boolean
        runEveryCount:
          type: integer
          format: int32
          nullable: true
        runEveryPeriod:
          type: integer
          format: int32
          nullable: true
        inputParameters:
          type: string
          nullable: true
        parallelism:
          type: integer
          format: int32
          nullable: true
        parallelMaxConcurrency:
          type: integer
          format: int32
          nullable: true
        parallelExport:
          $ref: '#/components/schemas/ParallelExport'
        proxyPoolId:
          type: integer
          format: int32
          nullable: true
        serverGroupId:
          type: integer
          format: int32
          nullable: true
        logLevel:
          $ref: '#/components/schemas/LogLevel'
        logMode:
          $ref: '#/components/schemas/LogMode'
        isExclusive:
          type: boolean
        isWaitOnFailure:
          type: boolean
        created:
          type: string
          format: date-time
        updated:
          type: string
          format: date-time
      additionalProperties: false
      description: Represents a scheduled task for an agent in the External API
    BadRequestError:
      type: object
      properties:
        statusCode:
          type: integer
          format: int32
        statusDescription:
          type: string
          nullable: true
        message:
          type: string
          nullable: true
          readOnly: true
        severity:
          $ref: '#/components/schemas/ErrorSeverity'
        errorCode:
          type: string
          description: "Optional machine-readable error code. When present, clients should switch on this\r\nvalue rather than parsing Sequentum.Enterprise.Core.ControllerError.Message. Omitted from the response when null."
          nullable: true
      additionalProperties: false
    ProblemDetails:
      type: object
      properties:
        type:
          type: string
          nullable: true
        title:
          type: string
          nullable: true
        status:
          type: integer
          format: int32
          nullable: true
        detail:
          type: string
          nullable: true
        instance:
          type: string
          nullable: true
      additionalProperties: {}
    ScheduleType:
      enum:
        - 0
        - 1
        - 2
        - 3
      type: integer
      description: '`0` = `None`; `1` = `RunOnce`; `2` = `RunEvery`; `3` = `CRON`'
      format: int32
    ParallelExport:
      enum:
        - Combined
        - Separated
      type: string
      description: '`0` = `Combined`; `1` = `Separated`'
    LogLevel:
      enum:
        - Fatal
        - Error
        - Warning
        - Info
      type: string
      description: '`0` = `Fatal`; `1` = `Error`; `2` = `Warning`; `3` = `Info`'
    LogMode:
      enum:
        - Text
        - TextAndHtml
      type: string
      description: '`0` = `Text`; `1` = `TextAndHtml`'
    ErrorSeverity:
      enum:
        - 0
        - 1
        - 2
        - 3
        - 4
      type: integer
      description: >-
        `0` = `Error`; `1` = `Unexpected`; `2` = `Fatal`; `3` = `Warning`; `4` =
        `Info`
      format: int32
  securitySchemes:
    ApiKey:
      type: apiKey
      description: >-
        API Key authorization header. Example: "Authorization: ApiKey
        {your-api-key}"
      name: Authorization
      in: header
    Bearer:
      type: http
      description: 'OAuth 2.0 Bearer token. Example: "Authorization: Bearer {access-token}"'
      scheme: bearer
      bearerFormat: JWT

````