# Panvaya Logistics API documentation

Public developer guide: https://panvaya.com/developers
OpenAPI 3.1 specification: https://api.panvaya.com/api/v1/openapi.json
Pricing and access: https://panvaya.com/pricing

These examples describe the public API contracts; they do not run requests.
Keep API keys server-side. Both test and live keys can contact real providers and consume credits.
Read the organization's configured product costs and limits before starting a billable workflow.
Example responses are illustrative snapshots, not current shipment or vessel observations.

## Guides by product

- [Ocean container tracking](https://panvaya.com/developers/docs/ocean.md)
- [Air cargo tracking](https://panvaya.com/developers/docs/air.md)
- [Sailing schedules](https://panvaya.com/developers/docs/schedules.md)
- [Freight carbon estimates](https://panvaya.com/developers/docs/carbon.md)
- [CBAM and maritime ETS estimates](https://panvaya.com/developers/docs/cbam.md)
- [Sea distance and transit time](https://panvaya.com/developers/docs/distance-time.md)
- [Vessel details and AIS positions](https://panvaya.com/developers/docs/vessels.md)
- [Port congestion](https://panvaya.com/developers/docs/port-congestion.md)
- [Incoterms reference](https://panvaya.com/developers/docs/incoterms.md)
- [Credit usage and billing ledger](https://panvaya.com/developers/docs/usage.md)
- [Demurrage and detention tariffs](https://panvaya.com/developers/docs/dnd-tariffs.md)
- [Ocean tracking webhooks](https://panvaya.com/developers/docs/webhooks.md)
- [Embedded tracking](https://panvaya.com/developers/docs/embedding.md)

## API pricing, access and integration

### How much does the Panvaya tracking API cost?
At public default rates, Tracking starts at $10 per 30 days with 20 shared Ocean/Air shipments and 1,200 API credits. Ocean tracking costs 2 credits per successful API response and Air tracking costs 5 by default, including cache hits. Organization-specific rates and product access remain authoritative; check the usage endpoint before a billable workflow.

### Do Web and API tracking use separate shipment allowances?
No. Ocean and Air tracking share one shipment allowance across Web and API. Web refreshes consume no API credits. Successful API calls consume the configured credits even when served from cache, while repeat API tracking of the same enrolled reference in one billing cycle does not add another distinct shipment. API errors are not billed.

### How do I get a container tracking API key?
Sign in to the Panvaya API Dashboard and select Create API key. Choose Sandbox (test) for development or Live for production. Send the key in the X-API-Key header from your server or integration backend. Store it in a secret manager or server-side environment variable.

### Does the sandbox return mock tracking data?
Sandbox keys use the same endpoints, response contracts and workspace limits as live keys. Tracking requests can contact real carriers and consume your workspace's credits and shipment allowance. Use the published JSON examples as fixtures for offline tests. Start with the unbilled GET /api/v1/usage request to verify your key and check available products, configured rates and remaining allowances before trying tracking.

### Are sailing schedules charged per sailing or per carrier?
The public default is 5 credits for each carrier returning usable sailings, regardless of how many sailings that carrier returns. Empty or failed carriers cost zero. Partial and cached results with usable sailings can be billable; your organization's configured price is authoritative.

### How do I connect Panvaya to a TMS or ERP?
Your backend or middleware keeps the API key server-side, calls the documented endpoints and maps the returned JSON to your own shipment records. The integration guide includes shared Ocean/Air request examples, field mappings and starter downloads. Scheduled Ocean webhooks and embedded tracking are also documented. These are integration building blocks, not a claim of a native vendor connector.

### Worked Ocean API example
100 ocean containers checked twice daily
100 containers × 2 checks/day × 30 days × 2 credits = 12,000 credits
At public defaults, 6,000 successful checks use all 12,000 credits in a $100 Tracking allocation. The 100 distinct references use 100 of its 200 shared shipment slots during one billing cycle.

## 1. General Architecture & Authentication
- **Base URL:** `https://api.panvaya.com/api/v1`
- **Authentication:** Pass the API key in the header:
  ```http
  X-API-Key: pv_live_your_key_here
  ```
  (Or as `Authorization: Bearer <key>`). Live keys are prefixed `pv_live_`; sandbox test keys are prefixed `pv_test_`.
- **Content-Type:** `application/json`
- **Rate Limits:** All API keys in one organization share a UTC-minute limit (Free 5, Enterprise 15 requests/minute by default). Each enabled product has a separate organization-wide cap (D&D Tariffs 20; Sailing Schedules 5; Ocean/Air Tracking 10; computational APIs 10; lightweight APIs 10 requests/minute by default). Admins may customize both.
  - Headers returned: `X-Request-Id`, `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and for metered products `X-Product-RateLimit-Limit` and `X-Product-RateLimit-Remaining`.
  - `X-Request-Id` is optional on requests; if omitted, Panvaya generates it and returns it in the response.
  - When throttled, returns `HTTP 429 RATE_LIMIT_EXCEEDED` (organization) or `PRODUCT_RATE_LIMIT_EXCEEDED` (product) with a `Retry-After: <seconds>` header. Integrations should automatically wait and retry.
  - Higher rate limits are available for enterprise accounts on request. Contact Panvaya support to unlock a higher limit.
- **Error Envelope:**
  ```json
  {
    "errors": [
      {
        "code": "INVALID_REQUEST",
        "title": "Invalid request",
        "detail": "One of container, bol, or bk is required."
      }
    ]
  }
  ```
  Always branch on the stable string `code` (e.g. `INVALID_REQUEST`, `CARRIER_NOT_SUPPORTED`, `CARRIER_MAINTENANCE`, `NOT_FOUND`, `QUOTA_EXCEEDED`, `RATE_LIMIT_EXCEEDED`, `PRODUCT_RATE_LIMIT_EXCEEDED`, `RATE_LIMIT_UNAVAILABLE`, `UPSTREAM_ERROR`, `UPSTREAM_UNAVAILABLE`).

## 2. Sea Tracking Normalized Data Model
Panvaya Sea Tracking returns a normalized relational structure to keep payloads compact and efficient:
- `data.locations[]`: Array of ports and facilities (`id`, `name`, `locode`, `coordinates`, `timezone`).
- `data.transports[]`: Array of vessels/vehicles (`id`, `mode`, `name`, `imo`, `call_sign`, `voyage`).
- `data.containers[]`: Array of containers. Each container has:
  - `equipment`: ISO code, length, type, reefer/dry flags.
  - `events[]`: Milestone timeline. Milestones do **NOT** duplicate port or vessel strings. Instead:
    - Match `event.location_id` against `data.locations[].id` to resolve port name and UN/LOCODE.
    - Match `event.transport_id` against `data.transports[].id` to resolve vessel name and IMO.

### Recommended Resolver Snippet (TypeScript / JS):
```typescript
export function enrichTrackingData(data: OceanTrackingResponse['data']) {
  const locationMap = new Map(data.locations.map(l => [l.id, l]));
  const transportMap = new Map(data.transports.map(t => [t.id, t]));

  return data.containers.map(c => ({
    containerNumber: c.number,
    equipment: c.equipment,
    status: c.status,
    events: c.events.map(e => ({
      code: e.event_code,
      name: e.event_name,
      time: e.event_time,
      isActual: e.actual,
      location: locationMap.get(e.location_id),
      transport: transportMap.get(e.transport_id),
    }))
  }));
}
```

### 1) Sea Tracking
- **Method & Path:** `POST /api/v1/track/ocean`
- **Request Body (JSON):**
  - `container` (string, optional): ISO container number (e.g. `"MEDU8611713"`).
  - `bol` (string, optional): Bill of Lading reference. (Mutually exclusive with `bk`).
  - `bk` (string, optional): Booking reference. (Mutually exclusive with `bol`).
  - `shipping_line_scac` (string, optional): Carrier SCAC (e.g. `"MSCU"`) to bypass auto-discovery.
  - `include_route_data` (boolean, default false): Set true to receive a single `path` per route segment, per-leg `status`, aligned `stops[]`, `current_position`, and `ais` vessel telemetry. With false, `data.route_data` is null.
- **Plotting:** Draw each `segments[].path` in GeoJSON `[longitude, latitude]` order and preserve longitudes outside ±180°. Place the marker at `current_position.plot_longitude ?? current_position.longitude` and `current_position.latitude` when present. `source: "live_ais"` identifies the AIS vessel position. Use `estimated` and `observed_at` for marker labels and `ais` for speed, course, heading, and distance to go in nautical miles.
- **Progress styling:** Draw completed legs solid and planned legs dotted. Match `current_position.active_segment_sequence` to `segments[].sequence` and project the position onto the active path. Draw up to that point solid and the rest dotted.
- **Leaflet example**
```js
// Request include_route_data: true. Pass the response JSON to an initialized Leaflet map.
const route = response.data?.route_data;
const layers = L.featureGroup().addTo(map);

for (const { path, status } of route?.segments ?? []) {
  if (!path || path.length < 2) continue;
  const points = path.map(([longitude, latitude]) => [latitude, longitude]);
  L.polyline(points, { dashArray: status === "completed" ? undefined : "6 8" }).addTo(layers);
}

for (const stop of route?.stops ?? []) {
  if (stop.latitude != null && stop.longitude != null) {
    L.circleMarker([stop.latitude, stop.longitude], { radius: 4 }).addTo(layers);
  }
}

const position = route?.current_position;
const longitude = position?.plot_longitude ?? position?.longitude;
const atSea = position?.source === "live_ais" || position?.source === "route_progress";
if (atSea && position.latitude != null && longitude != null) {
  L.marker([position.latitude, longitude]).addTo(layers);
}

const bounds = layers.getBounds();
if (bounds.isValid()) map.fitBounds(bounds, { maxZoom: 9 });
```
- **Example Request:**
```json
{"container":"MEDU8611713","shipping_line_scac":"MSCU","include_route_data":false}
```
- **Errors:** A selected carrier marked under maintenance returns HTTP 503 `CARRIER_MAINTENANCE` in the shared error envelope. Failed requests are not billed.
- **Expanded 200 OK Response (optional route data shown with `include_route_data: true`):**
```json
{
  "data": {
    "reference": {
      "number": "MEDU8611713",
      "type": "container"
    },
    "shipping_line": {
      "scac": "MSCU",
      "name": "Mediterranean Shipping Company (MSC)"
    },
    "status": "in_transit",
    "journey": {
      "origin": null,
      "port_of_lading": {
        "location_id": 1,
        "estimated_departure_at": "2026-10-24T00:00:00",
        "actual_departure_at": null,
        "estimated_arrival_at": null,
        "actual_arrival_at": null
      },
      "port_of_discharge": {
        "location_id": 3,
        "estimated_departure_at": null,
        "actual_departure_at": null,
        "estimated_arrival_at": "2026-11-11T00:00:00",
        "actual_arrival_at": null
      },
      "destination": null
    },
    "locations": [
      {
        "id": 1,
        "name": "Montreal",
        "state": "QC",
        "country": "Canada",
        "country_code": "CA",
        "locode": "CAMTR",
        "latitude": 45.545,
        "longitude": -73.528,
        "timezone": "America/Toronto"
      },
      {
        "id": 2,
        "name": "Gioia Tauro",
        "state": null,
        "country": "Italy",
        "country_code": "IT",
        "locode": "ITGIT",
        "latitude": 38.442,
        "longitude": 15.902,
        "timezone": "Europe/Rome"
      },
      {
        "id": 3,
        "name": "Mersin",
        "state": "33",
        "country": "Türkiye",
        "country_code": "TR",
        "locode": "TRMER",
        "latitude": 36.798,
        "longitude": 34.642,
        "timezone": "Europe/Istanbul"
      }
    ],
    "transports": [
      {
        "id": 1,
        "mode": "truck",
        "name": null,
        "imo": null,
        "call_sign": null,
        "mmsi": null,
        "flag": null,
        "vehicle_number": null,
        "voyage_number": null
      },
      {
        "id": 2,
        "mode": "vessel",
        "name": "MSC KILIMANJARO IV",
        "imo": 9318175,
        "call_sign": "A8JX3",
        "mmsi": 636013001,
        "flag": "LR",
        "vehicle_number": null,
        "voyage_number": "CD643R"
      },
      {
        "id": 3,
        "mode": "vessel",
        "name": "MSC PAMIRA III",
        "imo": 9239903,
        "call_sign": "5LCZ6",
        "mmsi": 636021246,
        "flag": "MH",
        "vehicle_number": null,
        "voyage_number": "AH645R"
      }
    ],
    "containers": [
      {
        "number": "MEDU8611713",
        "equipment": {
          "carrier_code": "40 HIGH CUBE",
          "iso_code": "45G1",
          "description": "High Cube Dry Standard",
          "size": 40,
          "length": "40'",
          "height": "9'6''",
          "width": "8'",
          "bulk": false,
          "liquid": false,
          "reefer": false,
          "high_cube": true,
          "dry": true
        },
        "status": "in_transit",
        "events": [
          {
            "id": 1,
            "location_id": 1,
            "event_code": "PICK",
            "event_name": "Empty equipment picked up",
            "event_category": "equipment",
            "carrier_event_name": "Start Export Cycle",
            "event_time": "2026-10-14T00:00:00",
            "actual": true,
            "transport_id": 1
          },
          {
            "id": 2,
            "location_id": 1,
            "event_code": "GTIN",
            "event_name": "Gate in",
            "event_category": "equipment",
            "carrier_event_name": "Export received at CY",
            "event_time": "2026-10-16T00:00:00",
            "actual": true,
            "transport_id": 1
          },
          {
            "id": 3,
            "location_id": 1,
            "event_code": "DEPA",
            "event_name": "Vessel departed",
            "event_category": "transport",
            "carrier_event_name": "Estimated Time of Departure",
            "event_time": "2026-10-24T00:00:00",
            "actual": false,
            "transport_id": 2
          },
          {
            "id": 4,
            "location_id": 2,
            "event_code": "DISC",
            "event_name": "Discharged at transshipment port",
            "event_category": "equipment",
            "carrier_event_name": "Full Intended Transshipment",
            "event_time": "2026-11-07T00:00:00",
            "actual": false,
            "transport_id": 2
          },
          {
            "id": 5,
            "location_id": 2,
            "event_code": "LOAD",
            "event_name": "Loaded at transshipment port",
            "event_category": "equipment",
            "carrier_event_name": "Full Intended Transshipment",
            "event_time": "2026-11-07T00:00:00",
            "actual": false,
            "transport_id": 3
          },
          {
            "id": 6,
            "location_id": 3,
            "event_code": "ARRI",
            "event_name": "Vessel arrived",
            "event_category": "transport",
            "carrier_event_name": "Estimated Time of Arrival",
            "event_time": "2026-11-11T00:00:00",
            "actual": false,
            "transport_id": 3
          }
        ]
      }
    ],
    "route_data": {
      "segments": [
        {
          "sequence": 1,
          "transport_mode": "vessel",
          "origin_location_id": 1,
          "destination_location_id": 2,
          "transport_id": 2,
          "voyage_number": "CD643R",
          "status": "planned",
          "path": [
            [
              -73.52800000000002,
              45.545
            ],
            [
              -70.375,
              47.375
            ],
            [
              -68.875,
              48.625
            ],
            [
              -66.125,
              49.375
            ],
            [
              -63.875,
              49.375
            ],
            [
              -63.125,
              49.125
            ],
            [
              -61.875,
              48.875
            ],
            [
              -59.125,
              47.375
            ],
            [
              -53.375,
              46.625
            ],
            [
              -8.625,
              36.875
            ],
            [
              -5.875,
              36.125
            ],
            [
              -5.125,
              36.125
            ],
            [
              -1.875,
              36.625
            ],
            [
              15.875,
              38.625
            ],
            [
              15.902000000000044,
              38.442
            ]
          ],
          "path_source": "calculated"
        },
        {
          "sequence": 2,
          "transport_mode": "vessel",
          "origin_location_id": 2,
          "destination_location_id": 3,
          "transport_id": 3,
          "voyage_number": "AH645R",
          "status": "planned",
          "path": [
            [
              15.902000000000044,
              38.442
            ],
            [
              15.875,
              38.625
            ],
            [
              15.625,
              38.375
            ],
            [
              15.625,
              37.875
            ],
            [
              22.375,
              36.625
            ],
            [
              28.625,
              36.625
            ],
            [
              29.375,
              36.125
            ],
            [
              33.375,
              35.875
            ],
            [
              34.625,
              36.625
            ],
            [
              34.64200000000005,
              36.798
            ]
          ],
          "path_source": "calculated"
        }
      ],
      "stops": [
        {
          "sequence": 1,
          "location_id": 1,
          "role": "pol",
          "status": "current",
          "latitude": 45.545,
          "longitude": -73.52800000000002
        },
        {
          "sequence": 2,
          "location_id": 2,
          "role": "transshipment",
          "status": "planned",
          "latitude": 38.442,
          "longitude": 15.902000000000044
        },
        {
          "sequence": 3,
          "location_id": 3,
          "role": "pod",
          "status": "planned",
          "latitude": 36.798,
          "longitude": 34.64200000000005
        }
      ],
      "current_position": {
        "latitude": 45.545,
        "longitude": -73.52800000000002,
        "plot_longitude": -73.52800000000002,
        "source": "last_event",
        "estimated": true,
        "observed_at": null,
        "active_segment_sequence": null
      },
      "ais": {
        "from_cache": null,
        "speed_knots": null,
        "course": null,
        "heading": null,
        "distance_to_go": null,
        "empty": true
      }
    }
  },
  "errors": null
}
```

### 2) List Ocean Carriers
- **Method & Path:** `GET /api/v1/carriers`
- **Description:** Returns all active ocean carriers and SCAC codes for container and document tracking.
- **Example 200 OK Response:**
```json
{
  "mode": "ocean",
  "carriers": [
    {
      "name": "Maersk",
      "code": "MAEU"
    },
    {
      "name": "Mediterranean Shipping Company (MSC)",
      "code": "MSCU"
    },
    {
      "name": "CMA CGM",
      "code": "CMDU"
    },
    {
      "name": "COSCO Shipping Lines",
      "code": "COSU"
    },
    {
      "name": "Hapag-Lloyd",
      "code": "HLCU"
    },
    {
      "name": "Ocean Network Express (ONE)",
      "code": "ONEY"
    },
    {
      "name": "Evergreen Line",
      "code": "EGLV"
    },
    {
      "name": "HMM (Hyundai Merchant Marine)",
      "code": "HDMU"
    },
    {
      "name": "Yang Ming Marine Transport",
      "code": "YMLU"
    },
    {
      "name": "ZIM Integrated Shipping",
      "code": "ZIMU"
    }
  ]
}
```

### Air Cargo Tracking
- **Method & Path:** `POST /api/v1/track/air`
- **Request Body (JSON):** `{"awb":"044-45428036"}`.
  - `awb` (string, required): Full eleven-digit AWB. Compact or formatted input is accepted; responses and billing use `XXX-XXXXXXXX` with leading zeros preserved. Serial-only references are invalid.
- **Response:** The Air object directly, using camelCase fields, IATA airports, flight legs, cargo milestones, pieces and weight. Do not apply the Ocean `data.containers`, vessel or shipping-line model. Missing values remain null. Airport-local timestamps have no UTC offset; interpret each event/leg in its airport's timezone. Use `eventTimeUtc` to order events across airports; retain `eventTime` for the original local display. A missing or ambiguous timezone leaves the UTC value null. `routePoints` is an illustrative great-circle path, not live aircraft coordinates.
- **Billing:** Uses product `AIR_TRACKING` and the shared API credit/distinct tracking pools. Each successful call (including cache hits) costs the organization's configured Air credits. The canonical AWB enrolls once per organization/billing cycle. Repeated success consumes credits but no additional distinct tracking unit. Failed calls do not consume credits or enroll shipments. Web tracking shares the shipment allowance, charges each Web journey only once through delivery, and consumes no API credits.
- **Errors:** Shared `errors` envelope. HTTP 400 `INVALID_REQUEST` or `CARRIER_NOT_SUPPORTED`; 404 `NOT_FOUND`; 402 `QUOTA_EXCEEDED`; 403 disabled product; 429 `RATE_LIMIT_EXCEEDED`; 503 `CARRIER_MAINTENANCE` when the selected airline is marked under maintenance (not billed); 502 `UPSTREAM_UNAVAILABLE`; 500 `SERVER_ERROR` for internal failures.
- **Example 200 OK Response (illustrative):**
```json
{
  "awbNumber": "044-45428036",
  "airlineId": 52,
  "airlineName": "Aerolíneas Argentinas",
  "airlinePrefix": "044",
  "originAirportCode": "MAD",
  "originAirportName": "Adolfo Suárez Madrid–Barajas Airport",
  "originLat": 40.4719,
  "originLng": -3.56264,
  "destinationAirportCode": "SCL",
  "destinationAirportName": "Arturo Merino Benítez International Airport",
  "destinationLat": -33.393,
  "destinationLng": -70.7858,
  "departureEstimated": "2026-10-02T09:00:00",
  "departureActual": "2026-10-02T09:15:00",
  "arrivalEstimated": "2026-10-03T06:30:00",
  "arrivalActual": null,
  "piece": 2,
  "weight": 295.5,
  "status": "IN_TRANSIT",
  "flightNumber": "AR1135",
  "events": [
    {
      "orderId": 1,
      "code": "DEP",
      "description": "Departed",
      "rawDescription": "Shipment departed",
      "airportCode": "MAD",
      "airportName": "Adolfo Suárez Madrid–Barajas Airport",
      "lat": 40.4719,
      "lng": -3.56264,
      "eventTime": "2026-10-02T09:15:00",
      "eventTimeUtc": "2026-10-02T07:15:00Z",
      "actual": true,
      "piece": 2,
      "weight": 295.5,
      "flightNumber": "AR1135",
      "fromAirport": "MAD",
      "toAirport": "EZE",
      "uld": null
    }
  ],
  "routes": [
    {
      "orderId": 1,
      "fromAirport": "MAD",
      "toAirport": "EZE",
      "flightNumber": "AR1135",
      "departureEstimated": "2026-10-02T09:00:00",
      "departureActual": "2026-10-02T09:15:00",
      "arrivalEstimated": "2026-10-02T17:00:00",
      "arrivalActual": null,
      "departureEstimatedUtc": "2026-10-02T07:00:00Z",
      "departureActualUtc": "2026-10-02T07:15:00Z",
      "arrivalEstimatedUtc": "2026-10-02T20:00:00Z",
      "arrivalActualUtc": null,
      "pieces": 2,
      "weight": 295.5,
      "status": "Departed"
    },
    {
      "orderId": 2,
      "fromAirport": "EZE",
      "toAirport": "SCL",
      "flightNumber": "AR1284",
      "departureEstimated": "2026-10-03T05:00:00",
      "departureActual": null,
      "arrivalEstimated": "2026-10-03T06:30:00",
      "arrivalActual": null,
      "departureEstimatedUtc": "2026-10-03T08:00:00Z",
      "departureActualUtc": null,
      "arrivalEstimatedUtc": "2026-10-03T09:30:00Z",
      "arrivalActualUtc": null,
      "pieces": 2,
      "weight": 295.5,
      "status": "Booked"
    }
  ],
  "routePoints": [
    {
      "lat": 40.4719,
      "lng": -3.56264
    },
    {
      "lat": -34.8222,
      "lng": -58.5358
    },
    {
      "lat": -33.393,
      "lng": -70.7858
    }
  ],
  "waypoints": [
    {
      "airportCode": "MAD",
      "airportName": "Adolfo Suárez Madrid–Barajas Airport",
      "lat": 40.4719,
      "lng": -3.56264,
      "role": "ORIGIN",
      "order": 1
    },
    {
      "airportCode": "EZE",
      "airportName": "Ministro Pistarini International Airport",
      "lat": -34.8222,
      "lng": -58.5358,
      "role": "TRANSIT",
      "order": 2
    },
    {
      "airportCode": "SCL",
      "airportName": "Arturo Merino Benítez International Airport",
      "lat": -33.393,
      "lng": -70.7858,
      "role": "DESTINATION",
      "order": 3
    }
  ],
  "carbonEstimate": null,
  "found": true,
  "errorMessage": null
}
```

### 3) List Cargo Airlines
- **Method & Path:** `GET /api/v1/airlines`
- **Description:** Returns supported, available cargo airlines as name and 3-digit AWB prefix. Requires an API key, costs zero credits, and follows rate limits. Send only the full awb to /track/air; the prefix identifies the airline automatically.
- **Example 200 OK Response:**
```json
{
  "mode": "air",
  "airlines": [
    {
      "name": "Aerolíneas Argentinas",
      "prefix": "044"
    },
    {
      "name": "Air Canada Cargo",
      "prefix": "014"
    },
    {
      "name": "Air France Cargo",
      "prefix": "057"
    },
    {
      "name": "Cathay Cargo",
      "prefix": "160"
    },
    {
      "name": "Emirates SkyCargo",
      "prefix": "176"
    },
    {
      "name": "Etihad Cargo",
      "prefix": "607"
    },
    {
      "name": "Finnair Cargo",
      "prefix": "105"
    },
    {
      "name": "Korean Air Cargo",
      "prefix": "180"
    },
    {
      "name": "Lufthansa Cargo",
      "prefix": "020"
    },
    {
      "name": "Qantas Freight",
      "prefix": "081"
    },
    {
      "name": "Qatar Airways Cargo",
      "prefix": "157"
    },
    {
      "name": "Singapore Airlines Cargo",
      "prefix": "618"
    }
  ]
}
```

### 4) Sailing Schedules Search
- **Default billing:** 5 credits per carrier returning usable sailings, not per sailing. Multiple sailings from one carrier count as one unit. Carriers without usable sailings cost zero; partial or fallback results are billable when they contain usable sailings. Configured organization credit rates remain authoritative.
- **Method & Path:** `POST /api/v1/schedules/search`
- **Request Body (JSON):**
  - `origin` (string, required): Origin UN/LOCODE (e.g. `"CNSHA"`).
  - `destination` (string, required): Destination UN/LOCODE (e.g. `"NLRTM"`).
  - `date` (string, optional): Earliest departure in `YYYY-MM-DD` (defaults to today).
  - `weeks` (integer, optional, default 4, min 1, max 12): Forward search horizon in weeks. Prunes carrier open-windows strictly to `[date, date + (weeks * 7) days]`.
  - `carriers` (array of string, optional): Filter by carrier names or SCACs (e.g. `["MAEU"]`).
- **Example 200 OK Response:**
```json
{
  "origin": {
    "name": "Shanghai",
    "locode": "CNSHA",
    "timezone": "Asia/Shanghai"
  },
  "destination": {
    "name": "Rotterdam",
    "locode": "NLRTM",
    "timezone": "Europe/Amsterdam"
  },
  "fromDate": "2025-09-01",
  "weeks": 8,
  "carriers": [
    "MAERSK"
  ],
  "successfulCarriers": [
    "MAERSK"
  ],
  "cached": true,
  "servedAt": "2025-09-01T11:25:00Z",
  "carrierStatuses": {
    "MAEU": {
      "carrier": "MAERSK",
      "carrierCode": "MAEU",
      "status": "FOUND",
      "count": 2,
      "cached": true,
      "cacheExpiresAt": "2025-09-01T20:00:00Z",
      "durationMs": 420.5
    }
  },
  "sailings": [
    {
      "carrier": "MAERSK",
      "carrierCode": "MAEU",
      "service": "AE1",
      "direct": true,
      "routingType": "Direct",
      "transshipments": 0,
      "originName": "Shanghai",
      "originLocode": "CNSHA",
      "originTerminal": "Yangshan Deepwater Port",
      "originTimezone": "Asia/Shanghai",
      "destinationName": "Rotterdam",
      "destinationLocode": "NLRTM",
      "destinationTerminal": "APM Terminals Maasvlakte II",
      "destinationTimezone": "Europe/Amsterdam",
      "retrievedAt": "2025-09-01T08:00:00Z",
      "cached": true,
      "sourceUpdatedAt": null,
      "sourceResultTimestamp": null,
      "sourceIdentifier": "carrier:MAEU",
      "departure": "2025-09-03T18:00:00+08:00",
      "arrival": "2025-10-05T06:00:00+02:00",
      "finalEtaStatus": "PUBLISHED",
      "transitTime": "32 days",
      "transitHours": 756,
      "vesselName": "MADRID MAERSK",
      "vesselImo": "9778791",
      "voyageNo": "2501W",
      "legs": [
        {
          "sequence": 1,
          "transportMode": "VESSEL",
          "vesselName": "MADRID MAERSK",
          "vesselImo": "9778791",
          "voyageNo": "2501W",
          "service": "AE1",
          "fromName": "Shanghai",
          "fromLocode": "CNSHA",
          "fromTerminal": "Yangshan Deepwater Port",
          "fromTimezone": "Asia/Shanghai",
          "departure": "2025-09-03T18:00:00+08:00",
          "toName": "Rotterdam",
          "toLocode": "NLRTM",
          "toTerminal": "APM Terminals Maasvlakte II",
          "toTimezone": "Europe/Amsterdam",
          "arrival": "2025-10-05T06:00:00+02:00",
          "transitHours": 756
        }
      ]
    },
    {
      "carrier": "MAERSK",
      "carrierCode": "MAEU",
      "service": "AE1",
      "direct": true,
      "routingType": "Direct",
      "transshipments": 0,
      "originName": "Shanghai",
      "originLocode": "CNSHA",
      "originTerminal": "Yangshan Deepwater Port",
      "originTimezone": "Asia/Shanghai",
      "destinationName": "Rotterdam",
      "destinationLocode": "NLRTM",
      "destinationTerminal": "APM Terminals Maasvlakte II",
      "destinationTimezone": "Europe/Amsterdam",
      "retrievedAt": "2025-09-01T08:00:00Z",
      "cached": true,
      "sourceUpdatedAt": null,
      "sourceResultTimestamp": null,
      "sourceIdentifier": "carrier:MAEU",
      "departure": "2025-09-10T12:00:00+08:00",
      "arrival": "2025-10-12T08:00:00+02:00",
      "finalEtaStatus": "PUBLISHED",
      "transitTime": "32 days",
      "transitHours": 764,
      "vesselName": "MUNICH MAERSK",
      "vesselImo": "9778806",
      "voyageNo": "2502W",
      "legs": [
        {
          "sequence": 1,
          "transportMode": "VESSEL",
          "vesselName": "MUNICH MAERSK",
          "vesselImo": "9778806",
          "voyageNo": "2502W",
          "service": "AE1",
          "fromName": "Shanghai",
          "fromLocode": "CNSHA",
          "fromTerminal": "Yangshan Deepwater Port",
          "fromTimezone": "Asia/Shanghai",
          "departure": "2025-09-10T12:00:00+08:00",
          "toName": "Rotterdam",
          "toLocode": "NLRTM",
          "toTerminal": "APM Terminals Maasvlakte II",
          "toTimezone": "Europe/Amsterdam",
          "arrival": "2025-10-12T08:00:00+02:00",
          "transitHours": 764
        }
      ]
    }
  ]
}
```
- **Carrier failure outcomes:** All carrier acquisition failures return HTTP 200 with their reasons in carrierStatuses, including location misses, network/timeout/CAPTCHA/proxy failures, parsing errors and incomplete coverage. Empty sailings with FAILED, TIMEOUT or PARTIAL carrier status is not confirmed no service and consumes zero credits for the affected carriers. Carriers returning usable sailings are billable, including PARTIAL_UPSTREAM and stale-cache rows; carriers returning zero usable sailings remain unbilled. Healthy complete empty or filtered-only results retain HTTP 404; request validation, authentication, entitlement, quota and rate-limit errors retain HTTP error statuses.
- **Reading the response:** `servedAt` is response assembly time; each sailing's `retrievedAt` is Panvaya's carrier capture time, and its `cached` flag identifies cache use even when the aggregate `cached` flag is false. A carrier status with usable data includes `cacheExpiresAt`, the original acquisition time plus the 12-hour freshness window; cache reads do not extend it. `sourceUpdatedAt` is set only from a verified carrier schedule-update timestamp; MSC's raw `sourceResultTimestamp` is a result-generation time, not a schedule revision. If the final destination `arrival` is null, `finalEtaStatus` is `NOT_PUBLISHED`; never replace it with an intermediate-leg arrival.

## Asynchronous batch sailing schedules
Available when asynchronous schedules are enabled for the deployment. Up to 2 active batch requests per organization by default. Contact support for higher limits.
### POST /api/v1/schedules/requests
Returns 202 with a request UUID, statusUrl, resultUrl and deadline. One port-to-port route per batch; omit carriers to select all enabled providers. Idempotency-Key is optional and must be reused only with the same request parameters.

```bash
curl -X POST "https://api.panvaya.com/api/v1/schedules/requests" \
  -H "X-API-Key: pv_live_your_key_here" \
  -H "Idempotency-Key: customer-search-123" \
  -H "Content-Type: application/json" \
  -d '{"origin":"CNSHA","destination":"NLRTM","weeks":4,"carriers":["MAEU","ONEY","HLCU"]}'
```

### GET /api/v1/schedules/requests/{requestId}
Returns 200 with progress, totalCarriers, terminalCarriers and each carrier's state, attempts and outcome. Terminal carriers include completed, partial, failed and timed-out carriers; this is not the billable-carrier count.

```bash
curl "https://api.panvaya.com/api/v1/schedules/requests/<requestId>" \
  -H "X-API-Key: pv_live_your_key_here"
```

### GET /api/v1/schedules/requests/{requestId}/result
Returns 202 progress while pending, then 200 with requestId, status, creditsCharged, metadata and result. The normalized result contains sailings and carrierStatuses; metadata includes chargedCarrierCodes and requestId. Partial results retain completed carrier data.

```bash
curl "https://api.panvaya.com/api/v1/schedules/requests/<requestId>/result" \
  -H "X-API-Key: pv_live_your_key_here"
```

### POST /api/v1/schedules/requests/{requestId}/retry-billing
After resolving a BILLING_FAILED issue, returns 202 and retries settlement using the collected results. It does not repeat carrier acquisition. Result access returns 409 until billing succeeds.

```bash
curl -X POST "https://api.panvaya.com/api/v1/schedules/requests/<requestId>/retry-billing" \
  -H "X-API-Key: pv_live_your_key_here"
```

202 acknowledgement:
```json
{
  "requestId": "a5b80a55-62a2-4935-92fd-ef3089cd90a6",
  "status": "CREATED",
  "createdAt": "2026-10-25T10:00:00Z",
  "deadlineAt": "2026-10-25T10:05:00Z",
  "statusUrl": "/api/v1/schedules/requests/a5b80a55-62a2-4935-92fd-ef3089cd90a6",
  "resultUrl": "/api/v1/schedules/requests/a5b80a55-62a2-4935-92fd-ef3089cd90a6/result"
}
```

- Up to 2 active batch requests per organization by default. Contact support for higher limits.
- Exceeding the active-request limit returns 429 ASYNC_SCHEDULE_CAPACITY_EXCEEDED. Wait for an active request to finish before submitting another batch.
- The five-minute budget includes queue wait, preparation and retries. Acquisition stops at 295 seconds to allow settlement. Consumer or database outages can delay final visibility; later carrier results cannot change a closed request.
- The default outer limit is 2 total execution attempts for retryable failures, including the first attempt. PARTIAL / PARTIAL_UPSTREAM responses are final and are not retried by the async worker. Individual carrier adapters retain their own internal retry policies.
- Poll no faster than Retry-After (15 seconds by default). Status and result reads share a separate 30 requests/minute organization allowance and do not charge credits.
- Uses SAILING_SCHEDULES pricing. No credits are reserved. Nonempty complete and partial carrier responses are charged, including partial stale-cache fallback. Empty responses and failures without usable sailings are unbilled. Partial flags remain visible; a charge does not certify complete route coverage. Existing fixed-price agreements remain supported until retired.
- Fresh exact windows are reused first; subsets of fresh wider windows keep the original acquisition time. Historical result reads remain stable after later cache refreshes.
- Request IDs, collected results and idempotency records have no automatic expiry. Retrieve an existing request using an authorized API key for its organization and live/sandbox environment. Use a new idempotency key for a new search.
- States: CREATED, PREPARING, RUNNING, FINALIZING, COMPLETED, PARTIAL, FAILED, BILLING_FAILED. Healthy empty results return COMPLETED with zero sailings and zero credits.
- API keys stay in request headers. Responses and queue messages contain no API key. Access is scoped to the organization and live/sandbox environment; responses are private, no-store.
Support: https://panvaya.com/contact-us


### 5) Freight Carbon Emissions Calculator
- **Method & Path:** `POST /api/v1/carbon/calculate`
- **Request Body (JSON):**
  - `origin` (string, required): Origin UN/LOCODE (e.g. `"NLRTM"`).
  - `destination` (string, required): Destination UN/LOCODE (e.g. `"SGSIN"`).
  - `weightKg` (number, required): Total cargo weight in kilograms.
  - `mode` (string, required): Transport mode (`"ocean"` or `"air"`).
- **Example 200 OK Response:**
```json
{
  "origin": {
    "name": "Shanghai",
    "locode": "CNSHA",
    "latitude": 31.23,
    "longitude": 121.47
  },
  "destination": {
    "name": "Rotterdam",
    "locode": "NLRTM",
    "latitude": 51.92,
    "longitude": 4.48
  },
  "mode": "ocean",
  "weightKg": 18000,
  "greatCircleKm": 8868.42,
  "distanceKm": 14189.47,
  "co2Kg": 2554.1,
  "co2Tonnes": 2.55,
  "factorGramsPerTonneKm": 10,
  "treesToOffset": 121.62,
  "carKmEquivalent": 15024.12
}
```

## CBAM and Maritime ETS Estimates
- Endpoint: `POST /api/v1/carbon/cbam`, API-key authenticated; uses `CARBON_CALCULATOR` on successful responses.
- Required: `cnCode` (8 digits, or an unambiguous 6-digit HS code) and `netWeightKg`; aliases `hsCode` and `weightKg` are supported.
- Optional: `originCountry` (ISO alpha-2 or DEFAULT), `origin` / `destination` (UN/LOCODE), and `invoicedEtsSurcharge` in `invoicedCurrency: "EUR"` only.
- Optional `shipmentIdentifier` must be a public UUID or organization-owned reference. Lookup excludes deleted shipments and never writes saved records. Unknown/foreign references return 404; multiple matches require UUID.
- These are estimates, not certified factors, CBAM tax calculations or invoice verification. Missing route values and report URLs are null. Responses contain no internal database IDs.
- Public calculator: https://panvaya.com/cbam-calculator. Web report downloads require login.
- Example without ports:
```json
{
  "shipmentIdentifier": null,
  "carrierName": null,
  "cnCode": "72083900",
  "commodityName": "Flat-rolled hot-rolled coils, thickness < 3 mm (HRC)",
  "sector": "IRON_STEEL",
  "originCountry": "DEFAULT",
  "netWeightKg": 20000,
  "netWeightTonnes": 20,
  "cbamEmissions": {
    "directTco2e": 43,
    "indirectTco2e": 5.2,
    "totalEmbeddedTco2e": 48.2,
    "directFactor": 2.15,
    "indirectFactor": 0.26
  },
  "freightEmissions": {
    "transportTco2e": null,
    "totalLandedCarbonTco2e": null
  },
  "euEtsMaritimeAudit": {
    "isEuDestination": null,
    "euPodLocode": null,
    "liableDistanceKm": null,
    "liabilityRatio": null,
    "euaPriceEurPerTonne": 70,
    "panvayaAuditedCostEur": null,
    "invoicedEtsSurcharge": null,
    "invoicedCurrency": "EUR",
    "discrepancyAmount": null,
    "auditStatus": "UNAVAILABLE"
  },
  "reports": {
    "xmlReportUrl": null,
    "excelReportUrl": null
  }
}
```

### 6) Sea Distance & Transit Time
- **Method & Path:** `POST /api/v1/distance-time/calculate`
- **Request Body (JSON):**
  - `origin` (string, optional): Origin UN/LOCODE (e.g. `"NLRTM"`). Required if waypoints not supplied.
  - `destination` (string, optional): Destination UN/LOCODE (e.g. `"SGSIN"`). Required if waypoints not supplied.
  - `waypoints` (array, optional): Multi-stop array (up to 6 stops) with `[{"locode": "CNSHA"}, {"locode": "NLRTM"}]`.
  - `avoidDangerZones` (boolean, default false): Set true to reroute around Red Sea / Suez Canal via Cape of Good Hope.
- **Example 200 OK Response:**
```json
{
  "safe": false,
  "totalNm": 8305.2,
  "totalKm": 15381.2,
  "speedKnots": 13,
  "transitHours": 638.9,
  "legs": [
    {
      "fromName": "Rotterdam",
      "fromLocode": "NLRTM",
      "from": [
        51.9244,
        4.4777
      ],
      "toName": "Singapore",
      "toLocode": "SGSIN",
      "to": [
        1.264,
        103.84
      ],
      "distanceNm": 8305.2,
      "cached": true,
      "error": null,
      "route": [
        [
          51.9244,
          4.4777
        ],
        [
          50.5,
          0.1
        ],
        [
          36,
          -5.3
        ],
        [
          31.2,
          32.3
        ],
        [
          12.6,
          43.3
        ],
        [
          1.264,
          103.84
        ]
      ]
    }
  ]
}
```

### 7) Vessel Details
- **Method & Path:** `GET /api/v1/vessels?imo={imo}`, `?mmsi={mmsi}`, or `?name={name}&similarity={threshold}`
- **Parameters (Query):**
  - Exactly one of `imo`, `mmsi`, or `name` is required.
  - `imo` (string, optional): Checksum-valid 7-digit IMO number (e.g. `9525338`).
  - `mmsi` (string, optional): 9-digit MMSI (e.g. `566093000`).
  - `name` (string, optional): Vessel name, 2-120 characters.
  - `similarity` (number, optional): Minimum name similarity from 0 to 1. Applies only to `name`; defaults to `1.0` for exact normalized-name matching.
- **Response:** Always an array, ordered by highest achieved `similarity` first and capped at 50 name matches. IMO/MMSI matches have `similarity: 1.0`.
- **Example 200 OK Response:**
```json
[
  {
    "imo": 9525338,
    "mmsi": 566093000,
    "name": "MAERSK CHENNAI",
    "country": "Singapore",
    "call_sign": "9V9403",
    "year_built": 2011,
    "vessel_type": "Cargo",
    "gross_tonnage": 93646,
    "deadweight": 104696,
    "teu": 7450,
    "length_meters": 299.9,
    "breadth_meters": 48.2,
    "similarity": 1
  }
]
```

### 8) Latest Stored Vessel Position (AIS)
- **Method & Path:** `GET /api/v1/vessels/position?imo={imo}` (or `?mmsi={mmsi}`)
- **Response:** Returns the latest stored coordinates and available navigation and voyage fields in snake_case. The response has no AIS observation timestamp. Use container milestones separately to determine cargo status. Unknown vessels return 404 `VESSEL_NOT_FOUND`; known vessels without a stored position return 502 `VESSEL_POSITION_UNAVAILABLE`. Those failures are unbilled.
- **Parameters (Query):**
  - `imo` (string, optional): 7-digit IMO number.
  - `mmsi` (string, optional): 9-digit MMSI.
- **Example 200 OK Response:**
```json
{
  "imo": 9525338,
  "mmsi": 566093000,
  "vessel_name": "MAERSK CHENNAI",
  "latitude": 18.2,
  "longitude": 72.4,
  "origin_port": "Singapore",
  "origin_unlocode": "SGSIN",
  "current_port": null,
  "current_unlocode": null,
  "destination_port": "Rotterdam",
  "destination_unlocode": "NLRTM",
  "speed": 14.5,
  "course": 285,
  "heading": 283,
  "distance_to_go": 1420,
  "atd": "2025-05-12T06:15:00Z",
  "eta": "2025-06-02T14:30:00Z",
  "eta_calc": "2025-06-02T12:45:00Z"
}
```

### 9) Port Congestion
- **Method & Path:** `GET /api/v1/port-congestion?locode={locode}` or `GET /api/v1/port-congestion?country={country}`
- **Description:** Real-time port congestion telemetry (anchorage wait times, berthing dwell, approaching queues, TEU density) covering top 300+ global ocean container ports.
- **Scope & 404 Behavior:** Tracks maritime container ports only. Air cargo airport hubs (e.g. `USJFK`, `GBLHR`, `CAYYZ`), inland rail/road depots (e.g. `USFLK`), and unmonitored ports return HTTP 404 `NOT_FOUND` (`"No port congestion data was found for <locode>. Panvaya Port Congestion tracks the top 300+ global maritime container ports. Air cargo airport hubs, inland depots, and unmonitored ports are not covered."`). 404 responses are unmetered (0 credits billed).
- **Parameters (Query):**
  - `locode` (string, required unless country is provided): Case-insensitive port UN/LOCODE (e.g. `SGSIN`, `USLAX`, `CNNBO`).
  - `country` (string, required unless locode is provided): Case-insensitive ISO alpha-2 country code (e.g. `SG`, `US`).
- **Validation & Billing:** At least one of locode or country is required. Both may be supplied to narrow the result. If both are missing, empty or whitespace-only, returns HTTP 400 `INVALID_REQUEST` with detail `At least one of locode or country is required.` and no credits charged. Unfiltered global queries are not supported.
- **Example 200 OK Response:**
```json
{
  "count": 1,
  "ports": [
    {
      "name": "Singapore",
      "locode": "SGSIN",
      "locodeAlt": "SGSIN",
      "country": "SG",
      "latitude": 1.264,
      "longitude": 103.84,
      "anchorLast30": {
        "median": 0.72,
        "q1": 0.31,
        "q3": 1.44
      },
      "berthingLast30": {
        "median": 1.18,
        "q1": 0.77,
        "q3": 1.92
      },
      "approachingLast30": {
        "vessels": 1240,
        "teu": 1840000,
        "vesselsNext7": 286
      },
      "within50nmiLast30": {
        "vesselsInArea": 45,
        "vesselsAnchoredOutside": 18,
        "vesselsMooredHere": 27,
        "teuInArea": 320000
      },
      "capLast30": {
        "vesselsArriving": 890,
        "teuArriving": 1420000,
        "vesselsDeparting": 875,
        "teuDeparting": 1395000
      }
    }
  ]
}
```

### 10) Incoterms 2020 Reference
- **Method & Path:** `GET /api/v1/incoterms/{code}`
- **Parameters (Path):**
  - `code` (string, required): 3-letter Incoterm code (e.g. `FOB`, `EXW`, `CIF`, `DAP`, `DDP`).
- **Example 200 OK Response:**
```json
{
  "code": "FOB",
  "name": "Free On Board",
  "mode": "Sea and inland waterway transport only",
  "riskTransfer": "When goods are loaded on board the vessel nominated by the buyer at the named port of shipment.",
  "costTransfer": "Seller pays all costs until goods are on board; buyer pays freight, import clearance, and onward costs.",
  "stages": [
    {
      "stage": "Packaging",
      "seller": true,
      "buyer": false
    },
    {
      "stage": "Loading at origin",
      "seller": true,
      "buyer": false
    },
    {
      "stage": "Export customs",
      "seller": true,
      "buyer": false
    },
    {
      "stage": "Main carriage (freight)",
      "seller": false,
      "buyer": true
    },
    {
      "stage": "Import customs & duties",
      "seller": false,
      "buyer": true
    }
  ]
}
```

### 11) API Credit Usage & Balance
- **Method & Path:** `GET /api/v1/usage`
- **Description:** Unbilled account request. Returns credit and shipment allowances, remaining balances, billing cycle dates, and enabled products with their configured credit costs.
- **Example 200 OK Response:**
```json
{
  "creditLimit": 12000,
  "creditsUsed": 1280,
  "creditsRemaining": 10720,
  "creditPeriodStartedAt": "2025-07-18T10:30:00",
  "creditResetAt": "2025-08-17T10:30:00",
  "enabledProducts": [
    {
      "productCode": "SEA_TRACKING",
      "creditCost": 2
    },
    {
      "productCode": "AIR_TRACKING",
      "creditCost": 5
    },
    {
      "productCode": "PORT_CONGESTION",
      "creditCost": 5
    },
    {
      "productCode": "SAILING_SCHEDULES",
      "creditCost": 5
    },
    {
      "productCode": "VESSEL_DETAILS",
      "creditCost": 5
    },
    {
      "productCode": "VESSEL_POSITION",
      "creditCost": 5
    },
    {
      "productCode": "DND_TARIFFS",
      "creditCost": 5
    }
  ]
}
```

### 12) Download Billing Ledger CSV
- **Method & Path:** `GET /api/v1/usage/report`
- **Parameters (Query):**
  - `productCode` (string, optional): E.g. `SAILING_SCHEDULES`.
  - `from` (string, optional): `YYYY-MM-DD`.
  - `to` (string, optional): `YYYY-MM-DD`.
- **Example request:**
```bash
curl "https://api.panvaya.com/api/v1/usage/report?productCode=SAILING_SCHEDULES&from=2026-10-23&to=2026-10-23" -H "X-API-Key: pv_live_your_key_here" -o panvaya-api-usage.csv
```
- **Response:** `text/csv`. The final `metadata` column contains quoted JSON with `chargedCarrierCodes` for new SAILING_SCHEDULES records. Historical records and other products have an empty metadata cell. Only carriers returning usable sailings are listed, including partial and stale-fallback results. Fixed-rate accounts keep per-search pricing.
```csv
timestamp,api_product,environment,request_reference,request_id,credits_charged,metadata
2026-10-23T09:15:00,SEA_TRACKING,prod,MSKU8094830,req_9a2f7c10b4d83e21,2,""
2026-10-23T09:16:00,SAILING_SCHEDULES,prod,CNSHA-NLRTM:NEXT:ALL:W8,c4b69324-4f46-4cb7-a720-dd5eb6bbdb59,10,"{""chargedCarrierCodes"":[""MAEU"",""ONEY""]}"
2026-09-26T06:41:37.030005,SAILING_SCHEDULES,prod,CNSHA-NLRTM:2026-09-26:ONEY:W8,,5,""
2026-10-23T09:17:00,AIR_TRACKING,prod,044-45428036,req_3c8e1a55f9b207d4,5,""
```

### 18) D&D Tariffs
- **Method & Path:** `POST /api/v1/dnd-tariffs/calculate`
- **Required JSON:** `port` (UN/LOCODE), `carrier` (name or SCAC), `tradeDirection` (IMPORT/EXPORT), `chargeType` (DEMURRAGE/DETENTION), and `equipmentType`.
- **Response scope:** Returns only the requested carrier's published free days and complete chargeable rate ranges. It does not return cross-carrier benchmarks.
- **Billing:** Enabled by default; 5 credits on a successful direct tariff match and 20 requests/minute by default. Validation failures and no-match 404 responses consume no credits.
- **Example 200 OK Response:**
```json
{
  "carrierName": "Maersk",
  "scacCode": "MAEU",
  "direction": "IMPORT",
  "chargeType": "DEMURRAGE",
  "countryCode": "US",
  "portUnlocode": "USLAX",
  "isoCode": "45G1",
  "containerDescription": "40' High Cube Dry",
  "freeDays": 7,
  "firstTierRate": 150,
  "currency": "USD",
  "calendarDayBasis": true,
  "tiers": [
    {
      "fromDay": 1,
      "toDay": 7,
      "rate": 0,
      "currency": "USD"
    },
    {
      "fromDay": 8,
      "toDay": 12,
      "rate": 150,
      "currency": "USD"
    },
    {
      "fromDay": 13,
      "toDay": null,
      "rate": 225,
      "currency": "USD"
    }
  ]
}
```


## Ocean Tracking Webhooks
Base URL: https://api.panvaya.com/api/v1. Authenticate management requests with X-API-Key.
Webhook access (WEBHOOK_SEA_TRACKING) must be enabled for your organization. Use an active key
in the destination's live/sandbox environment. API-key requests use the authenticated key for billing.

Default price: 5 credits per successful acquisition, including successful cache hits. Each new
scheduled or manual run is billable once after success. Failed acquisitions, delivery retries and
replays cost zero credits. REST and webhook tracking share distinct-shipment slots in both directions.
Quota exhaustion persists status BLOCKED, blockedReason QUOTA_EXCEEDED, product HTTP 402.
A top-up alone never resumes a blocked subscription: explicitly activate after resolving the reason.
Revoked keys or disabled product/API access also block until explicitly activated after correction.

### Create an HTTPS destination
Public HTTPS, port 443, valid TLS. Private/reserved addresses and redirects are rejected.
Receiver auth: NONE, API_KEY (authHeaderName + authSecret), STATIC_BEARER (authSecret),
OAUTH2_CLIENT_CREDENTIALS (oauthTokenUrl, oauthClientId, oauthClientSecret,
oauthClientAuthMethod CLIENT_SECRET_BASIC or CLIENT_SECRET_POST; optional oauthScope/oauthAudience).
Credentials are encrypted at rest and never returned. These are receiver credentials, not Panvaya API keys.
There is no HMAC signature header; verify your configured receiver authentication over TLS.

```bash
curl -X POST https://api.panvaya.com/api/v1/webhook-endpoints \
  -H "X-API-Key: pv_live_your_key_here" \
  -H "Idempotency-Key: 8c192cb3-04c6-481b-b315-422df39ddc92" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Operations webhook receiver",
    "environment": "live",
    "url": "https://hooks.example.com/panvaya/ocean",
    "authType": "API_KEY",
    "authHeaderName": "X-Custom-Webhook-Secret",
    "authSecret": "sec_prod_9f81a7b2..."
  }'
```

### Create a subscription
Container, bol or bk is required; bol/bk may be scoped to a container. Optional shipping_line_scac
and include_route_data. intervalSeconds: 300–2592000. DAILY_TIMES: unique HH:MM times with IANA timezone.
Optional startAt/endAt are ISO-8601 instants; startAt defaults to now. For future startAt use
runImmediately:false. Reuse an Idempotency-Key for the identical request; changing the body requires a new key.

```bash
curl -X POST https://api.panvaya.com/api/v1/webhook-subscriptions \
  -H "X-API-Key: pv_live_your_key_here" \
  -H "Idempotency-Key: 146ce001-01f1-43b9-af42-b068585f6358" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "High-priority container monitoring",
    "endpointId": "0192a6b2-031f-7000-8000-000000000001",
    "productCode": "WEBHOOK_SEA_TRACKING",
    "requestConfig": {
      "input": {
        "container": "MSKU8094830",
        "shipping_line_scac": "MSCU",
        "include_route_data": false
      }
    },
    "schedule": {
      "type": "INTERVAL",
      "intervalSeconds": 300,
      "timezone": "UTC"
    },
    "externalReference": "order-po-98421",
    "runImmediately": true
  }'
```

```bash
curl -X POST https://api.panvaya.com/api/v1/webhook-subscriptions \
  -H "X-API-Key: pv_live_your_key_here" \
  -H "Idempotency-Key: 257de102-02f2-44ca-bf53-c179696f7469" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Daily customs milestone check",
    "endpointId": "0192a6b2-031f-7000-8000-000000000001",
    "productCode": "WEBHOOK_SEA_TRACKING",
    "requestConfig": {
      "input": {
        "bol": "MEDUS2984102"
      }
    },
    "schedule": {
      "type": "DAILY_TIMES",
      "times": ["09:00", "21:00"],
      "timezone": "America/New_York"
    },
    "runImmediately": true
  }'
```

### Receiver contract
POST body is the normalized ocean response object {data,errors}, not a flat milestone array.
Join event location_id/transport_id to data.locations/data.transports. Null fields are valid.
X-Panvaya-Delivery-Id is the execution identity and stays stable across automatic retries and replay.
Deduplicate this ID durably before acknowledging. X-Panvaya-External-Reference is optional.

```http
POST /panvaya/ocean HTTP/1.1
Host: hooks.example.com
Content-Type: application/json
X-Panvaya-Delivery-Id: 0192a71f-0a21-7000-8000-000000000042
X-Panvaya-Subscription-Id: 0192a6b2-031f-7000-8000-000000000001
X-Panvaya-Product: WEBHOOK_SEA_TRACKING
X-Panvaya-Environment: live
X-Panvaya-Sequence: 1
X-Panvaya-Timestamp: 1791633600
X-Panvaya-Schema-Version: v1
X-Panvaya-External-Reference: order-po-98421
X-Custom-Webhook-Secret: receiver_secret_here
```

```json
{
  "data": {
    "reference": {
      "number": "MSKU8094830",
      "type": "container"
    },
    "shipping_line": {
      "scac": "MSCU",
      "name": "Mediterranean Shipping Company"
    },
    "status": "IN_TRANSIT",
    "journey": {
      "origin": {
        "location_id": 1,
        "estimated_departure_at": null,
        "actual_departure_at": null,
        "estimated_arrival_at": null,
        "actual_arrival_at": null
      },
      "port_of_lading": {
        "location_id": 1,
        "estimated_departure_at": null,
        "actual_departure_at": "2026-10-04T08:15:00Z",
        "estimated_arrival_at": null,
        "actual_arrival_at": null
      },
      "port_of_discharge": {
        "location_id": 2,
        "estimated_departure_at": null,
        "actual_departure_at": null,
        "estimated_arrival_at": "2026-10-18T14:30:00Z",
        "actual_arrival_at": null
      },
      "destination": {
        "location_id": 2,
        "estimated_departure_at": null,
        "actual_departure_at": null,
        "estimated_arrival_at": null,
        "actual_arrival_at": null
      }
    },
    "locations": [
      {
        "id": 1,
        "name": "Shanghai",
        "state": null,
        "country": "China",
        "country_code": "CN",
        "locode": "CNSHA",
        "latitude": 31.23,
        "longitude": 121.47,
        "timezone": "Asia/Shanghai"
      },
      {
        "id": 2,
        "name": "Los Angeles",
        "state": "California",
        "country": "United States",
        "country_code": "US",
        "locode": "USLAX",
        "latitude": 33.74,
        "longitude": -118.27,
        "timezone": "America/Los_Angeles"
      }
    ],
    "transports": [
      {
        "id": 1,
        "mode": "vessel",
        "name": "MSC GULSUN",
        "imo": 9839430,
        "call_sign": null,
        "mmsi": null,
        "flag": null,
        "vehicle_number": null,
        "voyage_number": "639W"
      }
    ],
    "containers": [
      {
        "number": "MSKU8094830",
        "equipment": null,
        "status": "IN_TRANSIT",
        "events": [
          {
            "id": 1,
            "location_id": 1,
            "event_code": "DEPA",
            "event_name": "Departure from port",
            "event_category": "transport",
            "carrier_event_name": "Vessel departed",
            "event_time": "2026-10-04T08:15:00Z",
            "actual": true,
            "transport_id": 1
          },
          {
            "id": 2,
            "location_id": 2,
            "event_code": "ARRI",
            "event_name": "Arrival at port",
            "event_category": "transport",
            "carrier_event_name": "Expected arrival",
            "event_time": "2026-10-18T14:30:00Z",
            "actual": false,
            "transport_id": 1
          }
        ]
      }
    ],
    "route_data": null
  },
  "errors": null
}
```

Any 2xx acknowledges delivery. Respond within the configured timeout (default 10 seconds).
408/429/5xx/timeouts retry for up to 8 total attempts over 24 hours; Retry-After may extend backoff
within the deadline. Other 4xx are permanent rejections. Redirects are not followed.
Retries and replay re-send the earlier tracking update without another tracking charge;
live vessel metadata may change. Replay is available for 48 hours.

### Management
GET /webhook-endpoints; GET /webhook-subscriptions?page=0&pageSize=25&status=ACTIVE&q=MSKU
(pageSize max 100); POST /webhook-subscriptions/{id}/activate, /pause or /cancel;
GET /webhook-subscriptions/{id}/executions (latest 100). List rows expose status and blockedReason.
Manual runs require ACTIVE status, current time inside the window and capacity for pending deliveries.
Pause defers unsent work without consuming an attempt; an in-flight acquisition can finish and
be billed, with delivery deferred. Window completion stops new work but accepted acquisitions can finish.
Cancel invalidates pending work; a request already sent to a receiver cannot be recalled.

```bash
curl -X POST https://api.panvaya.com/api/v1/webhook-subscriptions/{subscriptionId}/run \
  -H "X-API-Key: pv_live_your_key_here" \
  -H "Idempotency-Key: a4c81f34-31e2-45a8-92cb-1f6b8648e3a2"
```

Replay a DELIVERED or DEAD execution only with an ACTIVE/COMPLETED subscription and active endpoint,
within the 48-hour replay window. Set If-Match to lease_generation from execution history; 412 means refresh.

```bash
curl -X POST https://api.panvaya.com/api/v1/webhook-executions/{executionId}/replay \
  -H "X-API-Key: pv_live_your_key_here" \
  -H "If-Match: 1"
```


## Embedded tracking

**Embedded Tracking UI** — Configure in /dashboard/integrations?tab=embedding. EMBED_SEA_TRACKING charges the organization's configured credit cost per successful search, subject to its shared credit limit, and shares ocean reference slots with REST/webhooks. GET /api/v1/tracking-widgets/{widgetId}/references returns {id,allowedReferences}; PATCH on the same path accepts add/remove canonical references. Both require a server-side active organization-admin API key, enforce widget ownership, and are unmetered. Reads use safe logs; mutations retain a small security audit. Enable privateAccess and POST /api/v1/tracking-widgets/{widgetId}/launch from the customer backend with an existing active organization-admin API key, parentOrigin and authorized references. Keep the key server-side. Launches expire in 60 seconds and are single-use; load /embed/{widgetId}#launch=CODE immediately. The widget exchanges the code for a 15-minute reference-scoped session. Revocation, owner permissions and configuration versions are rechecked. Private widgets never issue anonymous sessions, including hosted mode. Reference changes, launches, page loads and failures are free. Tracking requests store only billing/idempotency state, not responses. Retrying a completed successful idempotency key returns HTTP 409 REQUEST_ALREADY_COMPLETED without another acquisition or charge; explicitly start a new search to retrieve tracking again at the configured cost. Public widgets remain copyable; origin restrictions alone do not authenticate visitors. Full API documentation: https://panvaya.com/developers/embedding.
