Scheduler API
Manage recurring tasks via the scheduler endpoints.
Scheduler API
CodeSpar includes a built-in task scheduler for recurring operations like health checks, build status reports, and audit cleanup. You can list, pause, resume, and cancel scheduled tasks via the API.
List All Tasks
Retrieve all registered scheduled tasks and their current state.
Request
Response
Response Schema
| Field | Type | Description |
|---|---|---|
name | string | Unique task identifier |
intervalMs | number | Interval between runs in milliseconds |
lastRun | string | ISO 8601 timestamp of the last execution (null if never run) |
nextRun | string | ISO 8601 timestamp of the next scheduled execution |
runCount | number | Total number of completed runs |
errors | number | Total number of failed runs |
enabled | boolean | Whether the task is currently active |
Pause a Task
Temporarily stop a scheduled task from running. The task retains its state and can be resumed later.
Request
Response
Resume a Task
Resume a previously paused task. It will run at the next scheduled interval.
Request
Response
Cancel a Task
Permanently remove a scheduled task. This cannot be undone. Built-in tasks will be re-registered on server restart.
Request
Response
Built-in Tasks
CodeSpar registers these tasks automatically on startup:
| Task | Interval | Description |
|---|---|---|
health-check | 5 minutes | Verifies agent connectivity, channel status, and system health. Logs warnings if any component is degraded. |
build-status-report | 24 hours | Collects build status from linked GitHub repos and stores a summary. Used by the @codespar status build command. |
audit-cleanup | 24 hours | Removes expired audit entries beyond the retention period. Preserves hash chain integrity by keeping boundary entries. |
Error Handling
Each task runs in isolation. If a task handler throws an error, the scheduler increments the errors counter and logs the failure, but other tasks continue running unaffected.
Next Steps
- REST API Overview -- Endpoints and conventions
- Scheduled Tasks Guide -- Creating custom tasks
- Configuration -- Environment variables