# parcelLab webhooks in production: duplicates, ordering, retries and timeouts

Agent skill: `npx skills add hookdeck/webhook-skills --skill parcellab-webhooks` ([details](https://hookdeck.com/webhooks/parcellab/skill))

This guide covers the problems parcelLab webhooks can cause in production and how to handle each one. What parcelLab sends is on the [parcelLab webhooks](/webhooks/parcellab) overview, the event types are on [parcelLab webhook events](/webhooks/parcellab/events), and how to check the credentials is on [Verify parcelLab webhooks](/webhooks/parcellab/verify).

parcelLab's docs give the retry policy, the payload fields and the events. They give no timeout, ordering guarantee, resend or test send, so much of this guide is about a receiver that doesn't depend on them.

## At a glance

| Problem | What to do | With Event Gateway |
| --- | --- | --- |
| [Timeouts](#timeouts) | Return a 2xx straight away; process in a background job | Accepts the event at once, then queues it for your service |
| [Duplicates](#duplicates) | Deduplicate on `eventid`; guard customer messages per consignment and event | Drops repeats based on the body fields you choose |
| [Ordering](#ordering) | Compare `timestamp` before applying a status; treat `onDelivered` and `onReturn` as final | Limits the delivery rate to your service |
| [Retries](#retries) | Alert within about 7.5 hours; read current status from the Checkpoints API after an outage | Accepts events while your service is down and retries to it |
| [Choosing events](#choosing-events) | Track each consignment separately; ignore events you don't act on | Filters and routes on any field in the body |
| [Testing](#testing) | Post a sample to your handler, then create a test record | Forwards to localhost and replays past requests |
| [Other limits](#other-limits) | Parse optional fields leniently; show customers the localized strings | Checks the Basic credentials on each request |

## parcelLab webhook timeouts and slow handlers {#timeouts}

Return a 2xx as soon as you've checked the credentials and stored the body, then do the work in a background job.

**Why it happens:** parcelLab doesn't state how long it waits for a response, or whether a slow response counts as the error that starts its retries. With no published limit, you can't tell how slow is too slow. Its [Webhooks report](https://docs.parcellab.com/docs/platform/overview/communication-insights/webhooks-report) does show your average response time.

**Fix it in your handler:**

1. Check the credentials, store the body and return `200` before anything else.
2. Update orders and send customer messages in a worker. See [why to process webhooks asynchronously](/webhooks/guides/why-implement-asynchronous-processing-webhooks).
3. Keep calls to other services out of the request path.

**With Event Gateway:** Hookdeck accepts each parcelLab event as it arrives, then queues it and delivers it to your service with its own [retries](/docs/retries). Your handler can take as long as it needs.

## Duplicate parcelLab webhooks {#duplicates}

Deduplicate on `eventid`, then decide per event type whether a repeat should reach the customer. [parcelLab doesn't deduplicate events](https://docs.parcellab.com/docs/developers/v2/data-elements/get-status-updates/webhooks#events), so one parcel can send the same event type several times.

**Why it happens:** Three things repeat a webhook:

* Every carrier scan of a type sends a webhook, so several out-for-delivery scans send several `onOutForDelivery` webhooks.
* `onScheduled` fires on every change to the delivery date or time window.
* After an error, parcelLab sends the event again, up to 15 times.

The docs say `eventid` is unique to a specific event and can be used for deduplication. They don't say whether a retry keeps the same `eventid`, or whether a repeated scan gets a new one, so don't rely on it alone to stop a repeated customer message.

**Fix it in your handler:**

1. Skip any `eventid` you've already processed. See our [guide to webhook idempotency](/webhooks/guides/implement-webhook-idempotency).
2. Before you message a customer, check whether you've already sent that message for this `references.courier`, `references.tracking_number` and event.
3. Compare the delivery date on `onScheduled` with the one you hold. A new date is worth telling the customer about, and the same date isn't.

**With Event Gateway:** [Deduplication](/docs/deduplication) can drop repeats within a window of up to an hour, based on the fields you choose, such as `eventid`, before they reach your service.

## Out-of-order parcelLab webhooks {#ordering}

parcelLab doesn't promise an order. Compare `timestamp` with what you've stored before you apply a status.

**Why it happens:** The docs say nothing about ordering, and each event is its own request. A retried event arrives at least 30 minutes after the first attempt, possibly behind newer ones, so an order could flip from delivered back to out for delivery. `timestamp` is when the event happened, not when the webhook was sent, which makes it the field to compare.

**Fix it in your handler:**

1. Apply an event only if its `timestamp` is newer than the one on your consignment record.
2. Once you've stored `onDelivered` or `onReturn`, ignore earlier statuses. parcelLab marks both as final events.
3. Keep the older event for your audit trail, even if you don't apply it.

**With Event Gateway:** A [max delivery rate](/docs/destinations#set-a-max-delivery-rate) on your destination keeps a burst from reaching your handler all at once, and every request is stored, so you can inspect the sequence you received.

## parcelLab webhook retries and missed events {#retries}

After an error, parcelLab [retries 15 times at 30 minute intervals](https://docs.parcellab.com/docs/developers/v2/data-elements/get-status-updates/webhooks#getting-started), about 7.5 hours, then logs an error and deletes the event from its queue. It documents no resend, so a longer outage can lose events, including final ones such as `onDelivered`.

**Why it happens:** The interval is fixed and the docs don't describe a way to extend it. They also don't say which responses count as an error, so assume that anything other than a 2xx does.

**Fix it in your handler:**

1. Alert on errors from your endpoint well inside the 7.5 hours.
2. Watch success rate and average response time in the [Webhooks report](https://docs.parcellab.com/docs/platform/overview/communication-insights/webhooks-report).
3. After an outage, read the current status of each open parcel with [`GET /v2/checkpoints`](https://docs.parcellab.com/docs/developers/v2/status-updates/checkpoints), using its courier and tracking number.

**With Event Gateway:** Hookdeck accepts each event as parcelLab sends it, stores it and delivers it to your service with [automatic retries](/docs/retries) on a schedule you control. [Issues](/docs/issues) alert you when deliveries fail, and you can replay any stored request after an outage.

## Choosing parcelLab events {#choosing-events}

Track each consignment separately, route on the body's `event` field, and acknowledge the events you don't act on. The docs describe no way to choose which events a webhook sends, so ask parcelLab if you need fewer.

**Why it happens:** Webhooks are sent per consignment rather than per order. For a split order, each tracking gets its own `onDispatch`, even if they ship together, so the first one doesn't mean the whole order has left. `onUpdated` doesn't say which fields changed. In the CloudEvent format the event is in `type`, such as `com.parcellab.tracking.event.ondelivered`, rather than `event`.

**Fix it in your handler:**

1. Key each consignment on `references.courier` and `references.tracking_number`, and find the order through `references.orderNo`.
2. Mark an order shipped only once you've seen every tracking you expect.
3. Return a 2xx for an event you don't handle, so it isn't retried. Treat the [event list](/webhooks/parcellab/events) as a floor, because the schema types `event` as a free string.
4. Read `onUpdated` as a signal to re-read the record, not as a list of changes.

**With Event Gateway:** Hookdeck stores every request with its body, so you can collect real examples. [Filters](/docs/filters) can route on `event` or `references.client`, so each service gets only what it handles.

## Testing parcelLab webhooks {#testing}

Post a sample body to your handler first, then have parcelLab point a webhook at a public URL and create a test record.

**Why it takes two steps:** parcelLab documents no test send and no resend, and its cloud can't reach `localhost`. Its only example bodies are for `onDelivered`, so the other events' `data` keys come from the field table rather than a sample.

**How to test it:**

1. Send your handler a sample body with `curl -u "$USERNAME:$PASSWORD"`, based on the example in [parcelLab's Data Format section](https://docs.parcellab.com/docs/developers/v2/data-elements/get-status-updates/webhooks#data-format).
2. Run `hookdeck listen 3000 parcellab --path /webhooks/parcellab` and give parcelLab the URL it prints.
3. Create a test consignment and watch for `onCreated`, the event for a new record.
4. Log the headers of that first delivery and confirm `Authorization: Basic ...` is on it. parcelLab's docs don't say whether credentials go on the first request or only after a `401` challenge, so ask parcelLab to confirm too.
5. Keep real bodies as fixtures, and remove customer details from them first.

**With Event Gateway:** The [Hookdeck CLI](/docs/cli) forwards requests to localhost, and you can replay stored requests without waiting for another carrier scan.

## Other parcelLab limits {#other-limits}

**Basic credentials aren't a signature.** parcelLab doesn't sign requests. Base64 is an encoding, and the credentials prove only that the sender knows the password, so a modified or replayed request still passes. parcelLab requires HTTPS. Use a long random password, and agree a new one with parcelLab if it might have leaked.

**Three source addresses.** Requests come from `35.156.240.70`, `35.157.215.87` and `35.157.195.174`. Allow them at your firewall as a second layer, alongside the credential check.

**`expected_delivery_date_raw` has no single shape.** The [field table](https://docs.parcellab.com/docs/developers/v2/data-elements/get-status-updates/webhooks#structure-of-data) says a JSON object or an empty object, the format section says the string `"null"`, the JSON Schema says a string, and the examples send an empty string. Accept all of them, and use `expected_delivery_date_formatted` for display. Dates are in the recipient's local time, with no timezone.

**CloudEvent bodies nest further than the prose says.** The docs say the `data` key is dropped and its contents listed directly in the CloudEvent's `data`, while their example has `data.data` beside `data.references` and `data.reporting`. Capture a real delivery before parsing strictly.

**Optional fields stay optional.** `exception_code`, `next_action`, `delivery_information`, `return_reason` and the pickup location fields appear only on their events, and opening hours and coordinates aren't available for every location. `reporting` lead times are `-1` until the scan that ends them has happened.

**`raw_scan` has no common pattern.** It's whatever the carrier sent. For customers, use `delivery_status_locale_short` and `delivery_status_locale_long`, which follow `references.language`.

**Bodies can carry personal data.** `delivery_information` can name the recipient or a neighbour, and `pickup_location_address` and `tracking_link` identify a delivery. Limit who can read your stored events, and how long you keep them.

**With Event Gateway:** Create a source with the parcelLab type, enter the same **Username** and **Password** you gave parcelLab, and give parcelLab the source URL. Hookdeck checks the Basic credentials on each request, and every request is listed with its headers and body. Access token headers and OAuth 2.0 access tokens can't be checked by this source type, so choose HTTP Basic.

[Get started with Hookdeck](https://dashboard.hookdeck.com/signup) for free and handle parcelLab webhooks reliably in minutes.