Skip to content
Documentation menu
docs / api / post-optimise-replan
Optimisation and jobs

POST/optimise/replan

Also served at /optimize/replan: the same operation and price.

Access and price

AuthAn API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Needs a full key; a browser (maps) key is refused.
PriceAs POST /optimise, on the remaining problem only: locked stops are not billed (10 calls up to 50 remaining locations). Class: standard, or premium for truck and ADR work. Published as unit_rules.optimise_replan in /pricing.json.
PremiumWhen the body asks for truck routing: "costing": "truck", a top-level adr object or "hazmat": true

What it does

Re-plan a fleet mid-shift. /optimize/replan is an alias.

An API key, as Authorization: Bearer snk_… or ?api_key=snk_…. Metered. Price: As POST /optimise, on the remaining problem only: locked stops are not billed (10 calls up to 50 remaining locations).

Also served at /optimize/replan (the American spelling): the same handler, body, answer and price.

Call it

bash
curl -fsS -X POST "https://api.mapmap.ai/optimise/replan" \
  -H "Authorization: Bearer $MAPMAP_KEY" \
  -H "Content-Type: application/json" \
  -d @request.json

Request body

application/json

The POST /optimise body for the day: vehicles, jobs, shipments, costing, costing_options, adr, emissions, avoid_zones, eu_drivers_hours, plus two re-planning fields. progress: an array of {vehicle, completed_stop_ids[], current_position{lat,lon}, unavailable}, one entry per vehicle that has done something. changes: {cancel_job_ids[], add_jobs[], add_shipments[]} in exactly the /optimise task shapes. Both are optional, but at least one progress entry or one change is required. Completed stops are LOCKED: they are removed from the problem and the reporting vehicle re-plans from current_position (or its last completed stop), so no solver can reschedule them. relax_if_unassigned applies to the REMAINING problem, exactly as on /optimise. A re-plan has NO CLOCK and no memory of the shift so far: time windows are solved from the start of each vehicle's time_window, not from now, and max_tasks, max_travel_time, breaks and capacity are applied to the remaining route in full. Send the time, limits and capacity each vehicle has LEFT; replan.notes names every such field the request carried. Per-vehicle reloads (multi-trip) is NOT supported here and is refused with a 400: a completion in progress does not say which trip it belongs to. Nothing is stored: MapMap keeps no dispatch state, so every re-plan carries the whole day

Example: From website/public/docs/api-reference.md:2904

json
{
  "changes": {
    "add_jobs": [
      {
        "id": 20,
        "location": {
          "lat": 53.9599,
          "lon": -1.0873
        },
        "service_s": 600
      }
    ],
    "cancel_job_ids": [
      12
    ]
  },
  "costing": "auto",
  "jobs": [
    {
      "id": 10,
      "location": {
        "lat": 52.4862,
        "lon": -1.8904
      },
      "service_s": 300
    },
    {
      "id": 11,
      "location": {
        "lat": 53.4808,
        "lon": -2.2426
      },
      "service_s": 300
    },
    {
      "id": 12,
      "location": {
        "lat": 53.8008,
        "lon": -1.5491
      },
      "service_s": 300
    }
  ],
  "progress": [
    {
      "completed_stop_ids": [
        10,
        11
      ],
      "current_position": {
        "lat": 53.4808,
        "lon": -2.2426
      },
      "vehicle": 1
    }
  ],
  "vehicles": [
    {
      "end": {
        "lat": 51.5074,
        "lon": -0.1278
      },
      "id": 1,
      "start": {
        "lat": 51.5074,
        "lon": -0.1278
      }
    },
    {
      "id": 2,
      "start": {
        "lat": 52.4862,
        "lon": -1.8904
      }
    }
  ]
}

Responses

