Route Optimization by Vehicle - Route End Parameter

Requires Route Optimization v3 - POST /api/v2/optimizations/scheduled

routeEnd per vehicle type

The optional routeEnd parameter can be set on each vehicle type for vehicle-based optimizations (optimizationType: "VEHICLES"). This lets customers end each vehicle type's routes at a different location. For example, cars can return to one hub while trucks return to another hub or to the team hub. If a vehicle type does not include routeEnd, it will use the optimization's top-level routeEnd.

This can only be used on the scheduled-optimization request for vehicle optimizations. It cannot be used for driver, Service Area, or on-demand optimizations, and it is only available through the API. There is no route optimization profile default for this field. Route start cannot be set per vehicle type.

NameTypeDescription
routeEndstringOptional. Sets where the routes for this vehicle type end. Accepts teams://DEFAULT or hub://<hubId>. Cannot be null.

The following values are accepted for routeEnd on a vehicle type

ValueDescription
teams://DEFAULTRoutes end at the hub of the team set in optimizationByVehicle.team.
hub://<hubId>Routes end at this hub. The hub must belong to the organization.
(not included)Uses the optimization's top-level routeEnd. If that is also not set, routes end at their last stop.

workers://ROUTING_ADDRESS cannot be used on a vehicle type since vehicle types do not have a driver with a routing address. It can still be used on the top-level routeEnd.

Example base payload that includes routeEnd per vehicle type

{
  "optimizationType": "VEHICLES",
  "tasks": [...],
  "teams": { "<teamId>": [] },
  "routeEnd": "hub://<mainHubId>",
  "optimizationByVehicle": {
    "team": "<teamId>",
    "vehicleTypes": {
      "car":        { "selected": true,  "count": 2, "maxTasksPerRoute": 5, "capacity": 100, "routeEnd": "hub://<northHubId>" },
      "truck":      { "selected": true,  "count": 1, "maxTasksPerRoute": 8, "capacity": 500, "routeEnd": "teams://DEFAULT" },
      "bicycle":    { "selected": true,  "count": 3, "maxTasksPerRoute": 4, "capacity": null },
      "motorcycle": { "selected": false, "count": 0, "maxTasksPerRoute": 0, "capacity": null },
      "walking":    { "selected": false, "count": 0, "maxTasksPerRoute": 0, "capacity": null }
    }
  }
}

In this example, cars end at the north hub, trucks end at the team hub, and bicycles use the optimization's routeEnd, which is the main hub.

400 Errors

A 400 error is returned if a vehicle type's routeEnd is not teams://DEFAULT or hub://<hubId>, if the hub does not belong to the organization, or if teams://DEFAULT is used without a team in the request that has a hub. The error message will name the vehicle type that has the invalid value.

routeEnd per vehicle type behaviours

  • Which value applies: A vehicle type's own routeEnd is used first. If it is not set, the optimization's routeEnd is used, including the profile default if there is one. If neither is set, routes end at their last stop, same as today.
  • Each vehicle type is separate: In one optimization, different vehicle types can end at different hubs, at the team hub, or use the optimization's routeEnd.
  • Only selected vehicle types are used: A routeEnd on a vehicle type with selected: false is saved but not used, and it is not checked against the organization's hubs. An invalid hub ID is still rejected.
  • End-of-route task: When createEndRouteTask is on, the end-of-route task is created at each vehicle type's own end location, not at the optimization's routeEnd.
  • Re-optimization: Does not apply. Route plans from vehicle-based optimizations cannot be re-optimized yet. Only driver-based route plans can be re-optimized.