Optimize: Reoptimize

POST /api/v1/optimize/reoptimize

Re-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.

When to use replan instead

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.

NameTypeRequiredDefaultDescription
locks.routesLockedRoute[]optional[]Each entry: {{resource_id, job_ids: [...]}}, an ordered sequence to freeze for that resource.
locks.disabled_resource_idsstring[]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

StatusCodeResolution
422VALIDATION_ERROR / JOB_NOT_FOUND / VEHICLE_NOT_FOUNDA locked route references a job or resource ID that does not exist in the request.
422SOLVER_INFEASIBLEThe locked routes conflict with other constraints.

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