Skip to main content
POST
Plan a route
Use this endpoint to build a new route or overwrite an existing route that shares the same name and date. Detrack runs an optimization engine to sequence the supplied job_ids, compute ETAs, and return totals such as distance and duration. If the route already exists, it is replaced with the newly computed plan.
Known issues:
  • If you re-plan with the same name and date and the request fails validation, the existing plan has already been deleted and isn’t replaced. Check your request before re-planning (DTR-6207).
  • Each name in vehicles matches any vehicle whose name contains it, ignoring case. For example, Driver 1 also selects Driver 10. Use vehicle names that aren’t contained in other names (DTR-6206).
Vehicle working hours (from and to) are configured per driver inside the Detrack app; they are not part of the API request payload.
Each route has two levels:
  • The plan (the top-level object) holds the plan’s status, depot, and totals across all vehicles.
  • planned_routes has one entry per vehicle, with that vehicle’s status, start_time, completion_time, time window, and its planned_jobs in delivery order (job_sequence, eta_time).
Jobs that couldn’t be placed on any vehicle are in the plan-level unplanned_jobs. The plan-level vehicle shows one of the plan’s vehicles; use planned_routes[].vehicle to see which vehicle drives which route. See Route status for what each status value means.

Errors

Validation errors return 422 with a code and message. The API checks the request in the order below and stops at the first failure.
See Errors for other status codes.

Authorizations

X-API-KEY
string
header
required

Your Detrack API key, from Integrations > API Key in the dashboard.

Body

application/json
data
object
required

Response

Optimization finished.

data
object