schedules resource on the Figranium Swift 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 struct, which supports interval, hourly, daily, weekly, monthly, and raw cron expressions.
SchedulesResource.swift
Schedule struct
ASchedule struct controls whether and how often a task runs automatically.
Schedule.swift
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 supplycrondirectly.intervalMinutes: required whenfrequencyis"interval".hourandminute: used with"daily","weekly", and"monthly"to set the time of day.daysOfWeek: array of weekday numbers (0= Sunday) for"weekly".dayOfMonth: day number (1to31) 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.swift
weekly_schedule.swift
cron_schedule.swift
Methods
list
list
Retrieve all tasks that currently have a schedule configured.Returns a
- HTTP endpoint:
GET /api/schedules - Signature:
func list(options: RequestOptions = .init()) async throws -> JSONObject
list_schedules.swift
JSONObject with a schedules array. Each entry contains taskId, taskName, mode, and the attached Schedule object.set
set
Attach or update a schedule for a specific task.Returns a
- HTTP endpoint:
POST /api/schedules/{taskId} - Signature:
func set(_ taskID: String, schedule: Schedule, options: RequestOptions = .init()) async throws -> JSONObject
set_schedule.swift
JSONObject containing the saved schedule, a human-readable description, and the nextRun timestamp (or nil if the schedule is disabled or invalid).delete
delete
Remove a task’s schedule entirely.Returns
- HTTP endpoint:
DELETE /api/schedules/{taskId} - Signature:
func delete(_ taskID: String, options: RequestOptions = .init()) async throws -> JSONObject
delete_schedule.swift
{"success": bool} indicating whether the schedule was removed.status
status
Inspect the current schedule for a single task, including its computed cron expression and validity.Returns a
- HTTP endpoint:
GET /api/schedules/{taskId}/status - Signature:
func status(_ taskID: String, options: RequestOptions = .init()) async throws -> JSONObject
schedule_status.swift
JSONObject with the current schedule, the resolved cron string, a human-readable description, and an isValid flag.describe
describe
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 Returns a
set.- HTTP endpoint:
POST /api/schedules/{taskId}/describe - Signature:
func describe(_ taskID: String, schedule: Schedule, options: RequestOptions = .init()) async throws -> JSONObject
describe_schedule.swift
JSONObject with valid, description, cron, and nextRun. If valid is false, the schedule will not be accepted by set.overallStatus
overallStatus
Get a high-level view of the scheduler state across all tasks.Returns a plain
- HTTP endpoint:
GET /api/schedules/status/all - Signature:
func overallStatus(options: RequestOptions = .init()) async throws -> JSONObject
overall_status.swift
JSONObject. The exact fields depend on the server version; inspect the response to discover available keys.Error handling
Schedule methods throwFigraniumError on failure. Common cases include a missing task ID (404) or an invalid schedule payload (400). See Error handling for retry guidance and error codes.
Related resources
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 FigraniumError responses.