200The re-planned day: exactly the POST /optimise response: summary, unassigned, routes[] and any zones block, covering the REMAINING work, plus a replan block: locked_stops_per_vehicle (the prefix held per vehicle, in order, with the start it re-planned from), released_stops, changes_applied and notes naming every instruction that could not be carried out as asked, plus a relaxation block when relax_if_unassigned was given
FieldTypeRequiredDescription
codeintegerno0 when solved.
eta_calibrationobjectnoThe typical-delay calibration applied to the plan's times.
profilestringnoThe costing the plan was solved for.
relaxationobjectnoConstraints relaxed to find a plan.
replanobjectnoHow the replan was built: basis, mechanism, changes_applied, locked_stops_per_vehicle, released_stops and notes.
routesobject[]noThe new routes, as on POST /optimise.
summaryobjectnoTotals of the new plan, as on POST /optimise.
territoriesnot statednoPer territory polygon the caller sent: the jobs inside it and the jobs the plan assigned. Present when territories were sent.
unassignedobject[]noJobs no vehicle could take.
zonesobjectnoClean-air zone charges at the plan's stops.

Example: Recorded from the hosted gateway on 2026-11-05 with a test key: POST /optimise/replan, two London vehicles, one stop done, one cancelled, one added; lists trimmed to their first items

json
{
  "code": 0,
  "eta_calibration": {
    "applied": true,
    "cells_calibrated": 12,
    "cells_not_walked": 0,
    "cells_unchanged": 4,
    "method": "gb_typical_delay_v1",
    "note": "Local roads in Great Britain carry no live traffic data, so the time on them includes the junction and congestion delay a typical car meets at this time of day, from Department for Transport statistics, on top of the routing engine's free-flowing time: the same delay POST /route adds, applied to the path each cell was costed on. It is a typical figure, not live traffic. Motorways, roads covered by National Highways traffic data and roads outside Great Britain keep the engine's own time.",
    "period": "all_day",
    "sources": [
      "Department for Transport, tables CGN0503 and CGN0504: average speed and delay on local 'A' roads in England, urban and rural, by time of day, rolling year to June 2026"
    ]
  },
  "profile": "auto",
  "replan": {
    "basis": "MapMap stores no dispatch state. Completed stops are locked by removing them from the problem and starting each vehicle where it actually is, so the solver is structurally unable to reschedule them. `routes[]` below therefore cover the REMAINING work only; the locked prefix is reported here, not re-emitted as steps, because its arrival times already happened and we will not invent them.",
    "changes_applied": {
      "added_jobs": [
        20
      ],
      "added_shipments": [],
      "cancelled_jobs": [
        12
      ],
      "completed_stops": 1,
      "vehicles_unavailable": []
    },
    "locked_stops_per_vehicle": [
      {
        "start_basis": "current_position",
        "start_from": {
          "lat": 51.5138,
          "lon": -0.0984
        },
        "stops": [
          10
        ],
        "unavailable": false,
        "vehicle": 1
      }
    ],
    "mechanism": "locked-prefix elision",
    "notes": [],
    "released_stops": []
  },
  "routes": [
    {
      "cost": 472,
      "distance": 2471,
      "duration": 472,
      "service": 600,
      "steps": [
        {
          "arrival": 0,
          "duration": 0,
          "location": {
            "lat": 51.5014,
            "lon": -0.1419
          },
          "service": 0,
          "type": "start",
          "waiting_time": 0
        },
        {
          "arrival": 0,
          "duration": 0,
          "id": 11,
          "location": {
            "lat": 51.5014,
            "lon": -0.1419
          },
          "service": 300,
          "type": "job",
          "waiting_time": 0
        }
      ],
      "vehicle": 2,
      "waiting_time": 0
    }
  ],
  "summary": {
    "cost": 472,
    "distance": 2471,
    "duration": 472,
    "routes": 1,
    "service": 600,
    "unassigned": 0,
    "waiting_time": 0
  },
  "unassigned": [],
  "zones": {
    "at_locations": [
      {
        "assessment": "unknown",
        "currency": "GBP",
        "daily_charge": null,
        "enforcement": "charge",
        "id": "gb-london-lez",
        "locations_inside": 4,
        "name": "London Low Emission Zone",
        "operator": "Transport for London",
        "source": {
          "checked": "2026-09-03",
          "licence": "TfL website content; reuse of tfl.gov.uk page content is restricted by TfL's website terms. These figures are transcribed by hand for citation, not extracted as a dataset.",
          "publisher": "Transport for London",
          "url": "https://tfl.gov.uk/modes/driving/low-emission-zone/make-a-payment"
        },
        "type": "lez"
      },
      {
        "assessment": "unknown",
        "currency": "GBP",
        "daily_charge": null,
        "enforcement": "charge",
        "id": "gb-london-ulez",
        "locations_inside": 4,
        "name": "London Ultra Low Emission Zone",
        "operator": "Transport for London",
        "source": {
          "checked": "2026-09-03",
          "licence": "TfL website content; reuse of tfl.gov.uk page content is restricted by TfL's website terms. These figures are transcribed by hand for citation, not extracted as a dataset.",
          "publisher": "Transport for London",
          "url": "https://tfl.gov.uk/modes/driving/ultra-low-emission-zone/cars"
        },
        "type": "ulez"
      }
    ],
    "basis": "the optimiser is fed a travel-time matrix, not road geometry, so this block reports the zones this problem's own locations sit in and the avoidance applied to the matrix. It does NOT enumerate the zones the driven roads pass through. Route each vehicle's ordered stops through POST /route with the same `emissions` object for that.",
    "caveats": "Zone boundaries are simplified from the published geometry to the tolerance stated on each zone, so a route running within that distance of a boundary may be classified either way. Charges are the published daily amounts as at each zone's `checked` date, quoted per zone per day and never summed into any routing cost; a vehicle crossing the same zone twice in a day pays once, and this estimate does not model residency, disability, historic-vehicle or trade exemptions, discounts, or accounts you may already hold. Verify against the cited source before relying on a figure.",
    "note": "charge depends on vehicle emissions, supply `emissions` (vehicle_category, fuel, euro_standard) to resolve"
  }
}
400Neither progress nor changes; an unknown or duplicated vehicle; a stop two vehicles both claim; an added task whose id is already taken; a vehicle declaring reloads (re-planning a multi-trip problem is not supported); or the underlying problem was invalid

