Skip to content

Order status & track-and-trace

Once an order is in MendriX, you usually want to know when its status changes: accepted, on the way, delivered, and every scan in between. The recommended pattern is webhooks for immediacy + polling as a safety net.

Step 1 — Receive status events (webhooks)

Section titled “Step 1 — Receive status events (webhooks)”

Ask your MendriX administrator to configure the relevant Event–Consequence pairs pointing at your endpoint. Useful events for tracking:

  • order accepted / rejected / finished,
  • order trace (scan status) changed,
  • task status changed / task completed,
  • ETA / late-notification events.

Expose an HTTPS endpoint that returns 2xx quickly, then processes asynchronously:

import express from 'express';
const app = express();
app.use(express.json()); // or express.text() for XML templates
app.post('/webhooks/mendrix', (req, res) => {
// 1) Acknowledge fast so MendriX does not retry.
res.sendStatus(204);
// 2) Extract the order id from the payload (shape is tenant-defined) and
// fetch the authoritative state from the REST API.
const orderId = req.body.orderId ?? req.body.OrderId;
queue.add(() => refreshOrder(orderId));
});
app.listen(8080);

Secure the endpoint with one of the supported outbound auth methods (Basic, Bearer, Digest, OAuth2) — MendriX does not HMAC-sign payloads. See Webhooks.

After a webhook (or on a schedule), read the order and its tasks via REST to get the current status:

Terminal window
# Rank / inspect an order's data via the Order service.
curl "$MENDRIX_BASE/order/orders/ORDER_ID/rank-purchase-options" \
-H "Authorization: Bearer $MENDRIX_ACCESS_TOKEN"

The exact read endpoints and their fields are in the REST API reference; use the Order service to inspect orders and tasks.

Webhooks can be missed (endpoint down longer than the retry window — see the retry policy). Run a periodic sweep as a safety net:

Use an incremental since= sweep on a schedule to catch anything a webhook missed, and reconcile against your local copy.

  1. Webhook → enqueue the order id.
  2. REST read → fetch authoritative status, update your system.
  3. Scheduled since= sweep → safety net for missed deliveries.
  4. Make every write idempotent so duplicate signals are harmless.