# FreightGate Demurrage & Detention Calculator

> FreightGate Demurrage & Detention Calculator is a paid API for AI agents from api.shippingrates.org, paid per call via x402, $0.1/call, status unknown (last checked 2026-10-13).

Calculates demurrage and detention costs for a specific shipping line, country, container type, and number of days, returning a slab-by-slab cost breakdown with free days and per-diem rates.

## Facts

- Endpoint: POST https://api.shippingrates.org/api/dd/calculate?utm_source=zero.xyz
- Price: $0.1/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/freightgate-demurrage-detention-calculator-36227f07
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_9lcgjIDQQICSvnVCmAW74

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability freightgate-demurrage-detention-calculator-36227f07 -d '<json body>'
```

Example prompt: What are the demurrage and detention costs for a 40HC container on Maersk in India if it's held for 14 days — show me the full slab breakdown with free days and per-diem rates?

## When to prefer this

Use this endpoint when you need a precise, slab-by-slab demurrage and detention cost calculation for a specific shipping line in a specific country, rather than a cross-line comparison. Ideal for logistics agents, freight forwarders, or importers who know their shipping line and need an exact liability estimate before container return.

## Known failure modes

- Unsupported shipping line slug returns validation error
- Country code not covered by the dataset returns empty or error response
- Container type not in supported enum returns 400 bad request
- Days value outside 1–365 range is rejected
- Missing required fields returns schema validation error
- Payment failure (x402 USDC) blocks request from being processed

## How this service works

Calculate demurrage & detention costs for a shipping line, country, container type, and number of days. Returns slab breakdown with free days, per-diem rates, and total cost.

## Output

A JSON object containing the shipping line, country, container type, number of days, the number of free days included, a list of cost slabs (each with from/to day range, rate per day, days in slab, and cost), the currency (USD), and the total cost across all chargeable days.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "days": {
   "type": "number",
   "maximum": 365,
   "minimum": 1,
   "description": "Number of detention days (1-365)"
  },
  "line": {
   "enum": [
    "maersk",
    "msc",
    "cma-cgm",
    "hapag-lloyd",
    "one",
    "cosco",
    "zim"
   ],
   "type": "string",
   "description": "Shipping line slug: maersk, msc, cma-cgm, hapag-lloyd, one, cosco, zim"
  },
  "country": {
   "type": "string",
   "description": "ISO 2-letter country code (e.g. IN, AE, SG, CN, MY, LK, PK, BD, TH)"
  },
  "container_type": {
   "enum": [
    "20DV",
    "40DV",
    "40HC",
    "20RF",
    "40RF",
    "20OT",
    "40OT",
    "20FR",
    "40FR"
   ],
   "type": "string",
   "description": "Container type: 20DV, 40DV, 40HC, 20RF, 40RF, 20OT, 40OT, 20FR, 40FR"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "days": 14,
  "line": "maersk",
  "slabs": [
   {
    "to": 7,
    "cost": 22.5,
    "days": 3,
    "from": 5,
    "rate_per_day": 7.5
   },
   {
    "to": 14,
    "cost": 105,
    "days": 7,
    "from": 8,
    "rate_per_day": 15
   }
  ],
  "country": "IN",
  "currency": "USD",
  "free_days": 4,
  "total_cost": 127.5,
  "container_type": "40HC"
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/freightgate-demurrage-detention-calculator-36227f07/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.shippingrates.org](https://www.zero.xyz/host/api.shippingrates.org/llms.txt)
