Ticket Crons — API
Cron endpoints for automated ticket lifecycle management. All endpoints are triggered by the cron scheduler and require token_cron authentication.
Endpoints
| Method | Path | Handler | Auth | Description |
|---|---|---|---|---|
GET | /notify/tickets/follow-up-incomplete | notifyFollowUpAndIncompleteTickets | token_cron | Send reminders for incomplete tickets and Slack alerts for follow-up tickets |
GET | /notify/tickets/autoclose | notifyAutocloseTickets | token_cron | Auto-accept tickets whose shipment was delivered |
GET | /notify/tickets/incomplete | closeTicketsIncomplete | token_cron | Auto-decline incomplete claim tickets after 10 days |
Route Definitions
All routes are defined in backend/routes/crons.routes.js and use the CronController from backend/controllers/crons.controller.js.
GET /notify/tickets/follow-up-incomplete
Sends multi-channel reminders to clients with incomplete tickets and Slack SLA alerts for follow-up tickets.
Request: No payload or query parameters.
Response:
{
"success": true
}Processing: Runs asynchronously via setImmediate. The HTTP response is returned immediately.
Side effects:
- Sends reminder emails to ticket creators
- Sends platform notifications
- Inserts admin comments on incomplete tickets
- Sends WhatsApp notifications for incomplete tickets
- Sends Slack messages to
#alert-cs-ticketsfor follow-up tickets - Updates ticket timestamps and inserts history records
GET /notify/tickets/autoclose
Automatically accepts tickets whose associated shipment has been delivered, then sends CSAT surveys.
Request: No payload or query parameters.
Response:
{
"data": true
}Processing: Runs asynchronously via setImmediate.
Ticket types affected:
- Shipment Created Without Changes (12)
- Delay (8)
- Redirection (14)
- Delivery Attempt (25)
Shipment statuses that trigger autoclose:
- Delivered
- Delivered at Origin
Side effects:
- Updates ticket status to
ACCEPTED(2) - Inserts translated "delivered" comment
- Inserts ticket history record
- Sends CSAT: in-platform rating, email, and WhatsApp
GET /notify/tickets/incomplete
Automatically declines claim tickets that have been incomplete for more than 10 days, then sends CSAT surveys.
Request: No payload or query parameters.
Response:
{
"success": true
}Processing: Runs asynchronously via setImmediate.
Ticket types affected (claim types only):
- Lost (4)
- Theft (13)
- Damaged (5)
- Overweight (3)
- Irregular Package (21)
Exclusions:
- India locale (
locale_id = 11) is excluded from the query - India locale is also excluded from CSAT notifications
Side effects:
- Bulk updates ticket status to
DECLINED(3) - Batch inserts history records
- Inserts personalized close comment per ticket
- Sends CSAT: in-platform rating, email, and WhatsApp
Error Handling
All three crons follow the same error handling pattern:
- Outer try/catch: Catches errors during route setup. Returns
Boom.badRequestorBoom.badData. - Inner try/catch (inside
setImmediate): Catches errors during async processing. Reports toobservability.captureError(Datadog). - Per-notification catch: Individual notification failures are caught independently so one failure doesn't block others.
Authentication
All cron routes use auth: 'token_cron', a bearer token strategy specifically for scheduled job triggers. This token is separate from admin and client authentication tokens.
Source Files
| File | Purpose |
|---|---|
backend/routes/crons.routes.js | Route definitions for all cron endpoints |
backend/controllers/crons.controller.js | Controller with cron handler methods |
backend/libraries/ticketsV2.util.js | Notification logic, message generation, CSAT pipeline |
backend/libraries/companies.util.js | Ticket comments, rating notifications |
backend/constants/tickets.contstants.js | Ticket type and status constants |
backend/libraries/translate.util.js | Translation/i18n utilities |
