Docs menu
PUT
/addons/route-optimization/jobs/{jobId}/baseline
Attach or replace the baseline of a finished job
Stores the partner's own plan for the job's orders, same body as the baseline field of POST /jobs, so GET /jobs/:id/result can compare plan versus plan. No core run, no quota charge, no webhook. A second call replaces the first and clears its remeasure.
Path
PUT
/api/v1/partners/addons/route-optimization/jobs/{jobId}/baselineAuthentication required
api-keycurl example
curl -X PUT "https://api.route4green.com/api/v1/partners/addons/route-optimization/jobs/{jobId}/baseline" \
-H "api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"km_type": {},
"includes_return_to_depot": false,
"routes": [
{
"vehicle_ref": "string",
"order_ids": [
"string"
],
"distance_km": 0,
"duration_minutes": 0
}
],
"km_basis": {},
"sequence_known": false
}'Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| jobId | path | string (uuid) | Yes |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
| km_type | road | straight_line | Yes | How the baseline distances were measured: 'road' (road network distance) or 'straight_line' (as the crow flies). Distance deltas are only reported for 'road'. |
| includes_return_to_depot | boolean | Yes | Whether each baseline distance_km includes the return leg to the depot |
| routes | object[] | Yes | The partner's own plan for the same orders, one entry per planned route. Orders absent from every route are the baseline's unassigned orders. |
| km_basis | reported | remeasure | No | Which km the comparison uses. 'reported' (default) compares the submitted distance_km against the Route4Green route distances. 'remeasure' measures both plans as closed loops from the depot on the same self-hosted road engine (OSRM) and compares those; the reported figures are used instead when the road engine is unavailable. |
| sequence_known | boolean | No | Whether each route's order_ids list the real stop order (default true). false means the order is not known, so baseline routes are not remeasured. |
Fields of routes
| Field | Type | Required | Description |
|---|---|---|---|
| vehicle_ref | string | Yes | The partner's own label for the vehicle that ran this planned route. It may or may not match an external_vehicle_id. Unique within the baseline. |
| order_ids | string[] | Yes | external_order_id values of this job's orders, in the partner's planned stop order. An order may appear in at most one baseline route. |
| distance_km | number | No | Planned distance of this route in kilometres, measured as declared by km_type and includes_return_to_depot. Omit it or send null when the plan has no km for the route (never 0 as a placeholder): the reported km comparison then has no baseline total and no km deltas (reason BASELINE_KM_UNREPORTED), while km_basis 'remeasure' still measures the route on the road engine |
| duration_minutes | number | No | Planned duration of this route, in minutes |
5 fieldsRouteOptimizationBaselineDto
Responses
200Baseline stored, wrapped in the success envelope400ROUTE_OPT_VALIDATION_ERROR: invalid body, more routes than the vehicle cap, a vehicle_ref used twice, an order not in the job or an order on two routes404ROUTE_OPT_JOB_NOT_FOUND409ROUTE_OPT_BASELINE_JOB_NOT_FINISHED: the job is not SUCCEEDED or PARTIAL410RESULT_PURGED: the job data was deleted after retention429ROUTE_OPT_RATE_LIMITED