Developers
Connect Demurly to your systems
Report waits from your TMS, approve from your AP system, and get every record change by webhook.
This page and the reference are generated from the OpenAPI file the API is tested against.
API keys and webhooks: Carriers need Pro ($199 a month) to set this up; upgrade on Settings > Plan & billing. Fuel buyers get it free.
Guides
- API referenceEvery endpoint and object, generated from the OpenAPI file the API is tested against.
- QuickstartFrom an API key to your first record in five minutes: test-mode keys, your first call, reporting a wait and sending it.
- Record lifecycleThe statuses a record moves through, what moves it and which webhook fires.
- WebhooksDemurly webhooks: event payloads, verifying signatures in Node.js, Python, C# and Go, retries and delivery rules.
- ErrorsEvery Demurly API error code: what causes it, how to fix it and whether to retry, with the request id to quote to support.
- Keep your system in syncPolling with updated_since and cursors, tombstones and webhooks together.
- MCP serverConnect Claude or another AI assistant to your Demurly data with an API key: it reads, and drafts for a person to send.
- Conventions and policiesTimes and time zones, money, IDs, idempotency, versioning, testing and browser use.
- GlossaryDemurrage, detention, free time, BOL, rack and the other terms the API uses.
Prefer Postman or Insomnia? Download the collection, generated from the same OpenAPI file.
Endpoints
Endpoints under /api/v1 for your organization's records, drivers (carriers only), terminals, connections and saved reports (a feed for Power BI, Excel and Tableau). Carriers can report finished waits from their own systems and send records; fuel buyers can approve and dispute them; both can comment. Outbound webhooks push record events to your systems as they happen.
| Endpoint | What it does | Scope |
|---|---|---|
| GET /api/v1/records | List records | records:read |
| POST /api/v1/records | Report a record | records:write |
| GET /api/v1/records/{id} | Get a record | records:read |
| POST /api/v1/records/{id}/send | Send a record | records:write |
| POST /api/v1/records/{id}/approve | Approve a record | records:write |
| POST /api/v1/records/{id}/dispute | Dispute a record | records:write |
| POST /api/v1/records/{id}/comments | Comment on a record | records:write |
| GET /api/v1/records/{id}/photos | List a record's photos | records:read |
| POST /api/v1/records/{id}/photos | Attach a photo | records:write |
| GET /api/v1/records/{id}/photos/{photo_id} | Get a photo | records:read |
| GET /api/v1/drivers | List drivers | drivers:read |
| GET /api/v1/terminals | List terminals | terminals:read |
| GET /api/v1/connections | List connections | connections:read |
| GET /api/v1/reports | List saved reports | reports:read |
| GET /api/v1/reports/{id}/data | Get a saved report's rows | reports:read |
| GET /api/v1/disputes | List disputes | records:read |
| GET /api/v1/disputes/{id} | Get a dispute | records:read |
| GET /api/v1/invoices | List invoices | records:read |
| GET /api/v1/invoices/{id} | Get an invoice | records:read |
| GET /api/v1/invoices/{id}/pdf | Download an invoice PDF | records:read |
| GET /api/v1/stats/terminals | Waits by terminal | analytics:read |
| GET /api/v1/stats/partners | Waits by carrier or buyer | analytics:read |
| GET /api/v1/stats/demurrage | Demurrage by week or month | analytics:read |
| GET /api/v1/stats/aging | Aging | analytics:read |
| GET /api/v1/webhook_endpoints | List webhook endpoints | webhooks:read |
| POST /api/v1/webhook_endpoints | Add a webhook endpoint | webhooks:write |
| GET /api/v1/webhook_endpoints/{id} | Get a webhook endpoint | webhooks:read |
| PATCH /api/v1/webhook_endpoints/{id} | Change a webhook endpoint | webhooks:write |
| DELETE /api/v1/webhook_endpoints/{id} | Delete a webhook endpoint | webhooks:write |
| POST /api/v1/webhook_endpoints/{id}/roll_secret | Roll a signing secret | webhooks:write |
| POST /api/v1/webhook_endpoints/{id}/test | Send a test event | webhooks:write |
| POST /api/v1/webhook_endpoints/{id}/missed_events | Send or skip missed events | webhooks:write |
| GET /api/v1/webhook_endpoints/{id}/deliveries | List deliveries | webhooks:read |
| GET /api/v1/webhook_endpoints/{id}/deliveries/{delivery_id} | Get a delivery | webhooks:read |
| POST /api/v1/webhook_endpoints/{id}/deliveries/{delivery_id}/resend | Resend a delivery | webhooks:write |
| POST /api/v1/test/records | Create a sample charge | records:write |
| POST /api/v1/test/records/{id}/approve | Simulate: the buyer approves | records:write |
| POST /api/v1/test/records/{id}/dispute | Simulate: the buyer disputes | records:write |
| POST /api/v1/test/records/{id}/pay | Simulate: the buyer pays in Demurly | records:write |
| POST /api/v1/test/records/{id}/mark_paid_external | Simulate: the buyer marks it paid outside Demurly | records:write |
| POST /api/v1/test/records/{id}/confirm_payment | Simulate: the carrier confirms an outside payment | records:write |
| POST /api/v1/test/sandbox/reset | Reset the sandbox | records:write |
Keys and scopes
Send an API key as Authorization: Bearer dmrl_.... Organization admins create keys under Settings > API keys and choose their scopes (records:read, records:write, drivers:read, terminals:read, connections:read, reports:read, analytics:read, webhooks:read, webhooks:write). Creating a key, or giving one more access, needs two-step sign-in (2FA) on the admin's account; carriers need the Pro plan, fuel buyers are free. A key acts as the admin who created it: writes are recorded as that person, marked as coming from the API, and stop working if they're no longer an admin.
Keys are live (dmrl_..., your real data) or test (dmrl_test_..., your test-mode sandbox; see Test mode). A company can have up to 25 active keys of each kind; past that, creating one is refused until you revoke one. To replace a key without downtime, rotate it (Settings > API keys > Rotate): you get a new key with the same name, scopes and mode, shown once, and the old key keeps working for the overlap you choose (1 hour, 24 hours or 7 days), then stops. Both are listed with the old one's expiry. A key that expires (after a rotation, or at an expiry it was given) is announced to the company's admins, in the app and by email, 7 days and 1 day before.
The API is server-to-server only. It sends no CORS headers, so a browser refuses a call made from a web page; that's on purpose, because a key is a secret. Keep keys on your server (an environment variable or a secrets store), never in front-end or mobile app code.
| Scope | Allows |
|---|---|
records:read | List and read demurrage records and their history |
records:write | Create records (carriers), send, approve, dispute, comment and attach photos |
drivers:read | List your drivers (carriers only) |
terminals:read | List your configured terminals |
connections:read | List your carrier/customer connections |
reports:read | List your saved reports and read their rows (Power BI, Excel, Tableau) |
analytics:read | Waits by terminal, demurrage by week or month, and aging |
webhooks:read | List your webhook endpoints and their delivery logs |
webhooks:write | Add, change and delete webhook endpoints, roll their signing secrets, send test events and resend deliveries |
Your first request
curl "https://demurly.com/api/v1/records" \
-H "Authorization: Bearer $DEMURLY_API_KEY"Webhooks
Add endpoints under Settings > Webhooks, or with the webhook endpoints API (webhooks:read and webhooks:write scopes): the same rules apply, the signing secret is returned once when you add an endpoint or roll its secret, and each change is in your audit log under the key's name. Each event is a POST with { id, type, created_at, record_id, sequence, occurred_at, data: { record, event } }, signed in X-Demurly-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>"> with the endpoint's secret. Accept the delivery if any v1 matches: after a secret is rolled, deliveries carry one v1 per valid secret (t=...,v1=<new>,v1=<old>) until the old one expires (at once, or after 1 hour, 24 hours or 7 days, as chosen). Answer 2xx within 10 seconds; anything else is retried after 1 m, 5 m, 30 m, 2 h, 6 h, 12 h and 24 h. The event types are listed below (x-webhooks in the spec); new types can be added, so ignore types and fields you don't know.
Delivery is at-least-once and unordered. id is the same on every retry and on a resend: drop an id you've already handled. Each delivery retries on its own schedule, so an older event can arrive after a newer one for the same record. sequence is the event's place in its record's history (it only increases, per record) and occurred_at is when it happened: keep the highest sequence you've applied for each record_id and ignore an event with a lower one (or fetch GET /api/v1/records/{id} for the current state). Sequence numbers have gaps: they count every event in the record's history, and only some of those are webhook events (GPS points, photos and calculations aren't), so 1, 2, 4, 5 is normal. Even the first events can arrive out of order (record.stopped before record.created for a wait reported in one call).
Timing: the first attempt is sent as the event happens. Retries are sent by a job that runs once a minute, so a retry can land up to a minute after its scheduled time. Every failed attempt counts toward the retries, however quickly it failed (a refused connection included).
data.record is the same object the records endpoints return, as it was when the body was first built (the first attempt; retries send the same bytes), not necessarily at the event.
When an endpoint is turned off: Demurly turns an endpoint off only when it has accepted nothing for 3 days and at least 5 events in a row failed every retry (each event is retried for about 45 hours), so an outage of hours never does. The company's admins get an email and an in-app notice. Nothing is lost: deliveries waiting for it pause, and events while it's off are kept for it (paused in the delivery log, also when an admin turned it off). Turn it back on in Settings > Webhooks and send the missed events (or skip them); they arrive with their original id and sequence.
A charge withdrawn from a fuel buyer (sent to another buyer, or taken back for review) sends that buyer record.withdrawn once, with the same tombstone the records endpoints show it (status: withdrawn, withdrawn_reason, withdrawn_at) and nothing from the new round. A cancellation sends record.cancelled instead. If the charge is sent to the buyer again, record.sent starts a new round.
| Event | Sent when |
|---|---|
| record.created | A record was started: a driver started the clock, or a wait was reported through the API, EDI or an import (carriers only) |
| record.stopped | The driver stopped the clock; the record is a draft until submitted (carriers only) |
| record.submitted | A record stopped and is waiting for the carrier's review (carriers only) |
| record.rejected_internal | The carrier's review rejected its driver's record; the buyer never sees it (carriers only) |
| record.reopened | The carrier took a review rejection back; the record is under review again (carriers only) |
| record.sent | The carrier sent a record to the buyer for approval |
| record.approved | The buyer approved a record |
| record.disputed | The buyer disputed a record, with a reason |
| record.escalated | The carrier escalated a dispute |
| record.closed | A disputed record was closed without payment |
| record.offer_accepted | The carrier accepted the buyer's counter-offer from a dispute; the charge is back with the buyer at that amount, to approve |
| record.withdrawn | A charge you were sent was sent to another buyer or taken back for review by the carrier; data.record is the tombstone the API shows you (buyers only) |
| record.cancelled | The carrier cancelled a record (buyers hear only of records sent to them, and get this, not record.withdrawn) |
| record.updated | A record's details or billed times changed (a field edit, or times adjusted, which changes the amount); data.event.type says which |
| record.comment_added | Someone on the carrier or the buyer side commented on a record |
| record.payment_pending | A payment is on its way: a bank payment started in Demurly, or the buyer marked it paid outside Demurly (method and reference in data.event.data) |
| record.payment_failed | A pending payment didn't arrive: a bank payment failed, or the carrier said an outside payment was never received; the record is approved and unpaid again |
| record.paid | A record was paid by card or confirmed paid outside Demurly |
| record.payment_reversed | A card payment was fully refunded or lost to a chargeback; the record is approved and unpaid again |
Good to know
Idempotency
Send an Idempotency-Key header with a write: a unique string of 1 to 255 letters, digits, underscores, periods, colons or hyphens (a UUID is ideal; anything else is 400). A retry with the same key and body returns the first response, with Idempotent-Replayed: true, instead of acting twice. The body must be byte-identical: the same key with a different body (even different spacing or key order) gets 422 IDEMPOTENCY_KEY_REUSED; use a new key when you change the request. A retry while the first request is still running gets 409 IDEMPOTENCY_IN_PROGRESS with Retry-After. Keys last 24 hours. Creating a record requires one.
Only final answers are kept under a key and replayed: 2xx, and 4xx that the same request would get again (400 validation errors, 404, 409 INVALID_STATUS / CONFLICT / OVERLAPPING_WAIT, 413, 415). Answers a retry could change are not kept, and a retry with the same key runs again: 5xx, 401, 403 (for example the key's creator was made an admin again), 429, and the retryable 409s (RECORD_CHANGED, RECORD_LOCKED). So after a 400, fix the request and send it with a new key: the old key answers 422 for the changed body.
Times and time zones
Every time field (start_time, approved_at, occurred_at...) is an ISO 8601 instant in UTC, written with milliseconds and Z (2026-11-07T04:07:00.000Z). Parse them as instants rather than comparing strings. Each record also says where the wait happened: time_zone (an IANA name such as America/Phoenix, from the terminal), start_time_local / end_time_local (the same instants with that zone's offset, e.g. 2026-11-07T21:07:00.000-07:00) and local_start_date (the wait's day at the terminal). The terminal object, and GET /api/v1/terminals, carry the terminal's time_zone.
Money and units
Amounts (amount, amount_approved, hourly_rate, proposed_amount) are US dollars as JSON numbers with up to two decimals (125.5 is $125.50), not cents; the one exception is a payment-rules problem, whose *_cents fields say so in their names. hourly_rate is dollars per hour. Minutes (total_minutes, free_time_minutes, billable_minutes) are whole minutes; billable time is charged in 15-minute steps, rounded up, and billed_minutes is that rounded figure (billable_minutes 62 bills 75).
Rate limiting
Each API key has its own per-minute limit (default 60, configurable from 1 to 1000). A company's keys together are also capped at 3,000 requests a minute; when that ceiling is the tighter one, X-RateLimit-Limit reports it. Responses include X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (the Unix time, in seconds, when the window resets). Over the limit, the API returns 429 RATE_LIMITED with a Retry-After header (seconds); wait that long. Requests with a missing or invalid key are limited too: 60 a minute from one IP address.
Requests and responses
Send JSON bodies with Content-Type: application/json (or a +json type); a non-empty body of any other type gets 415. A write with no body (approve, or send with no options) needs no Content-Type. Unknown query parameters are ignored; a known one with a bad value (limit, cursor, status, include, format) is 400 VALIDATION_ERROR naming it, never silently clamped. Text such as load and BOL numbers and notes is stored exactly as sent. An unknown path under /api/v1 is a JSON 404 NOT_FOUND; a method a path doesn't take is a JSON 405 METHOD_NOT_ALLOWED with an Allow header (and details.allow). A 401 carries WWW-Authenticate: Bearer realm="demurly".
Every response carries X-Request-Id, and every error body repeats it as error.request_id. Log it, and quote it when you write to support: it finds your request in our logs. You can send your own (8 to 64 letters, digits, periods, underscores, colons or hyphens) to tie our logs to yours; otherwise Demurly makes one.
Pagination
The records list is newest first. It returns { "data": [...], "has_more": true, "next_cursor": "..." }: pass limit (1 to 100, default 50) and send next_cursor back as cursor for the next page; on the last page has_more is false and next_cursor is null. Use updated_since to poll for changes: an ISO 8601 date-time with an offset or Z (e.g. 2026-11-01T00:00:00Z; URL-encode a + offset as %2B), from 2000 up to a day from now; anything else is 400. A cursor must be one this API returned; anything else is 400. Treat cursors as opaque: each is a keyset position (a time and an id) within your own company's data, not signed and not tied to one list. Sent to another list it only picks a starting point there, still within your data, so it's harmless but meaningless; always send a list's own next_cursor back to that list. An empty cursor= is the first page.
A charge a fuel buyer was sent never disappears from its view. If the carrier cancels it, sends it to another buyer, or takes it back for review, the buyer's list (and updated_since polls) and GET /api/v1/records/{id} return a tombstone instead (RecordTombstone): its id, record_number, carrier, status: "withdrawn", withdrawn_reason (cancelled, reassigned or recalled) and withdrawn_at, and nothing about what happened to it afterwards. Its updated_at is when it was withdrawn, so a poll sees it once. Close the payable on your side when you see one. A cancellation in your round also sends the record.cancelled webhook; a charge sent to another buyer or taken back has no webhook, so poll or GET it. If the carrier sends it to you again it comes back as an ordinary record. Filter with status=withdrawn to list only tombstones. Writes to a withdrawn charge get 409 INVALID_STATUS. Drivers, terminals and connections page the same way (limit 1 to 1,000, default 1,000; has_more, next_cursor): drivers and terminals oldest first, connections newest first. A saved report's data returns up to 50,000 rows with truncated saying whether more matched.
Versioning
The API's version is in the path (/api/v1). Within v1, changes are additive and can come at any time: new endpoints, new optional request fields, new response fields, new values in a field with a fixed set of values (such as status, source or a webhook's type) and new webhook event types. Write your client to ignore fields and values it doesn't know. A breaking change (removing or renaming a field, changing a type or a meaning, a new required field) only comes in a new version, announced at least 6 months ahead in the changelog and by email to every company with an active key; the old version keeps working for at least 12 months after the new one ships. A deprecated field or endpoint is marked in this file and the changelog first, and keeps working until its version ends.
Test mode
Build and test your integration without touching real charges. Create a test key under Settings > API keys > Test: test mode is free for every company (carriers don't need Pro for it), and creating a test key needs 2FA like any key. A test key works with every endpoint, on your company's sandbox, made on its first call: your test company (<your name> (test mode), of your kind) connected to a test counterparty (a test fuel buyer for a carrier, a test carrier for a fuel buyer), with sample drivers (T-101 to T-103) and terminals. Live and test data never mix: a test key can't see your real records, and a live key can't see the sandbox. Every JSON body an API key gets carries livemode (true for live keys, false for test keys), errors included. An error answered before the key is checked (a missing or invalid key, a body over the size limit, an unknown path) takes livemode from the key's prefix (dmrl_test_ is test), or null when no key was sent.
The sandbox sends no email or text to anyone, takes no payment, records no platform fee, syncs nothing to accounting systems and sends no EDI. Webhooks do fire: test-mode events go only to endpoints you add as test endpoints (Settings > Webhooks), with livemode: false in the body; a live endpoint never gets a test event, and a test endpoint never gets a live one.
To see the other side's moves, test keys can call the simulation endpoints under /api/v1/test (tag Test mode): the sandbox's fuel buyer approves, disputes, pays in Demurly or marks a charge paid outside Demurly; its carrier creates a sample charge (how a fuel buyer's test key receives one) and confirms an outside payment. Each step sends the same webhooks a real one would. POST /api/v1/test/sandbox/reset (or Reset sandbox in Settings > API keys > Test) deletes the sandbox's records; its drivers, terminals and connection stay. Live keys get 403 from /api/v1/test.
What isn't in the API
EDI setup and message history (/api/edi/configurations, /api/edi/messages) are session only: they're managed in the app under Settings > Connected systems > EDI, by a signed-in admin, and an API key gets 401 there. There are no /api/v1 EDI endpoints. Your trading partners send their signed X12 messages to /api/edi/webhook.
Errors
Errors use { "error": { "code", "message", "request_id", "details"?, "hint"?, "field"? } }. Branch on code, which is stable; message is safe to show to people and its wording can change; details comes with some errors only (the field errors of a VALIDATION_ERROR, for example). hint says what to do when there's something specific to do (a missing scope, a record number sent as an id, an expired key, how long to wait), and a VALIDATION_ERROR names its first field in field. Every 429 carries Retry-After. Every code, with its cause, how to fix it and whether to retry, is in the error table.
Every "not allowed in the record's current state" answer is a 409. Its code says whether retrying can help:
- Retry:
RECORD_CHANGED(another action changed the record first),RECORD_LOCKED(a payment is processing, or another wait for the same driver is being created) andIDEMPOTENCY_IN_PROGRESScome withRetry-After(seconds). Wait, then send the same request again (the same Idempotency-Key is fine). - Don't retry:
INVALID_STATUS(the record's status doesn't allow this;details.statusis the status it's in),OVERLAPPING_WAIT(the driver already has a wait at those times;details.record_idanddetails.record_numbername it) andCONFLICT(another state of the record rules it out, such as nothing billable or a buyer's payment terms). Re-read the record and decide.
A 503 SERVICE_UNAVAILABLE with Retry-After means the same change is still being written by an earlier request; retry after that many seconds. A 500 is safe to retry as well.
| Status | Code | When |
|---|---|---|
| 400 | VALIDATION_ERROR | A field, parameter or header is missing or invalid: a bad date, an unknown status, a limit out of range, a cursor this API didn't return, a malformed Idempotency-Key, disputed_minutes longer than the wait, or an offer at or above the charge. details.fields names each one. |
| 400 | BAD_REQUEST | The request can't be done as sent: the body isn't valid JSON, nothing is billable (the wait was within free time), a record has no photo yet (driver-app records; every record created from 2026-12-15, and in test mode now), or the file doesn't match its type. |
| 401 | UNAUTHORIZED | No API key, a malformed Authorization header, or a key that is wrong, revoked, turned off or expired. |
| 403 | FORBIDDEN | The key lacks the scope, its creator is no longer an admin (writes), the company is inactive, or only the other side can do this (only carriers report, send and attach photos; only fuel buyers approve and dispute; only carriers list drivers). |
| 403 | PLAN_LIMIT | The carrier's company isn't on the Pro plan, which the API needs (fuel buyers are free). |
| 404 | NOT_FOUND | No such record, report or path, or one your company can't see (another carrier's record, a draft not yet sent to you). |
| 405 | METHOD_NOT_ALLOWED | The path exists but not with this method (for example DELETE /api/v1/records). |
| 409 | INVALID_STATUS | Final: the record's status doesn't allow this (it's paid, closed, cancelled, already approved, or withdrawn from you); details.status says which. Re-read it; don't retry. |
| 409 | OVERLAPPING_WAIT | Final: the driver already has a wait at these times (or this exact one); details.record_id and details.record_number name it. |
| 409 | CONFLICT | Final: another state of the record rules it out (nothing billable, the buyer's payment terms, a changed amount or offer). Re-read it and decide. |
| 409 | RECORD_CHANGED | Retry: another action changed the record first. Wait Retry-After seconds and send the same request again. |
| 409 | RECORD_LOCKED | Retry: a payment is processing for this record. Wait Retry-After seconds and try again. |
| 409 | IDEMPOTENCY_IN_PROGRESS | Retry: a request with this Idempotency-Key is still running. Wait Retry-After seconds and send it again. |
| 409 | DELIVERY_IN_PROGRESS | Retry: the webhook delivery you asked to resend is being sent right now. Wait Retry-After seconds, then check the delivery log before resending. |
| 413 | PAYLOAD_TOO_LARGE | The body is too big (a photo over 5 MB, a JSON body over its limit), or a saved report's CSV would have more than 50,000 rows. |
| 415 | UNSUPPORTED_MEDIA_TYPE | The Content-Type isn't one this endpoint takes: a JSON endpoint got a body that isn't application/json (or +json), or a photo isn't image/jpeg or image/png. |
| 422 | UNPROCESSABLE | The photo check refused the file: a copy or near copy of a photo on another record, no camera data (from 2026-12-15; test mode now), or taken more than 24 hours before the wait started. details.reasons lists the codes. |
| 429 | RATE_LIMITED | Too many requests this minute: over the key's own limit (60 by default), over the company's 3,000 a minute across all its keys, or over 60 a minute with a missing or invalid key from one IP address. |
| 500 | INTERNAL_ERROR | Something went wrong on Demurly's side. |
| 503 | SERVICE_UNAVAILABLE | The same change is still being written by an earlier request, or Demurly is briefly unavailable. |
Building an integration?
Ready-made connections (QuickBooks, NetSuite, SAP, PDI, EDI) are on Integrations, with step-by-step guides. API changes are posted in the changelog. We answer integration questions by email.