Chuyển đến nội dung chính
Mục lục tài liệu
POST

/addons/route-optimization/jobs

Submit an asynchronous route optimization job

Mở trong ChatGPTMở trong Claude

Đường dẫn

POST/api/v1/partners/addons/route-optimization/jobs
Xác thực yêu cầuapi-key

Ví dụ gọi bằng curl

curl -X POST "https://<your-host>/api/v1/partners/addons/route-optimization/jobs" \
  -H "api-key: YOUR_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "content-type: application/json" \
  -d '{
  "external_reference": "string",
  "replaces_job_id": "string",
  "optimization_options": {
    "delivery_mode": "1",
    "kind_of_plan": "1",
    "tour_mode": "string"
  },
  "vehicles": [
    {
      "external_vehicle_id": "string",
      "resource_id": 0,
      "from_address": "string",
      "from_lat": 0,
      "from_lon": 0,
      "from_working_time": "2026-01-01T00:00:00+07:00",
      "to_working_time": "2026-01-01T00:00:00+07:00",
      "handling_unit_ids": [
        0
      ],
      "height_of_vehicle": 0,
      "length_of_vehicle": 0,
      "width_of_vehicle": 0,
      "vehicle_tonnage": 0,
      "to_address": "string",
      "to_lat": 0,
      "to_lon": 0
    }
  ],
  "orders": [
    {
      "external_order_id": "string",
      "transport_mode": "firstmile",
      "handling_unit_id": 0,
      "service_id": 0,
      "pickup_address": "string",
      "pickup_lat": 0,
      "pickup_lon": 0,
      "pickup_date_time": "2026-01-01T00:00:00+07:00",
      "pickup_date_time_to": "2026-01-01T00:00:00+07:00",
      "drop_address": "string",
      "drop_lat": 0,
      "drop_lon": 0,
      "drop_date_time": "2026-01-01T00:00:00+07:00",
      "drop_date_time_to": "2026-01-01T00:00:00+07:00",
      "rlength": 0,
      "rwidth": 0,
      "rheight": 0,
      "rweight": 0,
      "count_of_parcels": 0,
      "resource_id": 0,
      "distance": 0,
      "pickup_wid": 0,
      "drop_wid": 0,
      "loading_time": 0,
      "unloading_time": 0,
      "sender_name": "string",
      "sender_phone": "string",
      "receiver_name": "string",
      "receiver_phone": "string"
    }
  ]
}'

Tham số

TênVị tríKiểuBắt buộcMô tả
Idempotency-KeyheaderstringCóClient-scoped key retained indefinitely; maximum 128 chars

Nội dung gửi lên

Bổ sung ngoài bản đặc tả

Bản đặc tả OpenAPI chưa mô tả đầy đủ phần này, nên chúng tôi bổ sung nội dung dưới đây từ mã nguồn của API. Khi bản đặc tả có đủ thông tin, phần này sẽ được cập nhật theo.

TrườngKiểuBắt buộcMô tả
external_referencestringKhôngYour own identifier for this job. 0 to 128 characters.
replaces_job_idstring (uuid)KhôngIdentifier of one of your own jobs still in QUEUED status. Submitting with this field atomically supersedes that job, which becomes CANCELLED: this is the only way a job reaches CANCELLED, and there is no separate cancel endpoint. The guard fires once the target job has been picked up for processing, which can happen while it still reports QUEUED; past that point the submit is refused with JOB_ALREADY_PROCESSING.
optimization_optionsobjectCóControls how the optimizer weighs distance, vehicle count, workload balance, time windows and driver availability for this job.
vehiclesobject[]CóThe fleet available for this job. 1 to 200 vehicles.
ordersobject[]CóThe drop points to plan for this job. At least 1 order.

Các trường của optimization_options

TrườngKiểuBắt buộcMô tả
delivery_mode'1' | '2' | '3' | '4'CóDelivery mode. '1' normal, '2' same day, '3' express (2 hour), '4' four hour.
kind_of_plan'1' | '2'CóPlanning mode. '1' actual planning, '2' plan in advance.
tour_modestringCóFive binary flags plus a time limit, joined by semicolons in this exact order: minimize_total_distance, minimize_vehicle_count, balance_workload, prioritize_time_windows, require_available_driver, time_limited_route. Each flag is 0 or 1; time_limited_route is an integer number of minutes, 0 meaning no limit. Example: '1;0;0;0;0;0'. Length 11 to 32 characters, pattern ^[01](;[01]){4};\d+$.

