Skip to main content

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

string
required
The workspace ID (UUID format)

Request Body

number
default:30
How many days into the future to schedule events (7-90)
boolean
default:false
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

string
required
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:
This is used by the Vercel cron job that runs scheduling every 6 hours. The cron secret is read from process.env.CRON_SECRET ?? process.env.VERCEL_CRON_SECRET.

Error Responses

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:
The cron job:
  1. Finds all workspaces with auto-schedule enabled habits or tasks
  2. Calls the scheduling API for each workspace
  3. Logs results and any errors
The cron job uses forceReschedule: false to avoid disrupting existing schedules. Only new items are scheduled.