Chuyển đến nội dung chính
Mục lục tài liệu
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.

Mở trong ChatGPTMở trong Claude

Đường dẫn

PUT/api/v1/partners/addons/route-optimization/jobs/{jobId}/baseline
Xác thực yêu cầuapi-key

Ví dụ gọi bằng curl

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
}'

Tham số

TênVị tríKiểuBắt buộcMô tả
jobIdpathstring (uuid)Có

Nội dung gửi lên

TrườngKiểuBắt buộcMô tả
km_typeroad | straight_lineCó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_depotbooleanCóWhether each baseline distance_km includes the return leg to the depot
routesobject[]Có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_basisreported | remeasureKhôngWhich 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_knownbooleanKhôngWhether 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.

Các trường của routes

TrườngKiểuBắt buộcMô tả
vehicle_refstringCó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_idsstring[]Có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_kmnumberKhôngPlanned 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_minutesnumberKhôngPlanned duration of this route, in minutes
5 trườngRouteOptimizationBaselineDto

Kết quả trả về

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

Về nhóm: Tối ưu tuyến đường

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