Skip to main content
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}/baseline
Authentication requiredapi-key

curl 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

NameInTypeRequiredDescription
jobIdpathstring (uuid)Yes

Request body

FieldTypeRequiredDescription
km_typeroad | straight_lineYesHow 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_depotbooleanYesWhether each baseline distance_km includes the return leg to the depot
routesobject[]YesThe 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_basisreported | remeasureNoWhich 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_knownbooleanNoWhether 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

FieldTypeRequiredDescription
vehicle_refstringYesThe 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_idsstring[]Yesexternal_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_kmnumberNoPlanned 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_minutesnumberNoPlanned duration of this route, in minutes
5 fieldsRouteOptimizationBaselineDto

Responses

200Baseline stored, wrapped in the success envelope
400ROUTE_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 routes
404ROUTE_OPT_JOB_NOT_FOUND
409ROUTE_OPT_BASELINE_JOB_NOT_FINISHED: the job is not SUCCEEDED or PARTIAL
410RESULT_PURGED: the job data was deleted after retention
429ROUTE_OPT_RATE_LIMITED

Back to group: Route optimisation

PUT /addons/route-optimization/jobs/{jobId}/baseline | Route4Green