# Container tracking webhooks: watches and signed events

> For the complete documentation index, see [llms.txt](https://docs.containerfeed.com/llms.txt).

URL: https://docs.containerfeed.com/webhooks

A container trip runs for weeks, so polling every container is wasteful. Set one webhook URL with `PUT /v1/webhook`, then follow containers with `POST /v1/watches`. OpenContainer re-checks each one on a schedule and POSTs a signed `tracking.updated` event when its status, its newest move or its ETA changes. You set up nothing with the shipping lines.

The first check runs at once and returns the same JSON as `GET /v1/track`. A webhook is sent when a scheduled check finds a change; it is not a live push from the line.

You don't need a watch to track a container. `GET /v1/track` stays the simplest way to answer "where is it" on demand. Watches are for when you'd rather be told.

## In the dashboard

Everything below can be done without code at [app.containerfeed.com](https://app.containerfeed.com):

- **[Watches](https://app.containerfeed.com/watches)**: paste up to 100 container numbers at once, with an optional line and a label (saved as `metadata.label`, such as a PO or customer). See each container's status, latest move and next check, expand its full move history, or stop watching.
- **[Webhooks](https://app.containerfeed.com/webhooks)**: set the endpoint URL and payload format, reveal or rotate the `whsec_…` signing secret, send a test event, and see every delivery from the last 30 days with its HTTP status, attempts and a **Resend** button.

## 1. Set your webhook

```bash
curl -X PUT https://api.containerfeed.com/v1/webhook \
  -H "Authorization: Bearer $OPENCONTAINER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/hooks/containers"}'
```

The URL must be `https://`. The response has your signing `secret` (`whsec_…`). It stays the same when you change the URL; send `"rotateSecret": true` for a new one. `POST /v1/webhook/test` sends a `webhook.test` event and tells you what your endpoint answered. `DELETE /v1/webhook` removes the URL.

## 2. Watch containers

```bash
curl -X POST https://api.containerfeed.com/v1/watches \
  -H "Authorization: Bearer $OPENCONTAINER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"trackingNumber": "MEDU1234562", "metadata": {"po": "PO-1042"}}'
```

- Send `"trackingNumbers": [...]` for up to 100 at once.
- `carrier` works as on [`/v1/track`](https://docs.containerfeed.com/tracking#line-detection): needed for a bill of lading or a leased container, for example `{"trackingNumber": "TGHU9123451", "carrier": "msc"}`. A number no line's prefix matches, sent without `carrier`, is refused with `400 unknown_carrier`.
- `metadata` is any JSON object under 2 KB. It comes back in every event for that watch.

The response is the watch, with its first `result` (`201` for a new watch, `200` if the number was already watched):

```json
{
  "id": "wat_109060ade9f9a48732117f7a",
  "trackingNumber": "MEDU1234562",
  "carrier": "msc",
  "status": "in_transit",
  "active": true,
  "metadata": { "po": "PO-1042" },
  "createdAt": "2026-11-02T09:14:05Z",
  "checkedAt": "2026-11-02T09:14:09Z",
  "nextCheckAt": "2026-11-02T15:14:09Z",
  "endedAt": null,
  "endReason": null,
  "result": { "carrier": "msc", "status": "in_transit", "...": "same shape as /v1/track" },
  "error": null
}
```

A new watch counts as one tracked container, like a lookup. Re-checks after that are free. An account can have 5,000 active watches. Free accounts can start one watch in any 7 days to try it; paid plans have no weekly limit.

| Route | |
| --- | --- |
| `GET /v1/watches` | Active watches, newest first. `?active=false` for ended ones; `?limit=` (max 200), `?cursor=` from `nextCursor`. |
| `GET /v1/watches/:id` | One watch with its last `result` or `error`. |
| `DELETE /v1/watches/:id` | Stop watching. |

### How often we check

| Status | Next check |
| --- | --- |
| `out_for_delivery` (full container out to the consignee) | 1 hour |
| `exception` (a hold) | 2 hours |
| `in_transit`, `label_created`, `unknown` | 6 hours |

A failed check is tried again in 30 minutes; a `not_found` in 2 hours.

A watch ends by itself when the empty container is returned (`delivered`) or the cargo is `returned`, after 14 days with no record at the line, or after 90 days in all.

## What sends an event

`tracking.updated` is sent when a check finds that the container's status, its newest move or its ETA changed. The first successful check always sends one.

| Change at the line | What you get |
| --- | --- |
| A new milestone: gate in, loaded, vessel departed, transshipment, vessel arrived, discharged, hold, gate out, empty returned | `tracking.updated` with the new move first in `result.events` |
| Status change, e.g. to `out_for_delivery` when the full container leaves the terminal | `tracking.updated`, with `previousStatus` |
| ETA drift | `tracking.updated` with the new `result.estimatedDelivery` (and `result.ocean.eta`) |
| Vessel or voyage rollover | `tracking.updated` when the line posts the change as a new move or a new ETA; the new vessel and voyage are in `result.ocean.vessel` and on the events |
| Port of loading or discharge changed | `tracking.updated` when the line posts it as a new move or ETA; the new ports are in `result.ocean.pol` and `result.ocean.pod` |

Store the last `result` per watch and compare it with the new one to see exactly what moved.

## Events

```json
{
  "id": "evt_63e401d5f73a4c31ef8fa8d9",
  "type": "tracking.updated",
  "createdAt": "2026-11-06T18:20:36Z",
  "data": {
    "watch": { "id": "wat_109060ade9f9a48732117f7a", "trackingNumber": "MEDU1234562", "carrier": "msc", "metadata": { "po": "PO-1042" } },
    "previousStatus": "in_transit",
    "result": { "carrier": "msc", "status": "out_for_delivery", "...": "same shape as /v1/track" }
  }
}
```

- `tracking.updated`: something changed. `data.result` is the full tracking result.
- `watch.ended`: the watch stopped without a final status. `data.reason` is `not_found` (14 days with no record) or `expired` (90 days). A container whose empty is returned ends with its last `tracking.updated`.
- `webhook.test`: sent by `POST /v1/webhook/test` and the dashboard's test button.

## Delivery and retries

Any `2xx` within 10 seconds counts as delivered. Anything else is retried after 1, 5, 30, 120, 360 and 720 minutes, then marked failed. `GET /v1/webhook/deliveries` lists the last 30 days (`?state=delivered`, `pending` or `failed`), `GET /v1/webhook/deliveries/:id` shows one with its payload, and `POST /v1/webhook/deliveries/:id/retry` sends it again.

A retry can arrive after a newer event, and in rare cases one event arrives twice. Deduplicate on the event `id` (also in the `OpenContainer-Event-Id` header) and order by `createdAt`.

## Signatures

Every request carries `OpenContainer-Signature: t=<unix seconds>,v1=<hex>`. `v1` is HMAC-SHA256 of `"<t>.<raw body>"`, keyed with your secret. Check it against the raw body, before parsing, and reject old `t` values.

```js tab="Node"
import crypto from "node:crypto";

function verify(rawBody, header, secret, toleranceSec = 300) {
  const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const expected = crypto.createHmac("sha256", secret).update(`${t}.${rawBody}`).digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(t)) < toleranceSec;
  return fresh && crypto.timingSafeEqual(Buffer.from(v1, "hex"), Buffer.from(expected, "hex"));
}
```

```python tab="Python"
import hashlib, hmac, time

def verify(raw_body: bytes, header: str, secret: str, tolerance: int = 300) -> bool:
    parts = dict(p.split("=", 1) for p in header.split(","))
    expected = hmac.new(secret.encode(), f"{parts['t']}.".encode() + raw_body, hashlib.sha256).hexdigest()
    return abs(time.time() - int(parts["t"])) < tolerance and hmac.compare_digest(parts["v1"], expected)
```

## Terminal49-compatible format

Coming from Terminal49? Select **Terminal49** on the [Webhooks dashboard](https://app.containerfeed.com/webhooks), or set the format by API, and the same events go out in a Terminal49-compatible payload, so a receiver built for Terminal49 keeps working:

```bash
curl -X PUT https://api.containerfeed.com/v1/webhook \
  -H "Authorization: Bearer $OPENCONTAINER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"format": "terminal49"}'
```

The schedule, retries and `OpenContainer-Signature` are the same in either format; point your receiver's signature check at your OpenContainer secret. Set `"format": "opencontainer"` to switch back to the native events above. See [Comparison](https://docs.containerfeed.com/comparison#terminal49) for the rest of a migration.
