Schedule API Documentation
Overviewβ
The Schedule API provides scheduling functionality for both trucking and service repair operations. It handles time range calculations with industry-specific logic for travel time, legal breaks, and appointment durations.
Time Range Calculationβ
Trucking Industryβ
For trucking operations, the system calculates realistic schedule times accounting for:
Start Time Calculationβ
- Base Time: Appointment date/time
- Travel Time: Calculated using:
- Distance (from route mileage)
- Average speed (default: 55 mph)
- Buffer time (default: 30 minutes)
- Pre-trip inspection (default: 15 minutes)
- Post-trip inspection (default: 10 minutes)
Legal Breaksβ
- 30-minute break: Required after 8 hours of driving
- Additional breaks: 30 minutes for every additional 8-hour period
- Complies with Federal Hours of Service (HOS) regulations
End Timeβ
- Uses the appointment date as the delivery/pickup time
Service Repair Industryβ
For service repair operations:
Start Time Calculationβ
- Preferred: Uses
timeRange.startif provided - Fallback: Uses appointment date
End Time Calculationβ
- Preferred: Uses
timeRange.endif provided - Fallback: Uses appointment date + default duration (configurable, default: 2 hours)
Configurationβ
Schedule Configurationβ
{
"Schedule": {
"defaultDuration": 2, // hours
"travelTime": {
"averageSpeed": 55, // mph for trucking, 35 for service
"bufferTime": 30, // minutes
"preTrip": 15, // minutes (trucking only)
"postTrip": 10 // minutes (trucking only)
},
"legalBreaks": {
"mandatory30MinBreak": {
"enabled": true,
"afterHours": 8,
"durationMinutes": 30
}
}
}
}
Accessing Configurationβ
const { getFeature } = useCustomerConfig();
const defaultDuration = getFeature("Schedule.defaultDuration") || 2;
API Endpointsβ
GET /api/v1/scheduleβ
Returns scheduled events and resources.
Query Parameters:
startDate(optional): Filter events from this dateendDate(optional): Filter events to this date
Response Structure:
{
"events": [
{
"id": "event_id",
"title": "Load #12345",
"industryType": "trucking",
"timeRange": {
"start": "2024-01-15T08:00:00Z",
"end": "2024-01-15T10:00:00Z",
"alerts": [
{
"code": "hos_rest_required",
"type": "action_required",
"severity": "high",
"message": "Trip exceeds the FMCSA 11-hour driving window and requires overnight rest planning.",
"actionable": true
}
],
"warnings": [
"Trip exceeds the FMCSA 11-hour driving window and requires overnight rest planning."
],
"requiresAttention": true
},
"route": {
"pickupLocation": {...},
"dropoffLocation": {...},
"estimatedDistance": 100
}
}
],
"resources": [
{
"id": "resource_id",
"name": "John Doe",
"type": "driver",
"status": "available"
}
]
}
Trucking alert metadataβ
For trucking events, timeRange may include additive alert metadata:
alerts: structured alert objects used by current dispatch UIwarnings: legacy warning strings kept for backward compatibilityrequiresAttention: derived from actionable/review alerts, not from every warning string
Current alert object fields:
codetypeseveritymessageactionable
Current alert types:
action_requiredneeds_reviewdata_qualityinfo
GET /api/v1/schedule/unassignedβ
Returns unassigned jobs/legs and available resources.
Time Range Examplesβ
Trucking Exampleβ
// Input: Leg with 100-mile route, appointment at 10:00 AM
const leg = {
appointmentDate: "2024-01-15T10:00:00Z",
route: { mileage: 100 }
};
// Calculation:
// - Travel time: 100 miles Γ· 55 mph = 1.82 hours = 109 minutes
// - Buffer time: 30 minutes
// - Pre-trip: 15 minutes
// - Post-trip: 10 minutes
// - Legal breaks: 0 minutes (under 8 hours)
// - Total: 164 minutes
// Result:
{
start: "2024-01-15T07:16:00Z", // 10:00 AM - 164 minutes
end: "2024-01-15T10:00:00Z" // Original appointment time
}
Service Repair Exampleβ
// Input: Job with timeRange provided
const job = {
appointmentDate: "2024-01-15T14:00:00Z",
timeRange: {
start: "2024-01-15T13:30:00Z",
end: "2024-01-15T15:30:00Z"
}
};
// Result:
{
start: "2024-01-15T13:30:00Z", // Use provided start time
end: "2024-01-15T15:30:00Z" // Use provided end time
}
Error Handlingβ
The system gracefully handles missing data:
- Missing route information defaults to 0 miles
- Missing appointment dates default to current time
- Missing configuration values use industry defaults
Industry-Specific Featuresβ
Truckingβ
- Hours of Service (HOS) compliance
- Pre/post-trip inspection time
- Long-distance travel calculations
- Legal break requirements
Service Repairβ
- Flexible time ranges
- Equipment setup/teardown time
- Shorter travel distances
- Configurable appointment durations