Load Market
Concepts

Webhooks

Instead of polling GET /get-tracking, Load Market can push tracking updates to an HTTPS endpoint of yours.

Enabling webhooks

Webhooks are configured per partner key by Load Market. Email office@load-market.com with:

  • the HTTPS URL of your endpoint (one for the live key, optionally another for the test key),
  • optionally a bearer token we should send in the Authorization header.

We reply with the signing secret (whsec_...) for each key. Store it like a password.

When updates are sent

Once per minute the server collects every tracking created with your partner key (after webhooks were enabled on it) that changed during the last minute:

  • the driver (or the truck's ELD) reported a new position,
  • the status changed (accepted, rejected, paused, resumed, finished, device issues, ...),
  • the driver uploaded a file (then driverFiles is included),
  • something happened that has an event (the truck arrived at a stop, a Smart Arrival Alert turned late, the carrier approved, ...).

All of them are sent in one POST - the body is a JSON array with one item per tracking. Nothing is sent for a minute in which nothing changed.

A tracking sends updates from its create. Until it reaches the driver's app (a pending installation, a scheduled tracking, an ELD or Hybrid request waiting for the carrier) it sends only items with events, such as carrier.rejected or driver.sms_undeliverable, and their data is the pending shape (TrackingPendingData). Once it starts (driver.installed, tracking.started or carrier.approved) every change is sent. It stops after its final done or cancel update (doneEld or cancelEld for ELD and Hybrid), when the driver of a phone tracking uninstalls the app or deletes the account, or when you delete the tracking. Your own PATCH /stop-tracking also produces the final done (or doneEld) update. A request that is removed without starting (it expired or was deleted) sends nothing more.

Request

Code
POST /your/webhook/endpoint HTTP/1.1 Content-Type: application/json Authorization: Bearer your-configured-token webhook-id: msg_2b7c1f0e-5d3a-4c8e-9b61-7a4f0d2e9c35 webhook-timestamp: 1793644927 webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4= [ { "message": "Ok", "data": { "trackingId": "api-7fK2mQ9xLpR4tN8vB1cD", "status": { "value": "active", "description": "Active" }, "customId": "tms-load-48213", "expDate": 1793800800000, "publicLink": "https://tracking.load-market.com?track=Qm3xT8vN2kLp9RfW4bYc", "driverCoords": { "lat": 39.781721, "lng": -89.650148, "speed": 28.6, "battery": 0.82, "heading": 205, "accuracy": 6, "locationSource": "gps", "lastUpdate": 1793644890000 }, "stopLocations": [] }, "events": [ { "id": "evt_3d8e0c41a7b29f6e15c0d2aa", "type": "stop.arrived", "at": 1793644410000, "stopIndex": 0, "customStopId": "PU-1" } ] } ]

Each item's data has the same shape as the data of GET /get-tracking (TrackingData in the API reference), shortened above, with these differences:

  • stopLocationsEta and driverCoords.location are never included (they exist only on request).
  • driverFiles is included only when the driver uploaded a file.
  • driverCoords is null outside the live window, and on a mobile tracking until the phone sends its first position after the driver accepts - see Tracking lifecycle. A position from the truck's ELD has battery, accuracy and locationSource null - see ELD and Hybrid tracking.
  • fraudAlerts follows the same live window. A change in it alone does not send an update, the current value arrives with the next one - see Potential Fraud Alerts.

Events

Each item's events lists what happened to the tracking since the last delivery, oldest first. It is empty when only the snapshot changed (a new position). The snapshot in data is the state at the time of the delivery, so it can be newer than the last event.

typeWhenExtra fields
driver.installedA pending installation is now in the driver's appstatus, previousStatus
driver.acceptedThe driver accepted the trackingstatus, previousStatus
driver.rejectedThe driver declined it (a Hybrid: the phone side)status, previousStatus
driver.pausedThe driver paused sharingstatus, previousStatus
driver.resumedThe driver resumed sharingstatus, previousStatus
driver.sms_undeliverableThe driver's number can never receive a textreason
driver.sms_opted_outThe driver's number replied STOP
tracking.startedA scheduled tracking startedstatus, previousStatus
tracking.finishedThe tracking finished (done or doneEld)status, previousStatus
carrier.approvedThe carrier approved the ELD sidestatus
carrier.rejectedThe carrier refused or cancelled the ELD side (status cancelEld ends the tracking, a Hybrid keeps its status)status
carrier.pausedThe carrier paused the ELD sidestatus
carrier.resumedThe carrier resumed the ELD sidestatus
stop.arrivedThe truck arrived at a stopstopIndex, customStopId
stop.departedThe truck left a stopstopIndex, customStopId
stop.arrival_clearedA user marked a confirmed arrival as not arrived - undo the arrival you recordedstopIndex, customStopId
stop.departure_clearedA user marked a confirmed departure as not completedstopIndex, customStopId
stop.alert_status_changedA stop's Smart Arrival Alert changed (PRO)stopIndex, customStopId, stopAlertStatus, previousStopAlertStatus
document.uploadedThe driver uploaded a file (it is in data.driverFiles)fileId, fileType

Every event has an id, a type and at (epoch milliseconds, when it happened). New types may be added over time, ignore a type you do not know. An event can arrive more than once - deduplicate by its id.

When the driver cannot receive a text (driver.sms_undeliverable, driver.sms_opted_out), data.driverInvite says why and carries the driver app link (appLink) to share with the driver another way.

Headers

HeaderValue
webhook-idUnique message id, msg_<uuid>. Identical on every retry of the same delivery - use it to deduplicate.
webhook-timestampUnix time in seconds when the message was signed.
webhook-signaturev1,<base64 signature>. It can hold several space-separated entries.
AuthorizationBearer <your token>, only when a token is configured for your key.

Responding and retries

  • Answer with any 2xx within 7 seconds. Do the real work asynchronously (queue the payload, respond, then process).
  • A timeout, a network error, 408, 429 or any 5xx is retried up to 2 more times with a short exponential backoff. A Retry-After (seconds) is honored, capped at 5 seconds.
  • Any other 4xx (for example 400 or 401) is not retried.
  • When every attempt failed, the tracking's events are sent again with its next item, for up to an hour (at most the newest 50 per tracking). The snapshot itself is not redelivered: the next change produces a new update, and you can always read the current state with GET /get-tracking.

Delivery is best effort and an update can arrive more than once: dedupe deliveries on webhook-id and events on their id, apply updates idempotently per trackingId (ignore an item whose driverCoords.lastUpdate is older than what you already stored), and fall back to GET /get-tracking for gaps.

Verifying the signature

Signatures follow the Standard Webhooks specification, so any Standard Webhooks library works. To verify by hand:

  1. Take the part of your secret after whsec_ and base64-decode it - that is the HMAC key.
  2. Build the signed content: `${webhook-id}.${webhook-timestamp}.${raw body}`. Use the raw request body bytes exactly as received - not a re-serialized JSON object.
  3. Compute HMAC-SHA256 of it with the key and base64-encode the result.
  4. Split webhook-signature on spaces. Accept the message when any v1,<signature> entry matches, using a constant-time comparison.
  5. Reject the message when webhook-timestamp is more than 5 minutes away from your clock (replay protection).
import crypto from 'node:crypto'; import express from 'express'; const SECRET = process.env.LOADMARKET_WEBHOOK_SECRET; // whsec_... const TOLERANCE_SECONDS = 5 * 60; export function verifyWebhook(rawBody, headers, secret = SECRET) { const id = headers['webhook-id']; const timestamp = headers['webhook-timestamp']; const signatures = headers['webhook-signature']; if (!id || !timestamp || !signatures) return false; const sentAt = Number(timestamp); const now = Math.floor(Date.now() / 1000); if (!Number.isInteger(sentAt) || Math.abs(now - sentAt) > TOLERANCE_SECONDS) return false; const key = Buffer.from(secret.replace(/^whsec_/, ''), 'base64'); const expected = crypto .createHmac('sha256', key) .update(`${id}.${timestamp}.`) .update(rawBody) // Buffer with the raw request body .digest(); return signatures.split(' ').some((entry) => { const [version, signature] = entry.split(','); if (version !== 'v1' || !signature) return false; const received = Buffer.from(signature, 'base64'); return received.length === expected.length && crypto.timingSafeEqual(received, expected); }); } const app = express(); // express.raw keeps the body as a Buffer - express.json() would lose the exact bytes. app.post('/webhooks/loadmarket', express.raw({ type: 'application/json' }), (req, res) => { if (!verifyWebhook(req.body, req.headers)) return res.sendStatus(401); res.sendStatus(204); // answer first, process afterwards const updates = JSON.parse(req.body.toString('utf8')); // enqueue(req.headers['webhook-id'], updates); });

Test vector

Check your verifier against this official Standard Webhooks vector before going live. With the 5-minute timestamp check turned off (the timestamp is from 2021), it must accept the message, and it must reject it when a single byte of the body changes.

InputValue
Secretwhsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw
webhook-idmsg_p5jXN8AQM9LWM0D4loKWxJek
webhook-timestamp1614265330
Raw body{"test": 2432232314}
Expected webhook-signaturev1,g0hM9SsE+OTPJTGt/tmIKtSyZlE3uFJELVlNIOLJ1OE=

Keys issued before signing was introduced

Partner keys that existed before webhook signing receive their signing secret from Load Market separately. Until you have it, deliveries to those keys are not signed and carry only the bearer token. Once you have the secret, start verifying and reject unsigned requests.

Testing your endpoint

With a test key, every POST /test/simulate call sends one signed webhook with the new state to the URL configured on the test key - once, no retries, 7-second timeout - and returns what your endpoint answered in the webhook object. The item carries the event the simulate stands for in events (driver.accepted, carrier.rejected, ...). This happens only when webhooks are enabled on the test key. Otherwise webhook.attempted is false. See Test mode.

Checklist

  • Verify the signature on the raw body and check the timestamp.
  • Respond with 2xx within 7 seconds. Process asynchronously.
  • Deduplicate deliveries on webhook-id and events on their id. Apply updates per trackingId idempotently.
  • Handle an array with many items, and statuses or fields you do not know yet.
  • Fall back to GET /get-tracking if you suspect you missed an update.
Last modified on