
Detention and Demurrage Analytics: A Guide for Canadian Logistics Teams
Detention and demurrage analytics means turning the clocks that run on every container into numbers you can act on before a charge is billed: how many free days are left, which lanes keep going over, which invoices don’t match the tariff. The value comes from joining your shipment events, carrier terms and invoices in one place, then automating the checks nobody has time to do by hand. That is a data integration and workflow problem, which is what we build at Digital Fractal for logistics teams, starting with an AI Readiness Audit that shows which of these data flows can be automated first.
TL;DR
- Demurrage is the charge for a container sitting inside the terminal past free time. Detention is the charge for keeping it outside the terminal past free time. Each runs as a daily clock.
- Useful analytics needs three data sets joined: shipment timestamps, carrier tariff terms (free days and tiers), and invoice lines.
- Track a short list of metrics: dwell time, free days used, cost per lane, and the share of charges you dispute successfully.
- The biggest savings come from alerts before free time ends and automated invoice checks after billing, not from dashboards alone.
- A tailored build on your own TMS and invoice flow is how you get there; we scope this in a 90-day engagement.
Table of Contents
- What you are actually measuring
- Who pays, and why the clock is rarely simple
- The data you need, and where it lives
- Metrics worth putting on the dashboard
- From reporting to prevention
- Where AI helps, and where plain rules do the work
- A practical rollout sequence
- Our perspective
- What a Digital Fractal engagement looks like
- FAQ
- Sources
What you are actually measuring
The two charges are easy to confuse, and your analytics will be wrong if the data model confuses them. UNCTAD defines demurrage as the charge a merchant pays for using a container inside the terminal beyond the free-time period, and detention as the charge for using it outside the terminal or depot beyond free time.
On an import, the clocks are sequential. CMA CGM’s general terms say demurrage runs from discharge from the vessel until the full container gates out. Detention then runs from that gate-out until the empty container gates back in. Each day or part of a day is due in full, and the first chargeable day follows the last day of free time. A container that leaves the terminal at 11 p.m. on its last free day and returns two hours late still costs a whole day.
Two wording traps matter when you build rules:
- Per diem. In most US trades, per diem is another name for detention, but some carriers use per diem for equipment and detention for driver waiting time. Your tariff mapping has to follow each carrier’s language, not a generic dictionary.
- Storage. CMA CGM’s terms state that demurrage and detention do not include storage costs or reefer services, which are charged separately. Keep storage in its own cost category or lane totals will mislead you.
Who pays, and why the clock is rarely simple
According to Maersk, on export the sender pays if the container isn’t loaded within the free days. On import the receiver pays if it isn’t picked up in time. Charges are calculated per day beyond free time at the per-diem rate, and the daily rate rises at each pricing tier. A container that is three days late does not cost three times one day. It can cost much more, because later days land in higher tiers.
Responsibility can also move. Clarksons’ glossary notes that free time is usually two to seven days and that the party responsible is usually the party responsible for the cargo unless the contract says otherwise. A forwarder whose documentation error caused the delay may be the one that pays. Hapag-Lloyd’s US policy, valid from July 2022, also states that charges resulting from customs or quarantine delays are billed to the merchant. Your data should therefore record the cause of each delay, not only its length.
That cause field is what makes disputes winnable. UNCTAD notes that delays in picking up or returning containers are often not attributable to the merchant but to bad weather, labour strikes and terminal congestion. If you can show the terminal was closed or the container was not available, the invoice line becomes negotiable. If you can’t show it, you pay.
For Canadian teams this is practical, not theoretical. A 2025 market report notes elevated congestion at Vancouver and Prince Rupert, which has pushed Canadian operators toward dedicated D&D management. Containers moving inland by rail add another handoff where the clock can run while nobody is watching.

