Calculate Demurrage & Detention Costs
shippingrates_dd_calculateCalculate demurrage and detention (D&D) costs for one carrier in one country.
Use this when the user needs a detailed cost breakdown for a specific carrier. Returns free days, per-diem rates for each tariff slab, and total cost. This is the core tool for logistics cost analysis — it answers "how much will I pay if my container is detained X days?"
To compare D&D costs across all carriers at once, use shippingrates_dd_compare instead.
By default this returns carrier detention/demurrage. Pass charge_type="storage" to instead get TERMINAL port storage — a distinct charge billed by the terminal, not the carrier, and never mixed into the default D&D answer. Storage coverage is thin — only a handful of carrier/country lanes have it. Any uncovered combo returns an explicit 'no data' error (never a false $0), and that error names the lanes that ARE covered, derived live from the database rather than from a hardcoded list that would go stale.
PAID: $0.10/call via x402 (USDC on Base or Solana). Without payment, returns 402 with payment instructions.
Returns: { line, country, container_type, days, free_days, breakdown, total_cost, currency, charge_type_served, charge_family: 'carrier_dd'|'terminal_storage' }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | Yes | Number of detention days | |
| line | Yes | Shipping line slug — maersk, msc, cmacgm (or cma-cgm), hapag-lloyd, one, cosco, zim, evergreen, yangming, hmm, arkas, oocl, pil | |
| country | Yes | ISO 2-letter country code (e.g. IN, AE, SG) | |
| direction | No | import or export (default import) | |
| x_payment | No | x402 payment proof header (optional — required for paid access) | |
| charge_type | No | Override the charge type; default is the engine's detention→demurrage→combined priority. 'storage' is a distinct TERMINAL charge (not carrier D&D) and is ONLY ever returned when explicitly requested here — thin coverage, see tool description. | |
| container_type | Yes | ISO 6346 container type — 20GP, 40GP, 40HC, 20RF, 40RF, 20OT, 40OT, 45HC, 40FR, 20FR, 40DG, 20DG, 45RF, 45OT, 45DG, 40TK, 20TK, 45GP, 45TK, 40NOR |