Các trường của vehicles

TrườngKiểuBắt buộcMô tả
external_vehicle_idstringCóYour own identifier for this vehicle. 1 to 128 characters.
resource_idintegerCóInternal resource identifier for the vehicle. 1 or greater.
from_addressstringCóStarting address of the vehicle. 1 to 500 characters.
from_latnumberCóStarting point latitude. Minus 90 to 90.
from_lonnumberCóStarting point longitude. Minus 180 to 180.
from_working_timestring (date-time)CóStart of the vehicle working window. ISO 8601 date time.
to_working_timestring (date-time)CóEnd of the vehicle working window. ISO 8601 date time.
handling_unit_idsinteger[]CóHandling unit identifiers this vehicle can carry. Maximum 100 entries.
height_of_vehiclenumberCóVehicle height, in centimetres. 1 or greater. An earlier revision of this documentation named the wrong unit for this field; the stored column has always been an integer count of centimetres with no conversion applied, so submit the value directly in centimetres.
length_of_vehiclenumberCóVehicle length, in centimetres. 1 or greater. See the note on height_of_vehicle above.
width_of_vehiclenumberCóVehicle width, in centimetres. 1 or greater. See the note on height_of_vehicle above.
vehicle_tonnagenumberCóVehicle payload capacity, in kilograms despite the field name. 0 or greater. The stored column is an integer count of kilograms with no conversion applied, so submit the value directly in kilograms.
to_addressstringKhôngEnding address of the vehicle, if different from the start. 0 to 500 characters.
to_latnumberKhôngEnding point latitude, if the vehicle ends somewhere other than from_lat.
to_lonnumberKhôngEnding point longitude, if the vehicle ends somewhere other than from_lon.

Các trường của orders

TrườngKiểuBắt buộcMô tả
external_order_idstringCóYour own identifier for this order. 1 to 128 characters.
transport_mode'firstmile' | 'midmile' | 'lastmile'CóWhich leg of the haul this order belongs to.
handling_unit_idintegerCóHandling unit identifier for the cargo. 1 or greater.
service_idintegerCóService identifier for the order. 1 or greater.
pickup_addressstringCóPickup address. 1 to 500 characters.
pickup_latnumberCóPickup point latitude.
pickup_lonnumberCóPickup point longitude.
pickup_date_timestring (date-time)CóStart of the pickup window. ISO 8601 date time.
pickup_date_time_tostring (date-time)CóEnd of the pickup window. ISO 8601 date time.
drop_addressstringCóDrop off address. 1 to 500 characters.
drop_latnumberCóDrop off point latitude.
drop_lonnumberCóDrop off point longitude.
drop_date_timestring (date-time)CóStart of the drop off window. ISO 8601 date time.
drop_date_time_tostring (date-time)CóEnd of the drop off window. ISO 8601 date time.
rlengthnumberCóCargo length, in centimetres. 0 or greater.
rwidthnumberCóCargo width, in centimetres. 0 or greater.
rheightnumberCóCargo height, in centimetres. 0 or greater.
rweightnumberCóCargo weight, in kilograms. 0.01 or greater.
count_of_parcelsintegerCóNumber of parcels in this order. 1 or greater.
resource_idintegerKhôngInternal resource identifier, if known. 0 or greater.
distancenumberKhôngKnown distance for this order, in kilometres, if you have one. 0 or greater.
pickup_widintegerKhôngPickup warehouse identifier. 0 or greater.
drop_widintegerKhôngDrop off warehouse identifier. 0 or greater.
loading_timeintegerKhôngLoading time, in minutes. 0 or greater.
unloading_timeintegerKhôngUnloading time, in minutes. 0 or greater.
sender_namestringKhôngSender name. 0 to 200 characters.
sender_phonestringKhôngSender phone number. 0 to 32 characters.
receiver_namestringKhôngReceiver name. 0 to 200 characters.
receiver_phonestringKhôngReceiver phone number. 0 to 32 characters.
5 trườngCreateRouteOptimizationJobDto

Kết quả trả về

202Public job aggregate committed
400ROUTE_OPT_VALIDATION_ERROR or DUPLICATE_EXTERNAL_ID
409IDEMPOTENCY_CONFLICT, ACTIVE_EXTERNAL_ID_CONFLICT, or JOB_ALREADY_PROCESSING
413ROUTE_OPT_PAYLOAD_TOO_LARGE
429ROUTE_OPT_RATE_LIMITED

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

POST /addons/route-optimization/jobs | Route4Green