Skip to main content
The schedules resource on the Figranium Kotlin SDK lets you automate when tasks run. You can list every scheduled task, attach a recurring schedule to a specific task, delete it, validate a schedule before applying it, and inspect the overall scheduler health. All schedule payloads use the shared Schedule data class, which supports interval, hourly, daily, weekly, monthly, and raw cron expressions.
SchedulesResource.kt

Schedule data class

A Schedule value controls whether and how often a task runs automatically.
Schedule.kt
  • enabled: whether the schedule is active.
  • frequency: the recurrence pattern. Use "interval" for a simple minute-based timer, "hourly" / "daily" / "weekly" / "monthly" for calendar-based runs, or omit it and supply cron directly.
  • intervalMinutes: required when frequency is "interval".
  • hour and minute: used with "daily", "weekly", and "monthly" to set the time of day.
  • daysOfWeek: list of weekday numbers (0 = Sunday) for "weekly".
  • dayOfMonth: day number (1 to 31) for "monthly".
  • cron: a raw cron string when you need full control.
  • lastRun, lastRunStatus, lastRunDurationMs, nextRun: read-only fields returned by the server.

Examples

Run a task every 15 minutes:
interval_schedule.kt
Run a task every Monday and Wednesday at 09:30:
weekly_schedule.kt
Run a task daily at 07:00 with a cron expression:
cron_schedule.kt

Methods

Retrieve all tasks that currently have a schedule configured.
  • HTTP endpoint: GET /api/schedules
  • Signature: suspend fun list(options: RequestOptions = RequestOptions()): JsonObject
list_schedules.kt
Returns a JsonObject with a schedules array. Each entry contains taskId, taskName, mode, and the attached Schedule object.
Attach or update a schedule for a specific task.
  • HTTP endpoint: POST /api/schedules/{taskId}
  • Signature: suspend fun set(taskId: String, schedule: Schedule, options: RequestOptions = RequestOptions()): JsonObject
set_schedule.kt
Returns a JsonObject containing the saved schedule, a human-readable description, and the nextRun timestamp (or null if the schedule is disabled or invalid).
Remove a task’s schedule entirely.
  • HTTP endpoint: DELETE /api/schedules/{taskId}
  • Signature: suspend fun delete(taskId: String, options: RequestOptions = RequestOptions()): JsonObject
delete_schedule.kt
Returns {"success": bool} indicating whether the schedule was removed.
Inspect the current schedule for a single task, including its computed cron expression and validity.
  • HTTP endpoint: GET /api/schedules/{taskId}/status
  • Signature: suspend fun status(taskId: String, options: RequestOptions = RequestOptions()): JsonObject
schedule_status.kt
Returns a JsonObject with the current schedule, the resolved cron string, a human-readable description, and an isValid flag.
Validate a schedule payload for a task without saving it. This is useful for previewing the next run time and confirming a cron expression before you call set.
  • HTTP endpoint: POST /api/schedules/{taskId}/describe
  • Signature: suspend fun describe(taskId: String, schedule: Schedule, options: RequestOptions = RequestOptions()): JsonObject
describe_schedule.kt
Returns a JsonObject with valid, description, cron, and nextRun. If valid is false, the schedule will not be accepted by set.
Get a high-level view of the scheduler state across all tasks.
  • HTTP endpoint: GET /api/schedules/status/all
  • Signature: suspend fun overallStatus(options: RequestOptions = RequestOptions()): JsonObject
overall_status.kt
Returns a plain JsonObject. The exact fields depend on the server version; inspect the response to discover available keys.

Error handling

Schedule methods throw FigraniumException on failure. Common cases include a missing task ID (404) or an invalid schedule payload (400). See Errors for retry guidance and error codes.

Tasks

Create and manage the tasks you schedule.

Executions

Inspect the runs produced by scheduled tasks.

Request options

Pass custom headers and per-request timeouts.

Task scheduling

Learn how scheduling works in Figranium.

Errors

Handle FigraniumException responses.