Detention and Demurrage Fees API

Overview

The Detention and Demurrage Fees API is designed to provide you with a breakdown of operational fees for international ocean shipments. It supports advanced tariff calculations, fee modeling, and clear visibility into cost components, currently focusing on Detention and Demurrage (D&D) fees at the Destination stage. Future versions will include a broader fee support across the Origin, Freight, and Destination legs of a shipment.

API Response Structure

Top-level Response Object

The API response is organized as follows:

  • Each response includes a list of trackedShipments, while each shipment contains a rates object.
  • Shipment’s rates contain a breakdown by Origin, Freight, and Destination.
  • Fees are organized by buy and sell sides, with associated contract IDs, fees, currencies, and billable day structures.

Rate Structure

A rate includes fees of the the following three types that correspond to a shipment journey legs:

  • Origin (to be implemented in a future version)
  • Freight (to be implemented in a future version)
  • Destination

The following Destination fee sub-types are currently supported:

  • Demurrage: Fees for container storage at the terminal beyond free days
  • Detention: Fees for holding containers outside the terminal after pickup and before return
  • Combined: A merged fee covering both demurrage and detention under a single structure
  • Carrier storage: Fees charged by the carrier for container storage, usually at port facilities or inland depots

Buy and Sell

  • Buy: What the forwarder pays to the carrier
  • Sell: What the forwarder charges the customer. Sell calculations are optional and may return null if the contract data is missing or not configured.

Request Example

query TrackedShipments($filterBy: [FilterByInput!]) {
  trackedShipments(filterBy: $filterBy) {
    data {
      shipment {
        rates {
          destination {
            dnd {
              total
              currency
              response {
                code
                message
              }
              buy {
                contractId
                currency
                response {
                  code
                  message
                }
                totalFees
                fees {
                  ... on DndFeeDetails {
                    feeType
                    mappingId
                    daysCalculation {
                      code
                      description
                    }
                    totalCharges
                    currency
                    billableDays
                    paymentTiers {
                      numberOfDays
                      costPerDay
                      actual {
                        startDate
                        endDate
                        totalDays
                        billableDays
                        totalCharges
                      }
                    }
                  }
                }
              }
              sell {
                contractId
                currency
                totalFees
                fees {
                  ... on DndFeeDetails {
                    feeType
                    mappingId
                    daysCalculation {
                      code
                      description
                    }
                    totalCharges
                    currency
                    billableDays
                    paymentTiers {
                      numberOfDays
                      costPerDay
                      actual {
                        startDate
                        endDate
                        totalDays
                        billableDays
                        totalCharges
                      }
                    }
                  }
                }
                response {
                  code
                  message
                }
              }
            }
          }
        }
      }
    }
  }
}

GraphQL Variables

{
  "filterBy": [
    {
      "field": "shipment_id",
      "values": ["Add Shipment ID here"]
    }
  ]
}

Fee Object Structure

Each fee object, under either buy or sell, includes:

FieldDescription
feeTypeType of fee (demurrage, detention, etc.)
daysCalculationLogic for calculating days (e.g., calendar vs. working days)
totalChargesCalculated monetary value for the fee
billableDaysNumber of billable days based on the tariff
currencyISO currency code
paymentTiersBreakdown of charges by day ranges or rate brackets
actualActual dates the fee applied (with startDate, endDate, totalDays, and billableDays)
tariffIdInternal reference to the applied tariff
mappingIdIdentifier linking to internal mapping logic or external rules

Error Handling

These errors occur when the system fails to map the shipment to a valid contract or tariff due to missing or mismatched data:

Error NameDescription
MISSING_SHIPMENT_DETAILSRequired shipment data (e.g., dates, locations) is missing or incomplete
MISSING_ORGANIZATION_IDThe shipment is not associated with a valid organization ID
MISSING_PODPort of discharge (POD) is missing from the shipment details
MISSING_POLPort of loading (POL) is missing from the shipment details
MISSING_ISO_CODEContainer type (ISO code) is missing and is required for tariff matching
NO_TARIFFS_FOUNDNo tariffs are available that match the shipment criteria
NO_BUY_CONTRACT_ID_NO_STANDARDNo buy contract ID was provided, and no matching standard tariff was found
NO_SELL_CONTRACT_IDNo sell contract ID was provided for the shipment
NO_MATCHING_FIELDS_STANDARDNone of the standard tariff rules matched the shipment fields
OUTSIDE_VALIDITY_RANGE_STANDARDShipment falls outside the validity period of any matching standard tariff
NO_STANDARD_TARIFFS_FOR_SCACNo standard tariffs were found for the carrier (SCAC code)
NO_VALIDITY_EVENT_STANDARDStandard tariff validity could not be determined due to missing or invalid event dates
NO_MATCHING_CONTRACT_IDA contract ID was provided, but no matching contract was found
NO_MATCHING_FIELDSThe contract was found, but its conditions do not match the shipment details
OUTSIDE_VALIDITY_RANGEThe contract exists but is not valid for the shipment’s dates
NO_VALIDITY_EVENTRequired event dates (e.g., gate-in, discharge) are missing, so contract validity cannot be checked

Fee Calculation Response Codes

These response codes indicate the status of the fee calculation process for the buy and sell sides, and help identify missing or inconsistent data affecting the results:

Status CodeDescription
OKThe fee calculation completed successfully with all required data.
MULTI_CURRENCYFee calculation could not be completed because buy and sell fees use different currencies.
MISSING_FEESBoth buy and sell fee data are missing, so no calculation can be performed.
MISSING_BUY_FEESBuy-side fee data is missing, preventing accurate cost or profit calculation.
MISSING_SELL_FEESSell-side fee data is missing, so profit and loss cannot be determined.