Optimize: Reoptimize
/api/v1/optimize/reoptimizeRe-solve a request that already embeds locks and/or a seed_solution. This is a thin convenience endpoint: it is functionally identical to /optimize/sync except it skips the recurring-jobs injection step.
Description
Use this endpoint when you have already constructed the full OptimizationRequest with locks.routes (to freeze some routes) or locks.disabled_resource_ids (to exclude resources) and just want a normal solve over the rest. There is no special request/response shape beyond the standard OptimizationRequest/OptimizationResponse; the name simply documents intent.
If you need to advance vehicle positions and times based on real-time execution state (completed jobs, current GPS position), use /optimize/replan instead, which builds the locked/advanced request for you. Use /optimize/reoptimize when you have already built that request yourself.
Request body
Full OptimizationRequest with locks populated as needed.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| locks.routes | LockedRoute[] | optional | [] | Each entry: {{resource_id, job_ids: [...]}}, an ordered sequence to freeze for that resource. |
| locks.disabled_resource_ids | string[] | optional | [] | Resources to exclude entirely from this re-solve. |
Response
Full OptimizationResponse.
Examples
curl -X POST https://api.fieldgenius.be/api/v1/optimize/reoptimize \
-H "Content-Type: application/json" \
-H "X-API-Key: your-adapter-key" \
-H "X-Client-Key: your-client-key" \
-d '{
"travel": { "distance_matrix": [[0,6,9,7],[6,0,5,4],[9,5,0,6],[7,4,6,0]] },
"resources": [
{ "id": "van-01", "depot_index": 0 },
{ "id": "van-02", "depot_index": 0 }
],
"jobs": [
{ "id": "stop-a", "location_index": 1 },
{ "id": "stop-b", "location_index": 2 },
{ "id": "stop-c", "location_index": 3 }
],
"locks": {
"routes": [{ "resource_id": "van-01", "job_ids": ["stop-a"] }]
}
}'import httpx
payload = {
"travel": {"distance_matrix": [[0, 6, 9, 7], [6, 0, 5, 4], [9, 5, 0, 6], [7, 4, 6, 0]]},
"resources": [{"id": "van-01", "depot_index": 0}, {"id": "van-02", "depot_index": 0}],
"jobs": [
{"id": "stop-a", "location_index": 1},
{"id": "stop-b", "location_index": 2},
{"id": "stop-c", "location_index": 3},
],
"locks": {"routes": [{"resource_id": "van-01", "job_ids": ["stop-a"]}]},
}
headers = {"X-API-Key": "your-adapter-key", "X-Client-Key": "your-client-key"}
resp = httpx.post("https://api.fieldgenius.be/api/v1/optimize/reoptimize", json=payload, headers=headers)
print(resp.json()["routes"])Errors
| Status | Code | Resolution |
|---|---|---|
| 422 | VALIDATION_ERROR / JOB_NOT_FOUND / VEHICLE_NOT_FOUND | A locked route references a job or resource ID that does not exist in the request. |
| 422 | SOLVER_INFEASIBLE | The locked routes conflict with other constraints. |