Skip to main content

Create Schedule

Endpoint: POST /api/scheduler/schedules

Creates a new schedule with the specified name. If a schedule with the same name already exists, this operation updates the existing schedule.

Request body

ParameterDescriptionTypeRequired/ Optional
nameThe name of the schedule. Must be alphanumeric and can include underscores.stringRequired.
descriptionA description of the schedule.stringOptional.
cronExpressionA 6-field string defining the cadence using cron syntax. An asterisk * denotes a blank entry.

* * * * * *

The fields, from left to right, are: Second (0-59), Minute (0-59), Hour (0-23), Day of Month (1-31), Month (1-12 or JAN-DEC), Day of Week (1-7 or MON-SUN). For more configuration details, refer Using cron expression.
stringRequired.
zoneIdThe timezone in which the schedule runs. For example UTCor Asia/Dubai.stringRequired.
startWorkflowRequestA JSON object containing the details of the workflow to be scheduled.objectRequired.
startWorkflowRequest. nameThe name of the workflow to run. The creator of the schedule must have execute permission for this workflow.stringRequired.
startWorkflowRequest. versionThe version of the workflow to run. If not specified, the latest version will be used.stringOptional.
startWorkflowRequest. inputThe input parameters for the workflow, provided as a JSON object.objectOptional.
startWorkflowRequest. correlationIdA unique identifier for the workflow execution, used to correlate the current workflow instance with other workflows.stringOptional.
startWorkflowRequest. idempotencyKeyA unique, user-generated key to prevent duplicate workflow executions. Idempotency data is retained throughout the life of the workflow execution.stringOptional.
startWorkflowRequest. idempotencyStrategyThe idempotency strategy for handling duplicate requests. Supported values:
  • RETURN_EXISTING: Return the workflowId of the workflow instance with the same idempotency key.
  • FAIL: Start a new workflow instance only if there are no workflow executions with the same idempotency key.
  • FAIL_ON_RUNNING: Start a new workflow instance only if there are no RUNNING or PAUSED workflows with the same idempotency key. Completed workflows can run again.
string (enum)Required if idempotencyKey is used.
startWorkflowRequest. priorityThe priority of the workflow. Supports values from 0-99.stringOptional.
startWorkflowRequest. taskToDomainA mapping of task reference names to domain-specific values to route the task to defined workers.objectOptional.
scheduleStartTimeThe start time for the schedule in Unix timestamp format (in milliseconds), based on the local timezone.number (long/int64)Optional.
scheduleEndTimeThe end time for the schedule in Unix timestamp format (in milliseconds), based on the local timezone.number (long/int64)Optional.
pausedWhether the schedule is paused upon saving. If set to true, the schedule will not run. Set to false to start the schedule immediately upon saving. Default is false.booleanOptional.
runCatchupScheduleInstancesIf true, executes any pending schedules, such as when the server starts after downtime.booleanOptional.

Response

Returns 200 OK, indicating that the schedule has been created successfully.

Examples

Create a new schedule

Request

curl -X 'POST' \
'https://<YOUR-CLUSTER>/api/scheduler/schedules' \
-H 'accept: application/json' \
-H 'X-Authorization: <TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"paused": false,
"runCatchupScheduleInstances": false,
"name": "assignPRSchedule",
"description": "Schedule for automating PR assignment workflow.",
"cronExpression": "0 0 * ? * *",
"scheduleStartTime": 1770354000000,
"scheduleEndTime": 1774933200000,
"startWorkflowRequest": {
"name": "github_pr_reviewer_assignment",
"version": "",
"input": {},
"correlationId": "",
"idempotencyKey": "123",
"idempotencyStrategy": "RETURN_EXISTING",
"taskToDomain": {},
"priority": ""
},
"zoneId": "Asia/Dubai"
}'

Response

Returns 200 OK, indicating that the schedule has been created successfully.