en
Use casesLast-Mile Delivery
Developer view · Courier TMS & same-day

Last-Mile Delivery

You built the courier TMS the fleet runs on. At 7:42 a same-day pharma run lands on full routes — fourteen stops deep, a dock delay behind you — and it has to ride cold.

You may never stand on that dock — but your code decides whether the cold chain holds through the last mile. Re-planning routes by vehicle capability, receiver windows and legal driver hours is the code you don’t want to own. Your app flags the run priority: "p0"; Crisphive resequences routes against capabilities, windows, depot pickups and hours; your app confirms and dispatches.

You’re building
Delivery-orchestration, courier TMS, and retail same-day platforms
On the API for
Dispatchers, drivers on route, and the receiver watching the window

Try it in your language

Pick a scenario, switch the server SDK. Every snippet is the actual call the API reference generates — with delivery values filled in.

Retail drop · schedule a routine stop

POST/job-requestsFull reference
import { Configuration, JobRequestBusinessApi } from "@crisphive/sdk";

const config = new Configuration({ accessToken: "chsk_test_4eC8xQ9mZ2pL7Ka0rT" });
const api = new JobRequestBusinessApi(config);

const res = await api.createJobRequest({
  jobRequestCreateRequest: {
    "customer_id": "a1b2c3d4-0000-4a01-8c01-000000000001",
    "description": "Retail delivery — Zone 4, routine",
    "job_dates": [
      {
        "date": "2026-07-24",
        "periods": [
          {
            "business_view": [],
            "period": "morning"
          }
        ]
      }
    ],
    "job_type_id": "b2c3d4e5-0000-4a02-8c02-000000000002",
    "priority": "p3",
    "skill_ids": [
      "c3d4e5f6-0000-4a03-8c03-000000000003"
    ],
    "sla_deadline": "2026-07-30T17:00:00"
  },
});
const { error_code, message, data } = res.data;

Switch to Go, Ruby, PHP, Java or .NET — the class names, model types and method casing all follow that SDK’s generated conventions. Swap chsk_test_ for chsk_live_ and the same code runs against production.

Three ways this bites

These are the runs that eat a delivery day — each a spoiled load, an over-hours violation, or a window missed by a hand-cut route. Every one maps to a field the API already carries.

1
Dock delay eats the afternoon

The pain ·One 40-minute delay cascades; the route is re-cut by hand, the driver idles, and a receiver window is missed anyway.

Crisphive ·Flag the run priority: "p0" and the emergency re-plan preview resequences the route in one call, protecting every sla_deadline.

2
Cold load on the wrong van

The pain ·A pharmacy order rides a van with no reefer; the spoiled load is a total loss plus a re-delivery — a wasted trip end to end.

Crisphive ·The load’s skill_ids (e.g. reefer) gate the vehicle — only capable vans are eligible.

3
Depot pickup that wasn’t on the clock

The pain ·The depot pickup isn’t modelled, so every ETA is wrong from stop one and the driver blows legal hours catching up.

Crisphive ·Model the pickup in dependencies with real travel time; the plan sequences it before the drops.

Reading the cascade call

The A priority run just hit scenario above is the re-plan itself — it previews the moves so nothing is dispatched until you confirm. Its fields map to the story like this:

FieldWhat it is
emergency_job_idThe priority run driving the re-plan — the windowed stop that has to be honoured.
technician_idThe driver in play for that run — here, the reefer-equipped one.
start_atWhen the run lands — 07:42 in the story.
modeHow hard the solver may push to fit the response (here, allow overtime).
displacement_modeWhat may happen to the stops it moves (here, reschedule them rather than drop them).

The urgency flag from the intro — priority: "p0" — is set when you book or update the run on POST /job-requests (the Retail drop scenario shows a routine p3). The full priority ladder and the allowed values for mode and displacement_mode live in each endpoint’s Full reference.

Hard constraints, not suggestions

A router that ignores these isn’t scheduling — it’s putting a cold load on a dry van. Each one is a first-class field in the API.

The ruleWhat the API enforces
Vehicle capabilityCold chain needs a reefer; an appliance needs a liftgate. Only drivers whose skill_ids cover the load get assigned.
Receiver windowsA confirmed delivery window is a hard sla_deadline. The solver protects windowed stops before loose ones.
Depot pickupsA run that starts at the depot is modelled in dependencies with real travel time — never assumed away.
Driver hours & breaksHours-of-service and break rules are hard constraints. The compliant route is the only route the API returns.
Stop orderPickup before dropoff, returns after deliveries. Sequence is first-class dependencies.

What you ship

You ship routing that survives the dock.

  • No hand-rolled window math — capabilities, receiver windows, depot pickups and hours are API fields.
  • Deterministic ETAs you can stand behind: replay the exact route that broke.
  • Receiver copy comes back with the plan, ready for the status page verbatim.

What their day feels like

One dock delay stops eating the afternoon.

  • Dispatch stops re-cutting routes by hand.
  • Receiver windows are protected; cold rides cold.
  • Drivers’ legal hours hold — the pharmacy order lands on time and nobody else’s route collapses.

Every job has stakeholders

A priority run touches far more than the driver who carries it. Every route is a web of people who feel it when the day drifts — and a tighter operation quietly serves all of them.

In plain sight
The receiver

Gets a window that holds and a live ETA — the parcel arrives when promised, cold still cold.

The dispatcher

Confirms a resequence in one click instead of re-cutting routes by hand mid-shift.

The owner / MD

More drops per driver-hour with fewer spoiled loads and re-deliveries — margin the operation used to leak.

Often invisible — until they’re not
Auditors & finance

Replayable routing reconciles fuel, overtime and failed-delivery costs against the exact plan — granular drift an auditor can point to.

Brand & reputation

On-time, in-condition deliveries protect the brand the courier is carrying — no “where’s my order” escalations.

Drivers & retention

Legal hours and sane routes keep drivers off death-march shifts — the operation keeps its best people.

What you get back, and what gets pushed

The A priority run just hit preview returns the whole plan in data: moves and reassignments (which stop shifts, from and to which driver and time), a total_moves count, and warnings such as TECH_NOT_FEASIBLE — so you can show dispatch the re-plan before you commit it.

To feed the status page the moment a stop moves, register a webhook endpoint and Crisphive POSTs each event to your URL with a Crisphive-Signature header. Verify it against your whsec_… secret over the raw body before you trust the payload — Webhooks has the event shape and copy-paste verify snippets.

Cascades, previews, reads and MCP access are never billed — call the solver on every disruption without architecting around your own bill. The core is a deterministic solver: same inputs, same plan, every time. The LLM only sits at the edges, turning a plan into the message your customer reads.

Start building

The snippet above imports @crisphive/sdk — grab the package for your language, drop in a key, and the same call runs. Every response comes back in one { error_code, message, data } envelope.