The Optimization API
The /optimize endpoint is the heart of Klau. It uses our proprietary chaining algorithms to reduce miles, eliminate yard returns, and maximize hauler capacity.
How it Works
Optimization transforms a list of Unassigned Jobs and Active Drivers into a set of Published Dispatches.
Jobs
Type, Size, Site Location, and Time Windows.
Drivers
Start location, Start time, and Appointments.
Trucks
Compatibility and container capacity.
Running an Optimization
POST /api/v1/dispatches/optimize
Content-Type: application/json
Idempotency-Key: opt_today_unique_123
{
"date": "2025-12-20",
"constraints": {
"respectTimeWindows": true,
"prioritizeChainContinuity": true
}
}Self-Healing Dispatch
Optimization is not just for the start of the day. You can call /optimize multiple times as reality changes (e.g., a driver is delayed, a new urgent job arrives). Klau will perform a"Micro-Reoptimization" that fixes the plan with minimal disruption.
Container Chaining
The chained: true flag in assignments indicates that two jobs were successfully linked without a return to the yard, saving fuel and time.