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: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:- 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.Calendar link preview for Mail
GET /api/v1/workspaces/{wsId}/calendar/events/{eventId}/link-preview returns
a sanitized read-only target for an explicit Mail association. The default
Calendar/Tasks authentication boundary is preserved; this endpoint also accepts
a validated Mail app session and mobile bearer authentication. Workspace
membership and manage_calendar remain required. A provider target additionally
requires one enabled, active connected account owned by the actor, with both the
stored workspace source and external calendar IDs matching exactly. Read-only
provider roles are eligible; ambiguous or incomplete legacy identities, disabled
accounts, missing targets, and cancelled events suppress the preview.
The response preserves internal IDs, connected-account row and connection IDs,
provider calendar and immutable event IDs, actual provider UID, and original
occurrence identity when available. Microsoft occurrence UIDs are returned as
provided and must not be assumed to equal a series UID. Native events report
unknown account, organizer, UID, recurrence and attendee ownership.
Provider fields come from an exact authorized GET, after the local encrypted
storage boundary. Missing keys, malformed ciphertext and authentication failures
suppress both native previews and provider GETs; the preview never treats the
legacy decryption fallback or an encryption flag as proof of plaintext. Hidden
attendees are omitted; conferencing fields only yield
validated HTTPS Teams/Meet links, separately from the structured location. Raw
bodies, account credentials and provider errors are never returned. This endpoint
does not save associations, alter either event, respond to invitations, copy
events or grant permission to merge a private hold into an organizer’s request.
The shared wire contract is exported from @tuturuuu/internal-api/calendar.
Mail owns actor-scoped association metadata and must recheck this preview on
confirm/open. No Calendar table or provider mutation is part of this seam.