Escalate Pending Approvals Cron API
Overview
Background cron job endpoint that scans active ApprovalJourney entries where status = PENDING and expiresAt <= NOW(). It automatically escalates pending requests from Manager 1 -> Manager 2 -> Manager 3 after the company-configured timeout (escalationTimeMinutes).
- Endpoint:
/api/cron/escalate-approvals - Method:
POST/GET - Access: Cron Scheduler / System Administration
Success Response (200 OK)
{
"success": true,
"message": "Processed 2 expired approval journeys (1 escalated to next manager, 1 expired)",
"data": {
"totalEvaluated": 2,
"escalated": 1,
"expired": 1
}
}
Database Impact
- Tables:
approval_journeys,approval_histories,bookings,user_manager_maps - Operations:
- Marks current step history as
AUTO_ESCALATED. - Advances
currentStepto next level (Manager 2 or Manager 3) and creates newPENDINGhistory entry. - If no further manager exists, marks
ApprovalJourneyasEXPIREDandBookingasAPPROVAL_EXPIRED.
- Marks current step history as