Optimize a plan (async)
Starts the Routal optimizer on this plan and returns as soon as the run is accepted, without waiting for it to finish.
Starts the Routal optimizer on this plan and returns as soon as the run is accepted, without waiting for it to finish. Stops are assigned to vehicles, ordered, and the ETA, distance and load of every route are recomputed.
All routes are rebuilt by default, so stops may move between vehicles. Routes flagged is_locked are always preserved and left out of the run, and so are finished routes. A stop that already has a report keeps its route, order and planned times, and so does the other half of its pickup and delivery pair. Pass keep_current_assignment=true to keep each stop on its current route and only re-sequence stops within it, for example once a driver has started.
Getting the result
- Create a webhook in Developer Settings of your Routal workspace, subscribed to
routal.optimizer.2.optimization.succeededandroutal.optimizer.2.optimization.failed. - When the run ends, Routal sends one of the two. The event says how the run went, not where each stop ended up.
- Read the optimized routes with
GET /v2/plan/{id}/routes.
If someone cancels the run from the Routal Planner, neither event is sent and the plan keeps the routes it had before the run.
Only one optimization runs on a plan at a time. The call is rejected when one is already running, or when the plan has nothing to optimize: it needs at least one pending stop with a valid location and one route that is neither locked nor finished.
The optimizer respects time windows, service duration per stop, vehicle capacities (weight, volume, units), skills (stop requires matched against vehicle provides), route time windows, break times, route start and end locations, and geo-fenced zones.
Authorization
api_key Pass your API key as the private_key query string parameter. Generate and rotate keys in Developer Settings of your Routal workspace.
Keys stay server-side. Never ship them to a browser or mobile app.
In: query
Path Parameters
Plan ID
^[0-9a-f]{24}Query Parameters
When true, stops stay on their currently assigned route and only the in-route sequence is re-optimized. Use this once dispatch has started.
falseResponse Body
application/json
application/json
application/json
application/json
curl -X POST "https://example.com/v2/plan/string/optimize/async"{
"plan_id": "4f75d991ac359f8c4c79d762",
"project_id": "4f75d991ac359f8c4c79d762"
}{
"message": "Domain not found",
"message_id": "highway.domain.error.not_found"
}{
"message": "Domain not found",
"message_id": "highway.domain.error.not_found"
}{
"message": "Domain not found",
"message_id": "highway.domain.error.not_found"
}