Receive tracking event
Download OpenAPIWhen an event you subscribed to occurs, TimeToCargo sends a POST request to your callback_url.
Return 200 OK as soon as you receive the event. If processing takes time, enqueue the event, send the response, and then process it asynchronously. TimeToCargo waits up to 10 seconds for a response.
Delivery succeeds with any 2xx status. TimeToCargo retries after 408, 409, 425, 429, and 5xx statuses, as well as timeouts and DNS or network errors. It does not retry after 400, 401, 403, 404, or 422. After a 429 response, TimeToCargo honors the Retry-After header when present. Each delivery can have up to five attempts.
To verify the source of the request, use the webhook secret and the x-timetocargo-timestamp and x-timetocargo-signature headers. The signature is an HMAC SHA-256 digest of timestamp + '.' + rawBody, prefixed with sha256=. Use the unchanged request body as rawBody. Signature verification is optional, but recommended.
Node.js / Express
import crypto from 'node:crypto';import express from 'express';const app = express();const secret = process.env.TIMETOCARGO_WEBHOOK_SECRET;if (!secret) { throw new Error('TIMETOCARGO_WEBHOOK_SECRET is not set');}function queueWebhook(payload: unknown): void { // Enqueue the event, save it to your database, // or pass it to another service for processing. console.log('Webhook received from TimeToCargo:', payload);}app.post('/webhooks/timetocargo', express.raw({ type: 'application/json' }), (req, res) => { const timestamp = req.header('x-timetocargo-timestamp'); const signature = req.header('x-timetocargo-signature'); if (!timestamp || !signature) { return res.sendStatus(401); } const expected = 'sha256=' + crypto.createHmac('sha256', secret).update(timestamp).update('.').update(req.body).digest('hex'); const signatureBuffer = Buffer.from(signature); const expectedBuffer = Buffer.from(expected); if (signatureBuffer.length !== expectedBuffer.length || !crypto.timingSafeEqual(signatureBuffer, expectedBuffer)) { return res.sendStatus(401); } const payload = JSON.parse(req.body.toString('utf8')); queueWebhook(payload); return res.sendStatus(200);});app.listen(3000, () => { console.log('Webhook server is running on port 3000');});Python / FastAPI
import hmacimport hashlibimport osfrom fastapi import FastAPI, Request, HTTPExceptionapp = FastAPI()secret = os.environ["TIMETOCARGO_WEBHOOK_SECRET"].encode()def enqueue_webhook(payload: dict) -> None: # Enqueue the event, save it to your database, # or pass it to another service for processing. print("Webhook received from TimeToCargo:", payload)@app.post("/webhooks/timetocargo")async def timetocargo_webhook(request: Request): body = await request.body() timestamp = request.headers.get("x-timetocargo-timestamp") signature = request.headers.get("x-timetocargo-signature") if not timestamp or not signature: raise HTTPException(status_code=401) digest = hmac.new( secret, timestamp.encode() + b"." + body, hashlib.sha256, ).hexdigest() expected = f"sha256={digest}" if not hmac.compare_digest(signature, expected): raise HTTPException(status_code=401) payload = await request.json() enqueue_webhook(payload) return {"ok": True}x-timetocargo-signature*stringHMAC SHA-256 signature of timestamp + '.' + rawBody, prefixed with sha256=. Use the unchanged request body as rawBody.
x-timetocargo-timestamp*stringUnix timestamp used to generate the signature
x-timetocargo-event-id*stringUnique event ID matching payload.id
uuidx-timetocargo-delivery-id*stringUnique delivery attempt ID
uuidapplication/json- body
id*stringuuidtype*stringapi_version*stringcreated_at*stringdate-timeresource*|Technical context for the tracked item. The value is null for account-level events such as tracking.auto_archiving and tracking.test.
data*changes*array<>Delivery failed: the server returned 400 Bad Request. TimeToCargo will not retry it.
{ "id": "cccccccc-dddd-eeee-ffff-aaaaaaaaaaaa", "type": "tracking.eta_update", "api_version": "2026-07-09", "created_at": "2026-07-08T13:11:22.758Z", "resource": { "tracked_item_id": "eeeeeeee-ffff-aaaa-bbbb-cccccccccccc", "track_number": { "type": "container", "value": "MSBU6501445" }, "company": "Mediterranean Shipping Company", "company_scac": "MSCU" }, "data": { "shipment_status": "IN_TRANSIT", "route": { "origin": "Wilmington, US", "pol": "Wilmington, US", "pod": "Long Beach, US", "destination": "Dallas, US" }, "eta": "2026-07-15T00:00:00", "current_position": { "lat": 33.74, "lng": -118.27, "updated_at": "2026-07-08T12:00:00.000Z" } }, "changes": [ { "field": "eta", "old": "2026-07-01T00:00:00", "new": "2026-07-15T00:00:00" } ]}{ "x-timetocargo-signature": "sha256=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "x-timetocargo-timestamp": "1783512000", "x-timetocargo-event-id": "cccccccc-dddd-eeee-ffff-aaaaaaaaaaaa", "x-timetocargo-delivery-id": "dddddddd-eeee-ffff-aaaa-bbbbbbbbbbbb"}