# Panvaya: Ocean tracking webhooks

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.

## 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`).


## 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"
```


Full guide: https://panvaya.com/developers/docs.md