The data you need, and where it lives
Most teams already hold the raw material. It is just scattered across a TMS, carrier portals, email attachments and a finance system. A workable analytics model joins four groups of data.
| Data group | Examples | Where it usually lives |
|---|---|---|
| Shipment events | Vessel arrival, discharge, customs release, gate-out, gate-in empty | Carrier and terminal feeds, TMS |
| Contract terms | Free days by carrier, port, equipment type; tier rates; exceptions | Tariffs, service contracts, PDFs |
| Invoice lines | Charge type, container number, days billed, rate | Carrier invoices, AP system |
| Delay evidence | Appointment records, closure notices, pickup attempts, customs holds | Email, drayage dispatch, broker files |
DHL Global Forwarding explains that free days depend on location, carrier and equipment type. That alone means a single “five free days” setting in a spreadsheet will be wrong for a large share of your boxes. Free time has to be stored per carrier, port and equipment type, with a start date taken from the actual event, not a booking assumption.
The unglamorous part is the invoice side. Carrier invoices arrive as PDFs, and the charge breakdown often has to be read off a scanned page. An academic study from 2025 on automating detention claim approval recommends cleaning, normalizing and enriching incoming data through APIs and ETL pipelines, and using OCR to convert scanned PDFs to text before any language model touches them. We cover that extraction step in our guide to invoice data extraction for Canadian businesses.
Metrics worth putting on the dashboard
A D&D dashboard with forty charts gets ignored. Start with six measures, each tied to a decision someone can make.
- Container dwell time by location. Hours from gate-in to gate-out at the port or ramp, and from gate-out to empty return. This is your early-warning measure.
- Free days used, as a share of free days granted. Containers regularly using 90 percent of free time are one bad day from a charge.
- Share of containers exceeding free time. Track it by carrier, port pair and consignee. Patterns show up here before they show up in your P&L.
- Average days billed per charged container. Separates a few long-running problems from many small overruns.
- D&D cost per lane, per month. The carrier and lane view tells you where to renegotiate free time or change routing.
- Dispute outcomes. Charges disputed, charges credited, and the documentation that won. This is the feedback loop that improves your evidence.
One published guide suggests dwell targets of 18 to 48 hours at origin and 24 to 72 hours at destination, measured from gate-in, gate-out and last-free-day timestamps. Treat any such range as a starting hypothesis and set your own thresholds from your history, because your lanes, rail connections and consignee hours differ.
A worked example
Take a consignee that receives forty containers a month through one port. The tariff gives four free days for demurrage. Your data shows the median container is picked up on day three, but eleven of the forty leave on day five or later. Cut by consignee, nine of those eleven go to two receiving sites with limited dock hours.

