---
name: wingo-marine
description: >
  Integrate Wingo Marine (wingo-marine.com) — live AIS vessels, fleets, ports,
  on-demand satellite position checks, a credit-metered public API and signed
  fleet webhooks. Use when building shipping/logistics apps, vessel tracking,
  port calls or maritime alerts; when the user mentions Wingo Marine, AIS API,
  fleet webhooks, MMSI/IMO, or "conectează Wingo Marine".
---

# Wingo Marine — integration skill

**Product:** [Wingo Marine](https://wingo-marine.com) — real-time global AIS monitoring  
**Built by:** [Freevox](https://freevox.ro) · part of the [Wingo suite](https://websites.wingo.ro/en#platforme)

Use this skill to wire an external app to Wingo Marine via:

1. **Public REST API** (pull, credit-metered, `X-API-Key`)
2. **Webhooks** (push, HMAC-signed fleet events)

Do **not** invent endpoints, parameters or fields. Everything below matches the live API; the
authoritative, always-current references are on the same host:

| Reference | URL |
|---|---|
| API reference (live credit costs and rate limit) | `https://wingo-marine.com/docs/api` |
| OpenAPI 3.1 (every path, schema and webhook payload) | `https://wingo-marine.com/openapi.json` |
| Plain-text reference for LLMs | `https://wingo-marine.com/llms-full.txt` |
| Keys and daily usage (signed in) | `https://wingo-marine.com/developer` |

The costs and limits in this file are the **defaults**; the operator can change them. A successful
response tells you what its route cost (`X-Credits-Cost`); the satellite checks of `verify=true` are
debited separately (see below).

---

## Base URLs

| Surface | URL |
|---|---|
| App / UI | `https://wingo-marine.com` |
| Public API | `https://wingo-marine.com/api/public/v1` |
| Session API (browser cookies) | `https://wingo-marine.com/api/v1` — **not** for server-to-server |
| Auth | `https://wingo-marine.com/api/auth/*` (better-auth, browser) |

Keep the base URL in configuration (one value), never spread through the code. The public API is
never redirected: if the site's address changes, the previous API address keeps answering for a
transition period on every method, with the same keys, costs, limits and webhook signatures, and
the base URL is the only value to update.

The public routes answer CORS with `Access-Control-Allow-Origin: *` (no cookies; the key is the only
authentication), but the key still belongs on a server (see the rules at the end).

---

## Auth — API keys

1. Create a free account on wingo-marine.com (no card). New accounts get a one-time free credit bonus
   once their email is verified (amount on `https://wingo-marine.com/pricing`).
2. **Developer → API** (`/developer`): create a key → shown **once**. Up to 10 active keys per account.
3. Credits: monthly plan credits (reset at each renewal) and one-time packs (never expire). Fleets and
   webhooks need a paid plan; the read API works on any account with credits.
4. Every public request:

```http
X-API-Key: ais_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

| Status | Meaning |
|---|---|
| 400 | Invalid parameter (MMSI/IMO/LOCODE, bbox, pagination, bulk body) |
| 401 | Missing, unknown or revoked key |
| 402 | Not enough credits — body `{ "statusCode": 402, "message": "…", "required": 5, "remaining": 2 }` |
| 403 | Disabled account, or a fleet change without an active subscription |
| 404 | Vessel, port or fleet not found (a fleet of another account is a 404 too) |
| 409 | Vessel already in the fleet |
| 429 | Rate limit: **10 requests/second per key** by default (fixed 1-second window); the `Retry-After` header gives the whole seconds to wait |

The `message` texts are not part of the contract: most are in Romanian (for example `Cheie API lipsă`),
some parameter errors are in English. Branch on the status code, never on the text. A request refused
before metering (401, 429, the 403 of a disabled account) and the 402 of an empty balance cost nothing,
but a request that reaches its endpoint is billed even when it then fails (400, 404, 409, the 403 of a
fleet change without a subscription, the 402 of a `verify=true` check the balance cannot cover): validate
ids before calling. There are no overage charges — at zero credits the API answers 402.

Every successful response carries:

- `X-Credits-Cost` — credits the route cost (`0` on an unlimited account); the per-vessel `verify=true`
  checks are not included
- `X-Credits-Remaining` — credits left after the route's cost (`unlimited` on an unlimited account)

Store the key in env / a secret manager. Never commit it. Never put it in a browser app without a backend.

---

## Identifiers

- **Vessels:** MMSI (9 digits) or IMO (7 digits) only — never internal ids. Resolved by length: 9 → MMSI, 7 → IMO.
- **Ports:** UN/LOCODE (5 letters or digits, case-insensitive).
- **Fleets:** the integer `id` from `GET /fleets`.
- Vessel names are **not** unique. An invalid identifier returns 400.

---

## Public API (pull)

Base: `https://wingo-marine.com/api/public/v1`

| Method & path | Purpose | Default credits |
|---|---|---|
| `GET /vessels?search=&page=&pageSize=` | Search vessels (+ filters below) | 2 |
| `GET /vessels/{mmsi\|imo}` | Vessel detail and last position (`verify=true` → satellite check) | 1 (+10 per vessel verified) |
| `GET /vessels/{mmsi\|imo}/track?hours=` | Sampled track, oldest first (`hours` default 24, ≤ 168) | 5 |
| `GET /vessels/in-bbox?minLat=&minLon=&maxLat=&maxLon=` | Vessels in a box (≤ 1000, grid-sampled; + filters below) | 5 |
| `GET /ports?search=&country=&page=&pageSize=` | Search ports | 1 |
| `GET /ports/{locode}` | Port detail | 1 |
| `GET /fleets` | Your fleets with vessel counts | 1 |
| `GET /fleets/{id}` | One fleet with its vessels | 1 |
| `GET /fleets/{id}/vessels` | Memberships only | 1 |
| `GET /fleets/{id}/positions` | Positions of the whole fleet (`verify=true` → satellite check) | 2 (+10 per vessel verified) |
| `POST /fleets/{id}/vessels` | Add a vessel `{ "id": "<mmsi or imo>", "label": "…" }` (label optional) | 2 |
| `POST /fleets/{id}/vessels/bulk` | Add up to 200 vessels `{ "ids": ["…"] }`, per-id outcome | 2 per call |
| `PATCH /fleets/{id}/vessels/{mmsi}` | Set or clear the label `{ "label": "…" \| null }` | 1 |
| `DELETE /fleets/{id}/vessels/{mmsi}` | Remove a vessel from the fleet | 1 |

**Fleets.** Each key sees only its owner's fleets; fleets are created in the app. Fleet changes need an
**active subscription** on the key's account and respect the plan's limit of unique vessels (the same
vessel in two fleets uses one slot; over the limit → 400). In a bulk add each id succeeds or fails on its
own, the missing subscription and the plan limit included, so the call itself answers 200 (and is billed):
`{ "added": [ … ], "failed": [ { "id", "message" } ] }`.

**Pagination.** The two searches (`GET /vessels`, `GET /ports`) return
`{ "items": [ … ], "total": N, "page": 1, "pageSize": 50 }`; `page` is 1-based, `pageSize` defaults to 50
and is clamped to 100. The other collections (in-bbox, track, `GET /fleets`, `GET /fleets/{id}/vessels`,
`GET /fleets/{id}/positions` without `verify`) are plain JSON arrays.

**Search.** `search` (max 64 characters) matches every word against the vessel name, and digits as an MMSI
or IMO prefix; prefix matches rank first. Ports: every word must match the name, UN/LOCODE or country;
`country` is a case-insensitive substring of the country name.

**Filters** on `GET /vessels` and `GET /vessels/in-bbox` (lists comma-separated):

| Parameter | Meaning |
|---|---|
| `category` | `cargo`, `tanker`, `passenger`, `high_speed`, `fishing`, `tug`, `pleasure`, `sailing`, `military`, `special`, `other`, `unknown` |
| `shipType` | AIS ship type codes (0–99) |
| `navStatus` | AIS navigational status (0 under way, 1 at anchor, 5 moored, … 0–15) |
| `minSpeed` | Minimum speed over ground, knots |
| `flag` | Flag state, ISO 3166-1 alpha-2, derived from the MMSI (`NL,DE`) |
| `destination` | Case-insensitive substring of the AIS destination (max 32 characters) |
| `signalAgeMaxMin` | Last position at most this many minutes old (1–10080) |
| `minLength` / `maxLength` | Length overall in metres, from the AIS dimensions |
| `includeUnverified` | `true` also returns vessels known only by name (see below) |

**In a box.** `minLat`/`maxLat` in −90…90, `minLon`/`maxLon` in −180…180; a west edge greater than the east
edge wraps the antimeridian. When the box holds more than 1000 vessels the answer is **not** "the freshest
1000": the box is split into a grid and every cell gets a share proportional to its real number of vessels
(larger ships first, then the freshest), so sparse seas are not crowded out by dense ones.

### Response shapes

- **Vessel** (lists, in-bbox): `mmsi, imo, name, callsign, shipType, category, lat, lon, sog, cog, heading,
  navStatus, destination, eta, positionTs, unverified`. List rows have `eta: null`.
- **Vessel detail** adds the real `eta`, the AIS dimensions `dimA, dimB, dimC, dimD` (metres from the antenna
  to bow, stern, port, starboard) and `draught`.
- **Track point:** `{ "lat", "lon", "sog", "cog", "ts" }`. History is sampled (not every raw AIS message)
  and covers at most the last 7 days.
- **Port:** `{ "id", "locode", "name", "country", "lat", "lon", "updatedAt" }`.
- **Fleet:** `{ "id", "name", "vesselCount", "createdAt" }`; `GET /fleets/{id}` → `{ "fleet": {…}, "vessels": [ … ] }`;
  membership: `{ "mmsi", "label", "name", "imo", "addedAt", "verifyIntervalMinutes", "verifyLastRunAt", "verifyLastStatus" }`.
- **Fleet position:** `mmsi, label, name, category, lat, lon, sog, cog, heading, navStatus, destination,
  positionTs, silentHours, positionAccuracyM` (hours since the last report; position fields are `null` for a
  vessel that never reported). `positionAccuracyM` is the estimated error margin of the position, in meters,
  or `null` when the position is not an estimate.

### Unverified vessels (`includeUnverified=true`)

Some vessels are known only by name, from a source that does not report an MMSI. They are **excluded by
default** from `GET /vessels` and `GET /vessels/in-bbox`; add `includeUnverified=true` to receive them. Such a
row has `mmsi: null` and `unverified: true`. Use them for coverage in areas
without AIS reception, never as a stable identity: they cannot be addressed by id, and once matched to the
real vessel they disappear from the list.

### Satellite position checks (`verify=true`)

Stored positions are passive: the last AIS report received. Add `verify=true` (or `verify=1`) on
`GET /vessels/{id}` or `GET /fleets/{id}/positions` to fetch the vessel's position **now** from an external
tracking source; it is applied to the catalogue only if newer than the stored one.

- **Cost:** `vesselVerifyNow`, **10 credits per vessel actually checked**, on top of the route's cost. A result
  served from the 5-minute cache, a skipped vessel and an ineligible one cost nothing. The check is debited
  when it runs, so `X-Credits-Cost` / `X-Credits-Remaining` show only the route's cost: read the
  `verification.status` (table below) to know what was billed.
- **Eligibility:** the vessel needs an MMSI, an IMO **and** a name; otherwise `status: "ineligible"`.
- **Waiting:** the request waits about 20 s at most; past that you get the stored position with
  `status: "queued"` and the check finishes in the background (the next call sees it; it is billed).
- Every affected payload gains a `verification` object:

```json
"verification": {
  "status": "ok",
  "verifiedAt": "2026-07-29T13:06:30.000Z",
  "positionTs": "2026-07-29T13:06:00.000Z",
  "source": "satellite",
  "reason": null
}
```

| `status` | Meaning | Billed |
|---|---|---|
| `ok` | Fresh check, valid position (applied only if newer than the stored one) | yes |
| `cached` | A check from the last 5 minutes answered | no |
| `queued` | Not finished within the wait; stored position returned, the job completes | yes |
| `skipped` | Batch semantics skipped the vessel (`reason`: recent position, checked recently, cap reached, `no_credits`) | no |
| `ineligible` | MMSI, IMO or name missing | no |
| `failed` | The run failed (`reason` says why) | yes |

- **Fleet batch:** with `verify=true`, `/fleets/{id}/positions` returns `{ "items": [ … ], "batch": { "cap", "capApplied", "verified", "skipped" } }`.
  Only eligible vessels whose position is older than 15 minutes and that were not checked in the last
  5 minutes run, at most **25 per request**; `batch.capApplied: true` tells you the cap cut the batch, so a
  truncated answer is never mistaken for full coverage.
- **Credits:** a single-vessel request that cannot afford the check gets **402** before any external call
  (body `"required": "vesselVerifyNow"`; the route's own credit is still charged); a batch checks as many
  vessels as the balance covers and returns the rest `skipped` with `reason: "no_credits"`.
- Use it sparingly: poll the stored positions (cheap) and add `verify=true` only when freshness matters
  (a chartered vessel check, a port-call confirmation, a dispute).

### Example — TypeScript (server)

```ts
const BASE = process.env.WINGO_MARINE_API_BASE ?? 'https://wingo-marine.com/api/public/v1';
const KEY = process.env.WINGO_MARINE_API_KEY!;

async function wmGet<T>(path: string): Promise<T> {
  const res = await fetch(`${BASE}${path}`, { headers: { 'X-API-Key': KEY } });
  if (res.status === 402) throw new Error('Wingo Marine: out of credits (top up or upgrade)');
  if (res.status === 429) throw new Error(`Wingo Marine: rate limited, retry after ${res.headers.get('Retry-After')} s`);
  if (!res.ok) throw new Error(`Wingo Marine ${res.status}: ${await res.text()}`);
  return res.json() as Promise<T>;
}

// Search, with filters
const page = await wmGet<{ items: unknown[]; total: number }>(
  '/vessels?search=maersk&category=cargo&page=1&pageSize=25',
);

// Detail by MMSI, then a satellite check when freshness matters
const vessel = await wmGet('/vessels/244660920');
const checked = await wmGet('/vessels/244660920?verify=true');

// Fleet live positions
const positions = await wmGet('/fleets/3/positions');
```

### Example — curl

```bash
curl -sS -H "X-API-Key: $WINGO_MARINE_API_KEY" \
  "https://wingo-marine.com/api/public/v1/vessels?search=maersk"
```

---

## Webhooks (push)

Managed in the app: **https://wingo-marine.com/webhooks** (signed in, paid plans; the number of endpoints depends
on the plan). Each endpoint has a **signing secret** (`whsec_…`) shown once at create/rotate, a test button
and a delivery log. The URL must be public (`https://` recommended; private and loopback hosts are refused).

### Events (vessels in your fleets only)

| Event | When |
|---|---|
| `fleet.position` | Sampled position of a watched vessel |
| `fleet.port_call` | Entered or left a port geofence (`phase: enter\|exit`, plus `port: { id, name, locode }`) |
| `fleet.gone_silent` | No AIS report for longer than the silence threshold (`silentHours`) |
| `fleet.destination_changed` | AIS destination changed (`previousDestination`, `destination`) |
| `test` | Sent manually from the Webhooks page |

Each endpoint receives only the events it subscribes to (at least one, chosen in the app; the test button
sends `test` to it whatever it subscribes to). Optional: restrict an endpoint to specific `fleetIds`;
empty = all of the owner's fleets.

### Delivery headers

```
Content-Type:        application/json
X-AIS-Event:         fleet.position
X-AIS-Timestamp:     1752745920000        # ms since the epoch
X-AIS-Signature:     <hex HMAC-SHA256>
Idempotency-Key:     <delivery id>        # stable across retries
X-AIS-Delivery-Id:   <delivery id>        # same id
User-Agent:          Wingo-Marine-Webhooks/2.0
```

Neither the signature nor the headers contain the site's host: a change of address changes nothing for
webhook receivers.

### Verify signature (Node)

```ts
import crypto from 'crypto';

function verifyWingoWebhook(
  rawBody: Buffer | string,
  headers: { timestamp: string; signature: string },
  secret: string, // whsec_…
  maxSkewMs = 5 * 60 * 1000,
): boolean {
  const ts = Number(headers.timestamp);
  if (!Number.isFinite(ts) || Math.abs(Date.now() - ts) > maxSkewMs) return false;
  const body = typeof rawBody === 'string' ? rawBody : rawBody.toString('utf8');
  const expected = crypto
    .createHmac('sha256', secret)
    .update(`${headers.timestamp}.${body}`)
    .digest('hex');
  const a = Buffer.from(expected, 'utf8');
  const b = Buffer.from(headers.signature, 'utf8');
  if (a.length !== b.length) return false;
  return crypto.timingSafeEqual(a, b);
}

// Express: app.post('/hooks/wingo', express.raw({ type: 'application/json' }), ...)
// Use the raw body for the HMAC — do not re-JSON.stringify.
```

### Payload shape (position)

```json
{
  "event": "fleet.position",
  "vessel": {
    "mmsi": 244660920,
    "lat": 51.9, "lon": 4.1,
    "sog": 12.4, "cog": 88.1, "heading": 90,
    "navStatus": 0, "destination": null,
    "positionTs": "2026-07-18T12:00:00.000Z"
  },
  "fleets": [{ "id": 3, "name": "North Sea" }],
  "occurredAt": "2026-07-18T12:00:01.000Z"
}
```

The other payloads (port call, gone silent, destination changed, test) are in the `webhooks` section of
`https://wingo-marine.com/openapi.json`.

### Consumer checklist

1. Public endpoint; answer **2xx quickly** (do heavy work async). Redirects are not followed: a 3xx counts as a failure.
2. Verify the HMAC over `${X-AIS-Timestamp}.${rawBody}` with the **raw** body.
3. Reject a timestamp more than 5 minutes off.
4. Dedupe on `Idempotency-Key` / `X-AIS-Delivery-Id`.
5. A failed delivery is retried with backoff (about 30 s, 2 min, 8 min and 30 min; 5 attempts in all); after
   20 consecutive failed deliveries the endpoint is disabled and must be re-enabled in the app.

---

## Recommended integration patterns

| Goal | Prefer |
|---|---|
| Occasional vessel lookup / search | Public API |
| Always-on map of "my ships" | Fleets + `GET …/positions`, or webhook `fleet.position` |
| Position *now* for one vessel | `GET /vessels/{id}?verify=true` (billed per check) |
| Port enter/exit automation | Webhook `fleet.port_call` |
| Silence / missing AIS | Webhook `fleet.gone_silent` |
| Destination changes | Webhook `fleet.destination_changed` |
| Bulk offline analysis | Not a raw AIS dump — use API tracks (7 days) or contact Freevox |

**Typical flow for a logistics app:**

1. Create fleet(s) in the Wingo Marine app (paid plan)
2. Add MMSIs/IMOs (API bulk or the app)
3. Register a webhook for `port_call` + `gone_silent` (+ optional `position`)
4. Implement the signed receiver; store the delivery id for idempotency
5. Use the API for on-demand detail/track when a user opens a vessel screen

---

## Env template for client apps

```bash
WINGO_MARINE_API_BASE=https://wingo-marine.com/api/public/v1
WINGO_MARINE_API_KEY=ais_...
WINGO_MARINE_WEBHOOK_SECRET=whsec_...
```

---

## Implementation rules for the agent

1. **Server-side only** for the API key and the webhook secret.
2. Always handle **402** (top-up / upgrade) and **429** (wait the seconds in `Retry-After`) with clear UX.
3. Validate ids before calling: `/^\d{9}$/` (MMSI) or `/^\d{7}$/` (IMO); UN/LOCODE `/^[A-Za-z0-9]{5}$/`.
4. Branch on HTTP status codes, not on error messages (they are not a contract; most are in Romanian).
5. When adding webhooks, implement **signature verification** before trusting the body.
6. Read the base URL from configuration (`WINGO_MARINE_API_BASE`).
7. Prefer incremental integration: read-only API first, then fleets, then webhooks; `verify=true` only where it pays off.
8. Point humans to **https://wingo-marine.com/developer** for keys and usage and **https://wingo-marine.com/docs/api** for live costs.
9. Branding in user-facing copy: **Wingo Marine** (not "AIS Monitor").

---

## Support / product links

- App: https://wingo-marine.com
- API reference: https://wingo-marine.com/docs/api
- Freevox: https://freevox.ro
- Wingo suite: https://websites.wingo.ro/en#platforme — the Freevox product suite Wingo Marine belongs to
- Wingo UI: https://wingo-ui.com — the React component library the Wingo Marine interface is built with
- Wingo Websites: https://websites.wingo.ro/en — websites and online stores by the same team
- Public skill URL (this file when deployed): https://wingo-marine.com/skills/wingo-marine/SKILL.md
