OptimizationRequest

The top-level request body accepted by every /optimize/* endpoint. It is divided into 18 logical sections. Only resources and travel are required — every other section has a safe default or is simply omitted.

Units

All time values are seconds (typically seconds-from-midnight or seconds-from-an-arbitrary-origin, consistent across the whole request). All distance values are metres.

Section map

KeyRequired?Purpose
metadataNoProblem identification and tags
problemNoGlobal settings: num_days, timezone, max_wait_before_service
depotsNoNamed depots with GPS or matrix index
resourcesYesVehicles/crews with capacity, skills, time window
jobsNo*Service stops with demands, time windows, skills (*omitting jobs is valid but pointless — nothing to solve)
shipmentsNoPickup-delivery pairs
relationsNoPrecedence, sequence, same/different route
zonesNoGeographic access restrictions
appointmentsNoPre-scheduled time slots (resource + job + time)
dump_stationsNoCapacity-reset stops (waste handlers)
exclusive_dimensionsNoIncompatible load dimension pairs
locationsNo†GPS catalog for coordinate-based matrix mode (†required when travel.profile is set)
travelYesdistance_matrix/time_matrix OR profile
objectivesNomin_distance, min_time, min_vehicles, etc.
locksNoDynamic replanning: freeze existing routes
seed_solutionNoInitial solution hint
webhooksNoCompletion notification webhooks — accepted but not yet delivered, see the Async guide
optionsNoSolver time limit, strategy, metaheuristic
output_optionsNoControl what appears in the response

Metadata

FieldTypeDescription
problem_idstringClient-supplied problem identifier; echoed back in the response.
descriptionstringHuman-readable description.
tagsstring[]Arbitrary tags for filtering/logging.

Problem config

FieldTypeDescription
num_daysintegerNumber of planning days (≥1). Enables multi-day scheduling — each resource is expanded into one virtual vehicle per day. Must live here, not under options; misplacing it is silently ignored and the solve runs single-day.
timezonestringIANA timezone (e.g. Europe/Amsterdam). Informational only.
max_wait_before_serviceintegerGlobal maximum waiting time at a stop before service begins (seconds, ≥0). Overridden per-resource or per-job.

Depot

FieldTypeDescription
idstringrequired Unique depot identifier.
locationLocationrequired See Location below.
time_windowTimeWindowOpening hours of the depot.
labelstringHuman-readable depot name.

Location

FieldTypeDescription
indexintegerZero-based row/column index in the travel matrices (≥0). Required if no GPS coordinates.
latfloatLatitude (WGS84). Required if no index.
lonfloatLongitude (WGS84). Required if no index.
labelstringHuman-readable location name.

TimeWindow

FieldTypeDescription
startintegerrequired Earliest service start time (seconds, ≥0).
endintegerrequired Latest service start time (must be ≥ start).

Resource (vehicle / crew)

FieldTypeDescription
idstringrequired Unique resource identifier.
start_depot_idstringDepot id where the resource starts. One of start_depot_id, start_location, or depot_index must be provided.
end_depot_idstringDepot id where the resource ends. Defaults to start_depot_id.
start_location / end_locationLocationExplicit start/end locations as an alternative to depot ids.
depot_indexintegerFallback: matrix index for the start depot.
capacitiesobject | integerNamed capacity limits, e.g. {"waste": 10, "recyclable": 5}, or a single integer (becomes {"_default": n}).
time_windowTimeWindowWorking hours for this resource.
max_travel_timeintegerMaximum total travel time in the route (seconds, ≥0).
max_tasksintegerMaximum number of jobs in the route (≥0).
max_distanceintegerMaximum total route distance (metres, ≥0).
skillsstring[]Skill tags this resource has.
breaksBreak[]Scheduled break intervals; see Break below.
max_continuous_drivingintegerAuto-generate a break every N seconds of driving (≥1).
driving_break_durationintegerDuration of auto-generated driving break (seconds, default 15).
max_continuous_workintegerAuto-generate a break every N seconds of work (≥1).
work_break_durationintegerDuration of auto-generated work break (seconds, default 30).
max_wait_before_serviceintegerOverrides the global wait cap for this resource (≥0).
available_daysinteger[]Multi-day only: day indices this resource is available on.
activebooleanIf false, this resource is excluded from the solve entirely (default true).
fixed_costintegerCost charged if the vehicle is used (≥0).
cost_per_kmfloatVariable distance cost per kilometre (≥0).
cost_per_hourfloatVariable time cost per hour (≥0).

Break

FieldTypeDescription
idstringOptional break identifier.
time_windowTimeWindowrequired Window within which the break must start.
durationintegerrequired Duration of the break (seconds, ≥0).
Breaks force a fixed search strategy

When any resource has breaks, the solver requires PATH_CHEAPEST_ARC as the first-solution strategy regardless of what options.first_solution_strategy requests. The adapter applies this override automatically.

Job

FieldTypeDescription
idstringrequired Unique job identifier.
location / location_indexLocation / integerJob location, or a matrix index shorthand (≥0).
demandsobject | integerNamed capacity demands, e.g. {"waste": 3}, or a single integer.
service_timeintegerTime to complete service at the stop (seconds, default 0).
time_windowsTimeWindow[]Acceptable service time windows.
required_skillsstring[]Skills a resource must have to serve this job.
allowed_resource_idsstring[]Restrict to specific resources. Empty = all resources.
mandatorybooleanIf false, the job may be dropped with a penalty (default true).
penaltyintegerCost paid if the job is dropped (default 100000).
revenueintegerRevenue gained if served (used by maximize_served).
priorityintegerScheduling priority 1–10 (higher = serve first); multiplies into the penalty under priority-aware objectives.
dayintegerMulti-day only: pin the job to this day index (≥0).
lockedbooleanDynamic replanning: preserve this job's current assignment.
setup_timeintegerOne-time setup cost added before the first visit (seconds).
lifobooleanLast-in-first-out ordering constraint.
max_wait_before_serviceintegerOverrides the max wait for this specific job (≥0).
departure_timeintegerSeconds-from-midnight at which the assigned vehicle leaves its depot heading for this job. Requires exactly one entry in allowed_resource_ids. FG computes the depot→job travel time and derives the exact arrival window automatically (arrival = departure_time + travel_time); any manually specified time_windows on the same job are replaced.
departure_time validation

departure_time requires exactly one entry in allowed_resource_ids; otherwise the request fails validation with 400 Bad Request.

Shipment (pickup-delivery pair)

FieldTypeDescription
idstringrequired Unique shipment identifier.
pickup / deliveryShipmentSteprequired Pickup and delivery steps. The solver guarantees the same vehicle does both, pickup before delivery.
mandatorybooleanMay be dropped if false (default true).
penaltyintegerDrop penalty (default 100000).
allowed_resource_idsstring[]Restrict to specific resources.
required_skillsstring[]Required skills for serving this shipment.

ShipmentStep

FieldTypeDescription
idstringrequired Unique step identifier.
location / location_indexLocation / integerStep location.
service_timeintegerService duration (seconds, default 0).
time_windowsTimeWindow[]Acceptable service time windows.
demandsobject | integerCapacity change at this step.

Relation

FieldTypeDescription
typestringrequired One of the four types below.
job_idsstring[]required Job ids involved (min 2).
lapseintegerRequired time gap (seconds, ≥0). Only used by precedence.
TypeMeaning
precedenceJob A served before Job B, with at least lapse seconds gap. Different vehicles allowed.
sequenceJobs served in exactly that order, on the same vehicle, with nothing in between.
same_routeAll listed jobs assigned to the same vehicle.
different_routeAll listed jobs assigned to different vehicles.

Zone

FieldTypeDescription
idstringrequired Unique zone identifier.
location_indicesinteger[]required Matrix indices belonging to this zone (min 1).
allowed_resource_idsstring[]required Resources allowed to serve locations in this zone.

Appointment

Syntactic sugar for pinning a specific job to a specific resource at a specific time. Internally normalized to job-level time_windows and allowed_resource_ids.

FieldTypeDescription
resource_idstringrequired Resource that must serve this job.
job_idstringrequired Job to be served.
timeintegerrequired Scheduled service start (seconds, ≥0).
toleranceintegerAllowed deviation from time in either direction (seconds, default 0).

DumpStation

Reset a vehicle's capacity when visited — modelled as an optional node with a large negative demand.

FieldTypeDescription
idstringrequired Unique dump station identifier.
location / location_indexLocation / integerStation location.
service_timeintegerUnload/reload time at the station (seconds, default 0).
resets_capacitiesstring[]Which capacity dimensions to reset. Empty = reset all.
max_vehiclesintegerMaximum simultaneous vehicles (≥1, default 1). Values >1 generate virtual copies of the node.

Exclusive dimensions

A list of pairs of capacity-dimension names that cannot both be loaded between dump visits, e.g. [["organic", "recyclable"]]. Before loading one, the truck must have emptied all of the other.

Travel config

FieldTypeDescription
distance_matrixinteger[][]N×N distance matrix (metres, 0-indexed). Required if no GPS profile.
time_matrixinteger[][]N×N time matrix (seconds, 0-indexed). Required if no GPS profile.
speed_kmhfloatFixed speed for converting distance to time. Used if only one matrix is provided.
profilestringRouting profile: auto, truck, or bicycle. Triggers automatic matrix computation from GPS coordinates in a top-level locations array.

Objectives config

FieldTypeDescription
primarystringDefault min_distance. One of the five values below.
fairness_weightintegerWorkload balance coefficient (≥0, default 0).
vehicle_fixed_cost_weightfloatWeight on per-vehicle fixed cost (≥0, default 1.0).
ValueMeaning
min_distanceMinimize total route distance (default).
min_timeMinimize total route time.
min_vehiclesUse as few vehicles as possible.
maximize_servedMaximize revenue from served jobs.
balance_workloadMinimize workload variance across vehicles.

Solver options

FieldTypeDescription
time_limit_secondsintegerSolver runtime limit (≥1, default 30).
solution_limitintegerStop after finding N solutions (≥1, optional).
first_solution_strategystringInitial-solution heuristic. Default PATH_CHEAPEST_ARC.
local_search_metaheuristicstringImprovement algorithm. Default GUIDED_LOCAL_SEARCH.
num_threadsintegerParallel search threads (≥1, default 1).
log_searchbooleanEnable verbose solver log (default false).
first_solution_strategyDescription
AUTOMATICThe solver chooses the best strategy automatically.
PATH_CHEAPEST_ARCGreedy cheapest-edge insertion; default, and forced when breaks are present.
PATH_MOST_CONSTRAINED_ARCPrioritizes the most-constrained nodes first.
PARALLEL_CHEAPEST_INSERTIONParallel cheapest insertion heuristic.
LOCAL_CHEAPEST_INSERTIONSequential cheapest insertion.
GLOBAL_CHEAPEST_ARCGlobal minimum-cost arc selection.
SAVINGSClarke-Wright savings algorithm.
CHRISTOFIDESChristofides approximation algorithm.
local_search_metaheuristicDescription
AUTOMATICThe solver chooses automatically.
GUIDED_LOCAL_SEARCHGLS with penalty-guided neighborhood exploration (default).
GREEDY_DESCENTClassic hill climbing.
SIMULATED_ANNEALINGTemperature-based acceptance of worse solutions.
TABU_SEARCHForbids recently-visited moves.
GENERIC_TABU_SEARCHTabu search with aspiration criteria.

Locks config

Used for dynamic replanning: preserve some routes while re-optimizing the rest.

FieldTypeDescription
routesLockedRoute[]List of locked routes.
disabled_resource_idsstring[]Resources excluded from the re-optimization entirely.

LockedRoute

FieldTypeDescription
resource_idstringrequired Resource whose route is locked.
job_idsstring[]required Ordered sequence of locked job ids (min 1).

Output options

FieldTypeDescription
include_unserved_reasonsbooleanInclude reason codes for unserved jobs (default true).
include_violationsbooleanInclude constraint violation details (default true).
include_diagnosticsbooleanInclude solver diagnostics (default false).
include_score_breakdownbooleanInclude per-component score (default true).
route_geometrybooleanInclude route GeoJSON geometry (default false).

Minimal request

{
  "metadata": { "problem_id": "v2-01-basic" },
  "travel": {
    "distance_matrix": [
      [0, 4, 8, 6, 7],
      [4, 0, 5, 3, 6],
      [8, 5, 0, 6, 4],
      [6, 3, 6, 0, 5],
      [7, 6, 4, 5, 0]
    ]
  },
  "resources": [
    { "id": "truck-1", "depot_index": 0 },
    { "id": "truck-2", "depot_index": 0 }
  ],
  "jobs": [
    { "id": "j1", "location_index": 1 },
    { "id": "j2", "location_index": 2 },
    { "id": "j3", "location_index": 3 },
    { "id": "j4", "location_index": 4 }
  ],
  "options": { "time_limit_seconds": 5 }
}

See OptimizationResponse for the full shape of what comes back.

FieldGenius VRP API documentation. Generated from the engineering source of truth (.tex docs and app/ source).