The Leonard API lets a company's own systems (a TMS, an ERP, a data warehouse, a customer portal) read its loads, trucks, drivers, invoices, documents and a live load's tracking, file documents, and hear the moment something changes. This is version 1.1.0. The machine-readable version of this page is the OpenAPI 3.1 document.
Getting a key
The API comes with Leonard Enterprise. The company's owner makes keys in Settings, API and webhooks. A key looks like lk_live_ab12… (40 characters). Leonard shows it once, when it is made, and keeps only its fingerprint, so a lost key is revoked and a new one made. Send it on every request:
Authorization: Bearer lk_live_…A key can carry an expiry (30, 90 or 365 days) and a list of addresses it may be used from (single addresses or blocks like 203.0.113.0/24). Several keys can be live at once: to rotate one, make the new key, switch your system over, then revoke the old one. A key stops working the moment it is revoked or expires. Every key made or revoked, and every hour a key is used, is in the company's audit log; every call is kept, without its body, for 13 months.
curl https://desk.leonarddispatch.com/api/v1/loads?limit=2 \
-H "Authorization: Bearer lk_test_…"Scopes
A key does only what its scopes say. A call without the scope it needs answers 403 with the code missing_scope.
| Scope | What it allows |
|---|---|
loads:read | Read loads |
trucks:read | Read trucks |
drivers:read | Read drivers (name and unit) |
invoices:read | Read invoices |
documents:read | Read and download documents |
documents:write | Upload documents |
tracking:read | Read a live load's tracking |
partner:read | Read the program's totals (a partner's key only) |
One shape for everything
The base address is https://desk.leonarddispatch.com/api/v1. Every answer is JSON, except a document download.
- Lists answer
{ "data": [ … ], "next_cursor": "…" }, the latest change first. Passnext_cursorback as?cursor=for the next page; it isnullon the last one. Every row is returned once across the pages.?limit=is 1 to 200 (default 50). - Keeping a copy in step:
?updated_since=2026-11-15T00:00:00Zreturns only rows changed at or after that time. - Times are ISO 8601 in UTC, like
2026-11-15T14:02:11.482Z. - Money is a whole number of cents beside a
currency:"rate_cents": 285000, "currency": "USD". - Every answer carries a
Request-Idheader. Quote it when you write to us. - Never in the API: a driver's phone number, email or licence, a message, a text, or a document's extracted text.
Endpoints
Loads
GET /loadsloads:readlimit · cursor · updated_since · statusGET /loads/{id}loads:readTracking
GET /loads/{id}/trackingtracking:readlimit · cursorTrucks
GET /truckstrucks:readlimit · cursor · updated_since · statusDrivers
GET /driversdrivers:readlimit · cursor · updated_since · statusInvoices
GET /invoicesinvoices:readlimit · cursor · updated_since · statusGET /invoices/{id}invoices:readDocuments
GET /documentsdocuments:readlimit · cursor · updated_since · load_id · document_typePOST /documentsdocuments:writeIdempotency-Key (header)GET /documents/{id}documents:readGET /documents/{id}/downloaddocuments:readPartner totals
GET /partner/overviewpartner:readGET /partner/pilotpartner:readThe spec
GET /openapi.jsonno key neededUploading a document:
curl https://desk.leonarddispatch.com/api/v1/documents \
-H "Authorization: Bearer lk_live_…" \
-H "Idempotency-Key: pod-EX-1004-2026-11-15" \
-F document_type=pod \
-F load_id=6f1c… \
-F file=@pod.pdfThe Idempotency-Key is any string of yours, up to 200 characters, unique to the upload. If the request times out, send it again with the same key: you get the first document back (with Idempotent-Replayed: true) and no second one is made. The same key with a different file answers 422. Keys are remembered for 7 days.
Records
Load
| Field | Type | |
|---|---|---|
id | string | A uuid. |
reference | string or null | |
broker_reference | string or null | |
status | one of a fixed list | |
origin | { city, state } | |
destination | { city, state } | |
pickup_appointment | time or null | |
delivery_appointment | time or null | |
equipment | string or null | |
rate_cents | integer or null | The linehaul rate, in cents. |
projected_net_profit_cents | integer or null | Leonard's projected net profit on the load, in cents. |
currency | "USD" | ISO 4217. Leonard keeps US dollars. |
rate | number or null | Deprecated. The rate in dollars. Kept for keys made before 2026-11-15; read rate_cents. |
projected_net_profit | number or null | Deprecated. In dollars. Read projected_net_profit_cents. |
miles | number or null | |
verdict | TAKE | COUNTER | BACKUP | SKIP | WAIT | REPOSITION or null | |
truck_id | string or null | |
driver_id | string or null | |
broker_id | string or null | |
delivered_at | time or null | |
paid_at | time or null | |
created_at | time | ISO 8601, UTC. |
updated_at | time | ISO 8601, UTC. |
TrackingEvent
| Field | Type | |
|---|---|---|
id | string | |
type | position | dispatched | arrived_pickup | loaded | departed_pickup | arrived_delivery | |
at | time | ISO 8601, UTC. |
source | string or null | Where it came from: eld, driver_link, text, driver_sms, dispatcher or system. |
lat | number or null | |
lng | number or null | |
speed_mph | number or null | |
heading | number or null |
Truck
| Field | Type | |
|---|---|---|
id | string | A uuid. |
unit_number | string or null | |
state | string or null | The one state the truck is in: empty_soon, searching, offered, booked, in_transit, at_dock, delivered, paperwork, invoiced or paid. |
empty_at | time or null | |
equipment | string or null | |
trailer_type | string or null | |
year | number or null | |
make | string or null | |
model | string or null | |
driver_id | string or null | |
current_load_id | string or null | |
carrier_id | string or null | |
updated_at | time | ISO 8601, UTC. |
Driver
A driver: the name and the unit. Never a phone number, an email, a licence or a home address.
| Field | Type | |
|---|---|---|
id | string | A uuid. |
full_name | string | |
unit_number | string or null | The unit the driver is on. |
status | string or null | |
carrier_id | string or null | |
updated_at | time | ISO 8601, UTC. |
Invoice
| Field | Type | |
|---|---|---|
id | string | A uuid. |
number | string | |
kind | string | |
status | draft | issued | submitted_to_factor | paid | void | |
load_id | string or null | |
broker_id | string or null | |
carrier_id | string or null | |
subtotal_cents | integer | A whole number of cents. |
total_cents | integer | A whole number of cents. |
paid_cents | integer | A whole number of cents. |
currency | "USD" | ISO 4217. Leonard keeps US dollars. |
issued_at | time or null | |
due_at | time or null | |
submitted_at | time or null | |
paid_at | time or null | |
created_at | time | ISO 8601, UTC. |
updated_at | time | ISO 8601, UTC. |
Document
A document's facts. The file itself is GET /documents/{id}/download; its text is never in the API.
| Field | Type | |
|---|---|---|
id | string | A uuid. |
document_type | one of a fixed list | |
name | string or null | |
content_type | string or null | |
size_bytes | integer or null | |
load_id | string or null | |
invoice_id | string or null | |
truck_id | string or null | |
driver_id | string or null | |
broker_id | string or null | |
carrier_id | string or null | |
expires_on | string or null | A date, YYYY-MM-DD, for a document that runs out. |
created_at | time | ISO 8601, UTC. |
PartnerOverview
| Field | Type | |
|---|---|---|
enough | boolean | False while fewer than five carriers are in the program's totals; then there are no totals. |
message | string | |
as_of | string | The day of the snapshot, YYYY-MM-DD. Totals change once a day. |
invited | number | |
metrics | object | The console's totals. Each measure is { n, v }. |
trend | list of object |
PartnerPilot
| Field | Type | |
|---|---|---|
enough | boolean | |
message | string | |
pilot | boolean | |
start | string or null | |
at_start | { date, measures } | |
today | { date, measures } |
The sandbox
In Settings, API and webhooks, Make a test key gives a key that starts lk_test_. It works on every endpoint above and reads a sandbox of example data (six example loads, one of them live with tracking, three invoices, four documents you can download), never the company's own. Uploads with a test key land in the sandbox. Test keys are rate-limited the same way as live ones. A sandbox never posts a webhook.
Webhooks
In Settings, API and webhooks, add an https address and pick what it hears about. Leonard posts JSON to it the moment the thing happens.
| Event | When |
|---|---|
load.created | A load is created |
load.status_changed | A load changes state |
load.delivered | A load is delivered |
document.added | A document is added |
invoice.created | An invoice is made |
invoice.sent | An invoice is sent |
invoice.paid | An invoice is paid |
{
"id": "a5e0…",
"type": "load.status_changed",
"created_at": "2026-11-15T14:02:11Z",
"data": { "id": "6f1c…", "reference": "LD-10482", "status": "in_transit", "previous_status": "booked", "truck_id": "…", "driver_id": "…", "broker_id": "…", "updated_at": "2026-11-15T14:02:11Z" }
}A payload carries ids and what changed, never the whole record, a document's contents or anyone's phone or email. Read the record with its id when you need the rest. The headers are Leonard-Event, Leonard-Delivery (the same id on every retry and every redelivery, so you can drop a repeat) and Leonard-Signature.
Verifying a webhook
Leonard-Signature: t=1763215331,v1=5f2c…. t is when Leonard sent it, in Unix seconds. v1 is HMAC-SHA256, in hex, of t, a full stop and the raw body, keyed with the endpoint's signing secret (whsec_…). Check the signature against the raw body, and refuse a t more than 5 minutes old, so a post someone captured can't be sent to you again later.
Node
import { createHmac, timingSafeEqual } from "node:crypto";
// secret: the endpoint's signing secret (whsec_…)
// rawBody: the request body exactly as it arrived, before any JSON parsing
// header: the Leonard-Signature header
export function fromLeonard(secret, rawBody, header, nowSeconds = Date.now() / 1000) {
const parts = header.split(",").map((p) => p.trim().split("="));
const t = Number(parts.find(([k]) => k === "t")?.[1]);
// Refuse anything older than 5 minutes: a captured post can't be replayed later.
if (!Number.isFinite(t) || Math.abs(nowSeconds - t) > 300) return false;
const want = createHmac("sha256", secret).update(t + "." + rawBody).digest();
// After a secret is rotated there are two v1 values for 24 hours; either may match.
return parts.some(([k, v]) => {
if (k !== "v1" || !v) return false;
const got = Buffer.from(v, "hex");
return got.length === want.length && timingSafeEqual(got, want);
});
}Python
import hashlib, hmac, time
# secret: the endpoint's signing secret (whsec_…)
# raw_body: the request body as bytes, exactly as it arrived
# header: the Leonard-Signature header
def from_leonard(secret: str, raw_body: bytes, header: str, now: float | None = None) -> bool:
parts = [p.strip().split("=", 1) for p in header.split(",")]
t = next((v for k, v in parts if k == "t"), None)
if t is None or not t.isdigit():
return False
# Refuse anything older than 5 minutes: a captured post can't be replayed later.
if abs((now if now is not None else time.time()) - int(t)) > 300:
return False
want = hmac.new(secret.encode(), t.encode() + b"." + raw_body, hashlib.sha256).hexdigest()
# After a secret is rotated there are two v1 values for 24 hours; either may match.
return any(k == "v1" and hmac.compare_digest(v, want) for k, v in parts)Rotating a secret
Rotate gives the endpoint a new secret. For 24 hours each post carries two v1 values, the new secret's and the old one's, so your system keeps verifying while you switch it over.
Retries
Answer with any 2xx within 10 seconds. Anything else is tried again 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, 14 hours and 24 hours after the first try, then marked not delivered. After 50 failures in a row the endpoint is paused; the owner gets an email and a card on the Desk, and turns it back on in Settings. A delivery that failed can be sent again from there with Redeliver. Leonard doesn't follow redirects. The last posts, and what each answered, are kept for 30 days.
Rate limits
600 requests a minute per key, live or test. Every answer says where you stand: RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset (seconds until the minute starts again). Past the limit the answer is 429 with Retry-After.
Errors
Every error has one shape. Branch on the code; show the message to a person; send us the request id.
{ "error": { "code": "missing_scope", "message": "This key doesn't carry the invoices:read scope.", "request_id": "req_4f0c…", "status": 403 } }| Status | Code | What happened |
|---|---|---|
| 400 | invalid_request | A parameter or a field is wrong; the message says which. |
| 401 | unauthorized | No key, a key that isn't one of ours, or one that was revoked. |
| 401 | key_expired | The key's expiry date has passed. |
| 403 | ip_not_allowed | The key has an address allowlist and the call came from outside it. |
| 403 | missing_scope | The key doesn't carry the scope this endpoint needs. |
| 403 | wrong_key_kind | A partner's key called a carrier endpoint, or a company's key called a partner one. |
| 403 | plan_required | The company's plan, or the partner's contract, doesn't include the API. |
| 403 | company_closed | The company asked to be deleted. |
| 404 | not_found | Nothing of yours has that id. |
| 409 | idempotency_in_progress | The first request with this Idempotency-Key is still being worked. Try again shortly. |
| 413 | payload_too_large | The file is over 25 MB. |
| 415 | unsupported_media_type | The upload isn't multipart/form-data, or the file isn't a PDF or a photo. |
| 422 | idempotency_key_reused | This Idempotency-Key was already used with a different file or different fields. |
| 429 | rate_limited | Too many requests. Retry-After says how many seconds to wait. |
| 500 | server_error | Leonard couldn't answer just now. Try again; if it persists, send us the request id. |
Versioning
The version is in the path. Within /api/v1 we add endpoints, fields and events, and never remove or rename one or change what it means; write your client to ignore fields it doesn't know. A breaking change means /api/v2, and /api/v1 keeps working for at least 12 months after v2 ships, with the date in the changelog below.
Partner keys
A partner program whose contract includes the API can make a key in its console. A partner's key reads the program's totals, the same ones the console shows, from the same once-a-day snapshot, and nothing else: never a single carrier, never a number with fewer than five carriers in it. It answers 403 on every carrier endpoint.
Changelog
1.1.0 · November 15, 2026
- Scopes replace the single read scope: loads:read, trucks:read, drivers:read, invoices:read, documents:read, documents:write and tracking:read. A key made before today keeps working, as every :read scope.
- A key can carry an expiry and an address allowlist, and several keys can be live at once, so a key is rotated without downtime.
- New endpoints: invoices, documents (list, download, and upload with an Idempotency-Key) and a live load's tracking events.
- One shape: money in whole cents beside a currency (rate_cents; rate in dollars stays, deprecated), times in UTC, updated_since on every list, one error format with a code and a request_id, and a Request-Id header on every answer.
- Rate limits are per key, 600 requests a minute, with RateLimit-Limit, RateLimit-Remaining and RateLimit-Reset on every answer.
- Drivers answer with the name and the unit. home_base and hours_left_minutes are no longer returned.
- Webhooks: new events document.added and invoice.sent; payloads carry ids and what changed, not the whole record; a signing secret can be rotated, and the old one verifies for 24 hours; retries now run for 24 hours; a failed delivery can be sent again from Settings.
- Test keys (lk_test_…) read a sandbox of example data.
- An OpenAPI 3.1 document at /api/v1/openapi.json.
- Partner keys read a partner program's totals at /partner/overview and /partner/pilot.
1.0.0 · November 8, 2026
- The first version: loads, a load by id, trucks and drivers, read with a key; webhooks for loads and invoices, signed, with retries.