That is an analytics result you can act on: the problem is dock capacity at two sites, not carrier performance. The fix might be appointment changes or earlier pickups for those sites, which connects to dock scheduling optimization. Without the consignee cut, the same data looks like a general congestion problem and nothing changes.
From reporting to prevention
Reporting tells you what you paid. Prevention needs three working parts.
Alerts before free time ends
The goal is a warning with enough lead time to act. A useful alert fires from the last free day minus a buffer, and goes to the person who can book the truck or change the appointment, not to a shared inbox. Portcast is one example of the argument that timely milestone alerts and predictive ETAs let teams pick up cargo before free time expires and reroute earlier when congestion builds.
The quality of the alert depends on the quality of the arrival estimate. Rail legs in particular can shift late, which turns a planned pickup into a missed one. Our predictive ETA models guide explains how accuracy and speed trade off when you build these estimates on your own history.
Cost forecasting at the container level
Once free time and tier rates are stored as rules, the system can show each container’s current cost position and what tomorrow’s cost will be if it doesn’t move. Finance gets an accrual estimate. Operations gets a priority list sorted by cost per day, so the container about to enter a higher tier is handled before the one with three days of cheap runway.
Invoice audit after billing
Even with good prevention, some invoices will be wrong or disputable. Matching billed days against vessel movements, free days and contract terms is repetitive work that suits automation. We describe the approach in freight invoice audit automation.
Where AI helps, and where plain rules do the work
Not everything needs a model. Free-time arithmetic is deterministic: given a start event, a free-day count and a tier table, the answer is fixed. The 2025 IJCTT study frames detention-claim automation as a mix of deterministic rule engines for free-time and exception logic plus anomaly detection for repeated claims from specific locations, gaps in event logs and mismatches between reported and system-logged timestamps.
The same study reports that approving a detention claim for driver waiting time can mean manually matching TMS in and out times with proofs of delivery and driver tracking, taking one to two days per claim. It describes AI agents ingesting gate times, GPS container IDs, booking and bill of lading data, carrier schedules and free-time clauses to automate that matching.
A sensible split looks like this:
- Rules: free-time calculation, tier pricing, charge-type mapping, SLA clauses.
- Extraction models: reading tariffs and invoices from PDFs into structured fields.
- Anomaly detection: flagging a location, carrier or consignee whose charges or timestamps look off.
- Agents: assembling the evidence pack for a dispute and routing it for approval.
When decisions affect money and carriers’ claims, you also want a record of why each decision was made. See our guide to AI audit trail systems.
A practical rollout sequence
- Pick one lane or port pair. Start where charges are highest or most frequent. A narrow scope gives you results inside a quarter.
- Inventory the data. List the sources for events, terms, invoices and delay evidence, and who owns each. Gaps in the event log are the most common blocker.
- Digitize the contract terms. Put free days and tier rates by carrier, port and equipment type into a table the system can read.
- Clean and join. Normalize container numbers, time zones and carrier names so a container’s events and invoice lines meet on one record.
- Build the alerts and the six-metric dashboard. Send alerts to named owners with a lead time they can use.
- Automate invoice checks. Compare billed days with computed days and flag the differences with evidence attached.
- Review monthly. Look at dispute outcomes and repeat-offender lanes, and adjust thresholds.
If you are unsure whether your data is ready for this, our enterprise data readiness guide shows how to assess it.
Our perspective
Most D&D problems we see described are not analytics problems at first. They are connection problems: the timestamp is in one system, the free-day clause is in a PDF, and the invoice is in an inbox.
That is why we do not start with a dashboard. Our approach is to map the workflow end to end, find the repetitive steps that cost time and money, and automate those with a solution built around your systems and goals. We do not sell generic, off-the-shelf consulting, and every solution we deliver is customized to the client’s workflows. We aim for tangible results inside 90 days.
For a logistics team, that usually means three things working together: a clean event feed, contract terms the software can read, and automated checks on invoices. Pair them with a predictive ETA and a scheduling layer, and the charges that used to be a surprise become a managed line item.
Souhail
What a Digital Fractal engagement looks like
Our AI Readiness Audit is a one-off engagement priced from $2,500 to $10,000. It identifies the automation opportunities in your operation, including where D&D data, alerts and invoice checks would pay back first. From there we build tailored solutions through workflow automation and an AI scheduling agent for logistics companies, connected to your existing systems. For teams that need software behind it, we also develop transportation management software.

To scope a D&D project, start with the audit page.
FAQ
How much does demurrage cost per day?
It depends on the carrier, port, equipment type and how many days you are past free time. Maersk states that the daily rate rises at each pricing tier, so later days cost more than early ones. Your analytics should store each carrier’s tier table and compute the daily cost per container from it.
How many free days come before demurrage starts?
Clarksons says free time is usually two to seven days. The exact number is set by the carrier’s tariff or your contract and varies by location and equipment type. If a booking is cancelled, CMA CGM’s terms state that free time is set to zero and detention is invoiced.
Who pays detention and demurrage?
Usually the party responsible for the cargo: the sender on export and the receiver on import. A contract can assign it elsewhere, for instance to a forwarder whose documentation error caused the delay. Recording the cause of every delay lets you work out who is responsible and supports a dispute when the delay was outside your control.
What is the difference between detention and demurrage?
Demurrage applies while the container is inside the terminal past free time. Detention applies once it is outside the terminal, from gate-out until the empty is returned. In analytics they are two separate clocks with separate start events, free days and rates.
Sources
- UNCTAD: Demurrage and detention charges in container shipping
- CMA CGM: Demurrage Detention general terms
- Maersk: Manage demurrage and detention charges
- Hapag-Lloyd: US Detention and Demurrage Policies
- Clarksons: What is demurrage?
- DHL Global Forwarding: Demurrage, detention and storage charges
- Go Drayage: Demurrage vs. detention vs. per diem
- IJCTT: Detailed Analysis of Automating Detention Claim Approval
- Dataintelo: Detention and Demurrage Management Platform Market
- Portcast: Detention and Demurrage and the role of visibility
- GoFreight: Freight Logistics Analytics Tools 2026