Cron Jobs Overview
Hiro CRM uses scheduled cron jobs to automate routine tasks like syncing reservations, sending notifications, and executing marketing automations.Master Cron Endpoint
Configuration
Executed Endpoints
The master cron calls these endpoints sequentially:/api/cron/sync- Sync reservations from PMS/api/cron/calendar-notifications- Send calendar event notifications/api/cron/calendar-reminders- Send calendar reminders/api/cron/ticket-notifications- Send ticket notifications/api/cron/ticket-reminders- Send ticket reminders/api/cron/automations- Execute active marketing automations
Authentication
All cron endpoints requireCRON_SECRET in the Authorization header:
Example Request
Example Response
Individual Cron Endpoints
Sync
Endpoint:GET /api/cron/sync
Synchronizes reservations from CoverManager and other PMS systems.
Timeout: 60 seconds
Frequency: Every 15 minutes (recommended)
Response:
Automations
Endpoint:GET /api/cron/automations
Executes all active marketing automations (birthday campaigns, re-engagement, VIP rewards).
Timeout: 300 seconds (5 minutes)
Frequency: Daily or every 30 minutes (depending on automation type)
Response:
Calendar Notifications
Endpoint:GET /api/cron/calendar-notifications
Sends notifications for upcoming calendar events.
Timeout: 60 seconds
Frequency: Every 15 minutes (recommended)
Calendar Reminders
Endpoint:GET /api/cron/calendar-reminders
Sends reminders for calendar events.
Timeout: 60 seconds
Frequency: Hourly or every 30 minutes
Ticket Notifications
Endpoint:GET /api/cron/ticket-notifications
Sends notifications for new or updated support tickets.
Timeout: 60 seconds
Frequency: Every 15 minutes
Ticket Reminders
Endpoint:GET /api/cron/ticket-reminders
Sends reminders for open tickets nearing SLA deadlines.
Timeout: 60 seconds
Frequency: Every 4 hours
Vercel Cron Configuration
Add tovercel.json:
*/15 * * * *- Every 15 minutes0 * * * *- Every hour0 9 * * *- Daily at 9:00 AM0 0 * * 0- Weekly on Sunday at midnight
Error Handling
Cron jobs implement graceful error handling:- Individual endpoint failures don’t stop the master cron
- Errors are logged and returned in the
resultsarray - Failed tasks are retried on the next cron execution
Example Error Response
Monitoring
All cron executions are logged:- Execution frequency
- Error rates
- Performance metrics
- API call volumes
Best Practices
Use the master cron endpoint for Vercel Hobby Plan deployments
Set appropriate timeout durations for each task
Monitor cron execution logs for failures
Test cron endpoints manually before scheduling
Rotate CRON_SECRET periodically for security
Debugging Cron Jobs
Manually trigger cron endpoints for testing:Alternative Schedulers
Besides Vercel Cron, you can use:- GitHub Actions (scheduled workflows)
- Render Cron Jobs (if deploying on Render)
- Railway Cron (if deploying on Railway)
- External services (cron-job.org, EasyCron)
CRON_SECRET for authentication.