Skip to content
Developers

Fleet planning

Hand the day's orders and vehicles to one call and get back each driver's route: who takes which order, in what order, and when they arrive. Then find how many vehicles the day needs, re-plan during the day, and measure what the plan saves.

Base URLhttps://makani-gke-eu.lamah.com

From orders to routes

A routing matrix answers how far every point is from every other; a plan decides. Send vehicles and orders, and the solver assigns each order to a vehicle, puts each route in order and times every stop, on Makani's own roads with the country's road closures and time-of-day factors.

  • Vehicles: start and end, capacity (up to five dimensions: parcels, kilograms...), working hours, breaks, skills, most stops, most driving time or distance, and costs.
  • Orders: a job is one stop (a delivery or a pickup); a shipment is a pickup then a delivery on the same vehicle. Each has a place, time at the stop, time windows, a quantity, skills, a priority and a note for the driver.
  • A place is coordinates or an address's publicCode: the stop is then the entrance of its building, and the answer says so (entrance: true).
  • Orders no vehicle can take are listed in unassigned, each with its reason, never silently dropped.

A plan is solved in the background: the call answers its id at once, and the routes follow in seconds (about 36 seconds for 500 orders and 50 vehicles). Use a key with the routing:plan scope.

Send your first plan

Two vehicles leave one depot at 08:00, work until 16:00 with a 30-minute break, carry 20 parcels each and cost 5,000 when used plus 150 a kilometre. Two orders: one with a two-hour window and a note, one given by coordinates.

POST/v1/routing/plansScoperouting:plan
curl -X POST "https://makani-gke-eu.lamah.com/v1/routing/plans" \  -H "x-api-key: $MAKANI_API_KEY" \  -H "content-type: application/json" \  -d '{    "countryCode": "LY",    "name": "Tripoli, Sunday morning",    "departAt": "2026-11-08T08:00:00+02:00",    "objective": "distance",    "vehicles": [      {        "id": "vehicle-1",        "start": {          "publicCode": "LY-F1R5E-2734"        },        "end": {          "publicCode": "LY-F1R5E-2734"        },        "capacity": [          20        ],        "workWindow": {          "start": "2026-11-08T08:00:00+02:00",          "end": "2026-11-08T16:00:00+02:00"        },        "breaks": [          {            "id": "lunch",            "windows": [              {                "start": "2026-11-08T12:00:00+02:00",                "end": "2026-11-08T14:00:00+02:00"              }            ],            "durationSeconds": 1800          }        ],        "costs": {          "fixed": 5000,          "perKm": 150        }      },      {        "id": "vehicle-2",        "start": {          "publicCode": "LY-F1R5E-2734"        },        "end": {          "publicCode": "LY-F1R5E-2734"        },        "capacity": [          20        ],        "workWindow": {          "start": "2026-11-08T08:00:00+02:00",          "end": "2026-11-08T16:00:00+02:00"        },        "breaks": [          {            "id": "lunch",            "windows": [              {                "start": "2026-11-08T12:00:00+02:00",                "end": "2026-11-08T14:00:00+02:00"              }            ],            "durationSeconds": 1800          }        ],        "costs": {          "fixed": 5000,          "perKm": 150        }      }    ],    "jobs": [      {        "id": "order-1001",        "location": {          "publicCode": "LY-F1R3P-1687"        },        "serviceSeconds": 300,        "delivery": [          2        ],        "timeWindows": [          {            "start": "2026-11-08T09:00:00+02:00",            "end": "2026-11-08T11:00:00+02:00"          }        ],        "note": "Ahmed, 091 000 0000"      },      {        "id": "order-1002",        "location": {          "latitude": 32.8705,          "longitude": 13.1653        },        "serviceSeconds": 180,        "delivery": [          1        ]      }    ],    "webhook": {      "url": "https://example.com/hooks/plans",      "secret": "a-long-random-secret-of-yours"    }  }'