application/problem+json · Problem

401Missing or invalid API key. Also: No key, or a missing, malformed, unknown, revoked or expired one (unauthorized); the body carries signup, docs and a one-call hint for a free key

application/problem+json · Problem

402Beyond the included volume with no way to pay this call: an x402 body naming how to pay (provisional key past its allowance, prepaid balance below the price, or a rejected X-PAYMENT). Not problem+json

application/json · X402PaymentRequired

403The key may not call this: a browser key outside its scope (scope-insufficient), a request from an origin the key does not allow (origin-not-allowed), or an account restriction (forbidden)

application/problem+json · Problem

413The request declares a body larger than 1048576 bytes (plain text, not problem+json)

text/plain

422More than 200 unique locations in the REMAINING problem, or a problem spread wider than the routing engine's max_matrix_distance

application/problem+json · Problem

429Quota or rate limit exceeded. Also: Per-key rate limit (rate-limited, with Retry-After), or monthly quota exhausted with no payment path (quota-exceeded)

application/problem+json · Problem

502The VROOM solver is unreachable or failed

application/problem+json · Problem

503Optimisation is not enabled on this deployment (SN_VROOM_URL unset)

application/problem+json · Problem

504The request did not finish within the gateway's request deadline (request-timeout)

application/problem+json · Problem

Error bodies follow the shared problem model documented on API conventions.

Also under Optimisation and jobs

Generated from https://api.mapmap.ai/openapi.json on 2026-11-12 · operationId post_replan