Most fleet monitoring starts as a script that asks for the position of every vessel every few minutes and compares the answers with the previous run. It works for five ships. At fifty, it spends most of its time asking about vessels that have not moved, and it still misses the moment a ship arrived because it only looked every ten minutes.
The better design is the other way round: tell the data provider which vessels you care about, and let it call you when something happens. This article walks through that design with webhooks, from the watchlist to a receiver you can trust.
The building blocks
A fleet monitoring setup needs four pieces:
- A watchlist. The vessels you follow, identified by MMSI or IMO number. With our API this is a fleet: a named list of vessels on your account.
- Events. What you want to be told about. Ours are
fleet.port_call(a vessel entered or left a port, withphase: enterorexit),fleet.gone_silent(a vessel stopped reporting for longer than a threshold),fleet.destination_changed(the destination it broadcasts changed) andfleet.position(a sampled position of each vessel). - A receiver. An HTTPS endpoint of yours that accepts the events, checks that they are genuine and hands them to the rest of your system.
- A fallback read. One call that returns the current state of the whole fleet, for dashboards and for recovering after downtime.
Step 1: build the watchlist
Create a fleet in the app, then fill it from your own system through the API. Adding vessels by IMO number is the safer choice when you have it, because it survives a change of flag (see MMSI vs IMO number).
import os, requests
API = "https://wingo-marine.com/api/public/v1"
HEADERS = {"X-API-Key": os.environ["WINGO_KEY"]}
FLEET_ID = 3
imos = ["9074729", "9312341"]
r = requests.post(f"{API}/fleets/{FLEET_ID}/vessels/bulk", json={"ids": imos}, headers=HEADERS, timeout=30)
r.raise_for_status()
print(r.json())
Changes to fleets need an active plan, and the plan sets how many vessels your fleets can hold in total. The same vessel in two fleets counts once.
Step 2: register a webhook endpoint
In the Webhooks page of the app, add the URL of your receiver, choose the events you want, and optionally restrict the endpoint to some of your fleets. The page shows a signing secret once: store it next to your other secrets, never in the code.
Every delivery is a JSON POST with these headers:
| Header | Meaning |
|---|---|
X-AIS-Event |
the event name, such as fleet.port_call |
X-AIS-Timestamp |
when the delivery was signed, in milliseconds |
X-AIS-Signature |
hex HMAC-SHA256 of ${timestamp}.${rawBody} with your secret |
Idempotency-Key |
the same value on every retry of the same event |
A port call event looks like this (illustrative values):
{
"event": "fleet.port_call",
"phase": "enter",
"port": { "id": 42, "name": "Rotterdam", "locode": "NLRTM" },
"vessel": { "mmsi": 211331640, "name": "EXAMPLE VESSEL", "lat": 51.95, "lon": 4.05 },
"fleets": [{ "id": 3, "name": "Charters" }],
"occurredAt": "2026-12-03T09:41:12.000Z"
}
Step 3: write a receiver you can trust
A webhook endpoint is a public URL, so anyone who finds it can post to it. The signature is what tells a real event from a forged one. Three rules make a receiver robust:
- Verify the signature on the raw body, before parsing JSON. Re-serialising the parsed object changes whitespace and key order, and the signature will no longer match.
- Reject old timestamps. Refuse deliveries whose timestamp is more than a few minutes away from your clock, so a captured request cannot be replayed later.
- Answer fast, work later. Return
2xxas soon as the event is verified and stored, then process it in the background. Any non-2xx answer, a redirect included, counts as a failure and the delivery is retried, and an endpoint that keeps failing is eventually disabled.
Here is a minimal receiver in Node.js with Express:
import express from "express";
import { createHmac, timingSafeEqual } from "node:crypto";
const app = express();
const SECRET = process.env.WINGO_WEBHOOK_SECRET;
const seen = new Set(); // use a database table in production
app.post("/hooks/vessels", express.raw({ type: "application/json" }), (req, res) => {
const ts = req.get("X-AIS-Timestamp") ?? "";
const got = req.get("X-AIS-Signature") ?? "";
const expected = createHmac("sha256", SECRET).update(`${ts}.${req.body}`).digest("hex");
const valid = got.length === expected.length && timingSafeEqual(Buffer.from(got), Buffer.from(expected));
if (!valid || Math.abs(Date.now() - Number(ts)) > 5 * 60_000) return res.sendStatus(401);
const key = req.get("Idempotency-Key");
if (seen.has(key)) return res.sendStatus(200); // a retry of an event we already have
seen.add(key);
const event = JSON.parse(req.body.toString("utf8"));
queue.push(event); // your own background processing
res.sendStatus(200);
});
app.listen(8080);
The idempotency key matters because retries are normal: if your answer is lost on the way back, the same event arrives again. Store the key with the event and ignore duplicates.
Step 4: turn events into decisions
Each event maps naturally to an action:
fleet.port_callwithphase: enter: mark the vessel as arrived, notify the operations team, start a laytime or demurrage clock.fleet.port_callwithphase: exit: record the departure, compute the time in port, and ask for an ETA to the next port with the vessel ETA API.fleet.destination_changed: a change of plan worth a look, especially if the new destination is not the one in your contract.fleet.gone_silent: the vessel stopped reporting. Usually it has sailed out of receiver range; sometimes the transponder was switched off. Either way, someone should know.
Port calls are also available after the fact, with arrival, departure and duration, from the port calls API, which is useful to rebuild a timeline or to check a claim.
Step 5: keep a fallback read
Webhooks tell you about changes. Dashboards also need the current state, and after an outage of your receiver you want to resynchronise. One call returns the latest position of every vessel in a fleet:
curl -H "X-API-Key: $WINGO_KEY" "https://wingo-marine.com/api/public/v1/fleets/3/positions"
Call it when your dashboard loads, and on a slow schedule (every 15 or 30 minutes is plenty) as a safety net. That is a handful of calls an hour instead of one call per vessel per poll.
Common mistakes
- Parsing before verifying. The signature covers the exact bytes you received.
- Doing slow work before answering. A receiver that calls three other services before returning
200will time out and trigger retries. - Treating
gone_silentas an emergency. Most silences are coverage gaps; route them to a review queue, not to a pager. - Tracking by name. Names are not unique. Use MMSI or IMO everywhere.
Summary
A watchlist, four kinds of events, a receiver that verifies signatures and handles retries, and one fallback call: that is a fleet monitor that scales from five vessels to five hundred without changing shape. The vessel location API covers the positions, the API reference documents every payload, and Pricing lists the plans that include fleets and webhooks.