Smart Scheduling API
The Smart Scheduling API allows you to programmatically trigger scheduling and retrieve scheduling status.Endpoints
Trigger Scheduling
Triggers the unified scheduler for a workspace, scheduling both habits and tasks.Path Parameters
The workspace ID (UUID format)
Request Body
How many days into the future to schedule events (7-90)
If true, deletes existing auto-generated events and creates new ones
Response
Example
Get Scheduling Status
Retrieves the current scheduling status and statistics for a workspace.Path Parameters
The workspace ID (UUID format)
Response
Example
Authentication
User Authentication
Standard user authentication via session cookie. The user must be a member of the workspace.Cron Authentication
For background jobs, the API accepts a Bearer token with the cron secret:process.env.CRON_SECRET ?? process.env.VERCEL_CRON_SECRET.
Error Responses
| Status | Description |
|---|---|
| 400 | Invalid workspace ID |
| 401 | Not authenticated |
| 403 | Not a workspace member |
| 409 | Safe apply blocked because the schedule still has unresolved warnings |
| 422 | Workspace timezone is not set, or is set to auto |
| 500 | Internal server error |
Rate Limiting
The scheduling endpoint is rate-limited to prevent abuse:- Manual triggers: Limited by standard API rate limits
- Cron triggers: A single global cron runs every 6 hours and fans out to eligible workspaces (not per-workspace at the cron level)
Cron Job
Smart Scheduling runs automatically every 6 hours via Vercel Cron:- Finds all workspaces with auto-schedule enabled habits or tasks
- Calls the scheduling API for each workspace
- Logs results and any errors
The cron job uses
forceReschedule: false to avoid disrupting existing schedules. Only new items are scheduled.