The answer is 202 with { id, status: "queued", orderCount }. The plan is checked before it is queued; a refusal (400, 404) is never billed.

  • Times are ISO instants with their offset. departAt is the plan's start and the hour its traffic factors are read at.
  • Ids are yours, unique among vehicles and among orders. They come back as sent.
  • At most 500 orders and 50 vehicles in a plan by default; a country may set lower limits (GET /v1/routing/plans/{id} answers them in a refusal's details).

Read the routes

Read the plan until status is solved or failed, every two seconds or so, or use a webhook. A solved plan has:

GET/v1/routing/plans/{id}Scoperouting:plan
curl "https://makani-gke-eu.lamah.com/v1/routing/plans/3f6b2c1e-8a4d-4f2b-9c7e-5d1a0b2c3d4e" \  -H "x-api-key: $MAKANI_API_KEY"
  • routes: one per vehicle used, with steps in driving order. Each step has its type (start, job, pickup, delivery, break, end), the order's id, its place, arrivalAt, departureAt, waitingSeconds before a window opens, serviceSeconds, distance and driving time since the start, and the load on board after it.
  • Each route's totals, its road line (shape, a polyline at six decimals) and, with costs, its cost.
  • unassigned: each order left out with a reason: NO_ROAD_NEAR, NO_ROUTE, TIME_WINDOW_PASSED, TIME_WINDOW_UNREACHABLE, NO_VEHICLE_WITH_SKILLS, EXCEEDS_CAPACITY, VEHICLE_UNAVAILABLE or PLAN_FULL (not enough vehicles, capacity or hours).
  • summary: orders served and left out, vehicles used, distance, driving, waiting, the day's length and, with costs, the total cost. Reading a plan is free.

Be told when it is done

Give webhook.url (HTTPS) and the plan is posted there once, when it is solved or failed. With webhook.secret, the call is signed with the t=…,v1=… scheme of notification channel webhooks, in its own header (channel webhooks carry it in X-Makani-Signature): X-Makani-Webhook-Signature: t=<unix seconds>,v1=<HMAC of t, a dot and the raw body>. Refuse a t more than five minutes old, so a captured call cannot be sent again. X-Makani-Signature: sha256=<HMAC of the body> still comes too, for receivers written before; it does not stop a replay, so move to the new header. The secret is kept only until the call is made. Check the signature on the raw body before trusting it:

import { createHmac, timingSafeEqual } from "node:crypto" // The header is X-Makani-Webhook-Signature: t=<unix seconds>,v1=<hex HMAC// of "<t>.<raw body>">, keyed with the secret you sent in the plan's// `webhook.secret`.export function verifyPlanWebhook(rawBody, header, secret) {  const parts = Object.fromEntries(    String(header ?? "").split(",").map((part) => part.trim().split("="))  )  const t = Number(parts.t)  if (!t || !parts.v1) return false  // Refuse calls older than five minutes (replays).  if (Math.abs(Date.now() / 1000 - t) > 300) return false  const expected = createHmac("sha256", secret)    .update(`${t}.${rawBody}`)    .digest("hex")  const a = Buffer.from(expected, "hex")  const b = Buffer.from(parts.v1, "hex")  return a.length === b.length && timingSafeEqual(a, b)} // The body: { id, status: "solved" | "failed", summary, error }.// Read the routes with GET /v1/routing/plans/{id}.

What the plan makes small

The solver first serves as many orders as it can, keeping those with a higher priority. Among the plans that serve as many, it keeps the cheapest by the objective:

  • time (the default): the least driving time.
  • distance: the fewest kilometres, when fuel matters more than hours.
  • vehicles: the fewest vehicles, then the least driving: fill each vehicle before adding one.
  • Or give each vehicle its costs: fixed when it is used at all (a driver's day), perHour of driving and perKm, in your own unit (cents, say). A vehicle with costs is planned by them, and each route answers its cost, the summary their total. A van and a motorbike with different costs are then used where each is cheaper.

Profiles: send only the day's orders

Most days use the same fleet, hours and rules. Save them once as a profile in the dashboard (Fleet planning, Profiles), with a name such as tripoli-morning, and a plan names it with profile. The profile fills what the plan leaves out:

  • No vehicles sent: the profile's fleet of vehicleCount vehicles, named vehicle-1, vehicle-2... (or your prefix), from its depot, with its capacity, hours, break, limits and costs.
  • Vehicles sent: each keeps what it gives and takes the rest from the profile.
  • Orders without serviceSeconds take the profile's time at each stop, and a plan without objective takes the profile's.
  • Clock times (workStart, workEnd, the break) are on the day of departAt, in the country's time zone.
POST/v1/routing/plansScoperouting:plan
curl -X POST "https://makani-gke-eu.lamah.com/v1/routing/plans" \  -H "x-api-key: $MAKANI_API_KEY" \  -H "content-type: application/json" \  -d '{    "countryCode": "LY",    "profile": "tripoli-morning",    "departAt": "2026-11-08T08:00:00+02:00",    "jobs": [      {        "id": "order-1001",        "location": {          "publicCode": "LY-F1R3P-1687"        },        "serviceSeconds": 300,        "delivery": [          2        ],        "timeWindows": [          {            "start": "2026-11-08T09:00:00+02:00",            "end": "2026-11-08T11:00:00+02:00"          }        ],        "note": "Ahmed, 091 000 0000"      },      {        "id": "order-1002",        "location": {          "latitude": 32.8705,          "longitude": 13.1653        },        "serviceSeconds": 180,        "delivery": [          1        ]      }    ]  }'
GET/v1/routing/plans/profilesScoperouting:plan
curl "https://makani-gke-eu.lamah.com/v1/routing/plans/profiles" \  -H "x-api-key: $MAKANI_API_KEY"

How many vehicles does the day need?

Send the same orders with vehicleCounts (2 to 8 sizes): each size is planned as its own plan, with the first N vehicles (or the profile's fleet of the largest size). Each plan is billed like any plan: orders × sizes.

POST/v1/routing/plans/sweepsScoperouting:plan
curl -X POST "https://makani-gke-eu.lamah.com/v1/routing/plans/sweeps" \  -H "x-api-key: $MAKANI_API_KEY" \  -H "content-type: application/json" \  -d '{    "countryCode": "LY",    "profile": "tripoli-morning",    "departAt": "2026-11-08T08:00:00+02:00",    "jobs": [      {        "id": "order-1001",        "location": {          "publicCode": "LY-F1R3P-1687"        },        "serviceSeconds": 300,        "delivery": [          2        ],        "timeWindows": [          {            "start": "2026-11-08T09:00:00+02:00",            "end": "2026-11-08T11:00:00+02:00"          }        ],        "note": "Ahmed, 091 000 0000"      },      {        "id": "order-1002",        "location": {          "latitude": 32.8705,          "longitude": 13.1653        },        "serviceSeconds": 180,        "delivery": [          1        ]      }    ],    "vehicleCounts": [      3,      4,      5,      6    ]  }'

Read the sweep: each size's figures, and recommended, the fewest vehicles that serve as many orders as the largest fleet. Compare the distance, driving and cost of the sizes around it before you decide.

GET/v1/routing/plans/sweeps/{sweepId}Scoperouting:plan
curl "https://makani-gke-eu.lamah.com/v1/routing/plans/sweeps/9a1c7e52-0b3d-4e6f-8a2b-1c4d5e6f7a8b" \  -H "x-api-key: $MAKANI_API_KEY"

Plan again during the day

Something changed: a driver finished early, a van broke down, new orders came in. Re-plan from a solved plan and only what changed is sent:

  • completed: orders each vehicle finished; they leave the plan. position: where it is now (else its last completed stop).
  • pickedUp: shipments on board; only their delivery is left, on the same vehicle.
  • pinned (a list, or all) keeps orders on their vehicle; keepOrder keeps its remaining order exactly.
  • available: false takes a vehicle out; its orders move to the others. addJobs, addShipments and cancel change the orders.
  • A re-plan is billed like any plan, one unit per order it solves: the orders still to serve and the ones added. The objective and the profile go on with it.
POST/v1/routing/plans/{id}/replanScoperouting:plan
curl -X POST "https://makani-gke-eu.lamah.com/v1/routing/plans/3f6b2c1e-8a4d-4f2b-9c7e-5d1a0b2c3d4e/replan" \  -H "x-api-key: $MAKANI_API_KEY" \  -H "content-type: application/json" \  -d '{    "departAt": "2026-11-08T12:30:00+02:00",    "vehicles": [      {        "id": "vehicle-1",        "completed": [          "order-1001"        ],        "position": {          "latitude": 32.8641,          "longitude": 13.1902        }      },      {        "id": "vehicle-2",        "available": false      }    ],    "addJobs": [      {        "id": "order-1003",        "location": {          "publicCode": "LY-F1R6T-2889"        },        "serviceSeconds": 240,        "delivery": [          1        ]      }    ],    "cancel": [      "order-1002"    ]  }'

Routes for the drivers

Each route with turn-by-turn directions between its stops, in Arabic or English, from Makani's own street names. Free.

GET/v1/routing/plans/{id}/routes/{vehicleId}Scoperouting:plan
curl "https://makani-gke-eu.lamah.com/v1/routing/plans/3f6b2c1e-8a4d-4f2b-9c7e-5d1a0b2c3d4e/routes/vehicle-1?language=ar" \  -H "x-api-key: $MAKANI_API_KEY"

Or make a link the driver opens on a phone without signing in: the route on a map, its stops in order with times, notes and directions, and a play-through of the day. The token is shown once; the link works until it expires (24 hours by default, 72 at most).

POST/v1/routing/plans/{id}/routes/{vehicleId}/shareScoperouting:plan
curl -X POST "https://makani-gke-eu.lamah.com/v1/routing/plans/3f6b2c1e-8a4d-4f2b-9c7e-5d1a0b2c3d4e/routes/vehicle-1/share" \  -H "x-api-key: $MAKANI_API_KEY" \  -H "content-type: application/json" \  -d '{    "language": "ar",    "hours": 12  }'

Measure what the plan saves

Send what the drivers really did with the plan's orders: each vehicle's orders in the order served. Each route is measured from the depot through its orders and back, on the same roads the plan was solved on, and set beside the plan. Nothing is stored and the call is free.

POST/v1/routing/plans/{id}/actualScoperouting:plan
curl -X POST "https://makani-gke-eu.lamah.com/v1/routing/plans/3f6b2c1e-8a4d-4f2b-9c7e-5d1a0b2c3d4e/actual" \  -H "x-api-key: $MAKANI_API_KEY" \  -H "content-type: application/json" \  -d '{    "routes": [      {        "vehicleId": "driver-ali",        "orders": [          "order-1002",          "order-1001"        ]      }    ]  }'
  • actual, planned and saved: orders, vehicles, distance, driving and, with costs, money. A positive saved is what the plan saves.
  • savedShare: the distance saved as a share of the actual (0.31 is 31% less).
  • unknownOrders: ids sent that the plan does not have; they are left out.
  • Send depot when the actual routes started elsewhere than the plan's first vehicle.

Your own travel times

By default the plan uses Makani's roads. If you already have travel times (your own OSRM, say), send matrix with durations and distances (whole seconds and metres, null where there is no route) and give every point its row with matrixIndex. Makani then asks no engine for the plan; the price is the same.

  • The matrix is square, at most 1,000 points; every point of the plan names a row.
  • Road closures and time-of-day factors are then yours: Makani does not change your numbers.
  • Re-plans, sweeps and actual-route comparisons use the same matrix.

The same plans in the dashboard

Plans sent with a key appear in the console (Fleet planning) beside those made there, with who made them. Dispatchers can:

  • see every route on the map, click a stop for its card, and play the day back to watch each vehicle drive;
  • copy a plan into a scenario, compare up to four plans, try fleet sizes and re-plan;
  • export the stops as CSV, print a sheet per driver, copy or open a driver's link, and upload the actual routes;
  • save and edit the profiles a plan names with profile.

Refusals

A plan is checked before it is queued: these answers come at once, in the usual error envelope, and are never billed. A plan that fails after being queued has status: "failed" and an error with its code.

  • 400PLAN_EMPTYThe plan has no job and no shipment.
  • 400PLAN_NO_VEHICLEThe plan has no vehicle: send vehicles, or name a profile with a vehicleCount.
  • 400PLAN_TOO_LARGEMore orders or vehicles than a plan may hold in this country (details.maxOrders, details.maxVehicles).
  • 400PLAN_DUPLICATE_IDAn id is used twice among the vehicles or among the orders (details.id).
  • 400POINT_OUTSIDE_COUNTRYA point lies outside the country the plan names (details.fields).
  • 400PLAN_PROFILE_COUNTRYThe profile named is for another country.
  • 400PLAN_SWEEP_TOO_MANYA size in vehicleCounts is larger than the vehicles given (details.vehicles).
  • 400PLAN_MATRIX_INVALIDThe plan's own matrix is not square, too large or has a cell out of range (details.reason).
  • 400PLAN_MATRIX_INDEX_MISSINGWith its own matrix, every point of the plan (and an actual route's depot) names its row with matrixIndex.
  • 404ADDRESS_NOT_FOUNDAn end's publicCode is not a published address in countryCode. Never charged.
  • 404PLAN_PROFILE_NOT_FOUNDThe key's project has no profile with that name. GET /v1/routing/plans/profiles lists them.
  • 404PLAN_NOT_FOUNDNo plan with this id belongs to the key's project.
  • 409PLAN_NOT_SOLVEDThe plan is still queued or solving, or it failed: there are no routes to read, re-plan or compare yet.
  • 503ROUTING_PLAN_UNAVAILABLEThe solver is not running now. Only fleet planning is affected; send the plan again later. Never billed.

What it costs

A plan is billed one unit per order (job or shipment) it solves, of product routing-plan, with the matrix, closures and entrances included; a sweep one per order and size; a re-plan one per order it solves. The orders are reserved when the plan is accepted and charged once it is solved; a plan that fails for a reason that is not its input's is not charged. A plan the solver refuses as given (PLAN_INVALID) or cannot finish in its 3 minutes (PLAN_TIMEOUT, not tried again: send fewer orders or vehicles, or split it) is charged like a solved one. Plans made in the dashboard are billed the same way, to the project's billing account. Reading plans, routes, profiles and sweeps, drivers' links and actual-route comparisons are free. Each order weighs 20 units of a plan's included allowance. The price per 1,000 beyond it falls with the month's volume:

Loading prices…