# Panvaya: Embedded tracking

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

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

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