Sendcloud webhooks in production: duplicates, ordering, retries and timeouts
This guide covers the problems Sendcloud webhooks can cause in production and how to handle each one. What Sendcloud sends is on the Sendcloud webhooks overview, the event types are on Sendcloud webhook events, and how to check the signature is on Verify Sendcloud webhooks.
It's about webhooks set on an integration. Sendcloud's beta Event Subscriptions API is a separate route, with its own events, authentication and retries.
At a glance
| Problem | What to do | With Event Gateway |
|---|---|---|
| Timeouts | Return a 2xx within 10 seconds; process in a background job | Accepts the event at once, then queues it for your service |
| Duplicates | Build a key from action, the object's ID and timestamp | Drops repeats based on the body fields you choose |
| Ordering | Compare timestamp with the latest you've stored per parcel | Limits the delivery rate to your service |
| Retries | Use a 5xx for temporary problems; reconcile from the API after an outage | Accepts events while your service is down and retries to it |
| Choosing events | Configure each integration; branch on action, then parcel.status.id | Filters and routes on any field in the body |
| Testing | Use Test API webhook, then record a real parcel update | Forwards to localhost and replays past requests |
| Other limits | Allow for mixed date formats and unsigned timestamps | Verifies the signature on each request |
Sendcloud webhook timeouts and slow handlers
Your endpoint must return a 2xx within 10 seconds. Verify the signature, store the body and respond, then do the rest in a background job.
Why it happens: Parcel updates tend to start slow work, such as customer emails and order system calls. A request that passes 10 seconds counts as failed and is sent again, even if your handler finishes the work afterwards.
Fix it in your handler:
- Verify the signature, store the body and return
200before anything else. - Update orders and send customer messages in a worker. See why to process webhooks asynchronously.
- Keep calls to other services out of the request path.
With Event Gateway: Hookdeck accepts each Sendcloud event as it arrives, then queues it and delivers it to your service with its own retries. Your handler can take as long as it needs.
Duplicate Sendcloud webhooks
Make your handler idempotent with a key you build yourself, because Sendcloud's payload schemas have no event or delivery ID.
Why it happens: Sendcloud retries a request that timed out, so a slow handler can receive an update it has already processed. The docs don't say whether a retry is byte for byte the same, but they describe timestamp on a parcel update as the time the status changed, which makes it a useful part of the key.
Fix it in your handler:
- For
parcel_status_changed, key onaction,parcel.id,parcel.status.idandtimestamp. - For
return_created, key onactionanddata.id. - For the integration events, key on
action,integration.idandtimestamp. - Skip any key you've already processed. See our guide to webhook idempotency.
With Event Gateway: Deduplication can drop repeats within a window of up to an hour, based on the fields you choose, before they reach your service.
Out-of-order Sendcloud webhooks
Webhooks can arrive out of order, so compare each payload's timestamp with the latest you've stored for that parcel before you apply it.
Why it happens: Sendcloud gives the example of an application that was unreachable for a while. Retries for an older status can then land after a newer status has been delivered.
Fix it in your handler:
- Store the latest
timestampper parcel and ignore any update older than it. - Compare
timestamponly with othertimestampvalues. The docs call it a Unix timestamp without giving the unit, and their one example,1525271885993on the integration events, is in milliseconds. Check the scale on a real delivery before you compare it with anything else. - If an update matters to a customer and you're unsure, read the parcel from Sendcloud's API first.
carrier_ is the time of the change in the carrier's system, and it can be null, so don't order on it.
With Event Gateway: 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.
Sendcloud webhook retries and missed updates
Sendcloud makes up to 10 attempts over about an hour and a half, and only for some failures. A 400, 401, 404 or 422 stops delivery right away.
Why it happens: The first retry comes within 5 minutes, and the wait between later retries grows to roughly half an hour. Sendcloud sorts failures this way:
| Your endpoint | What Sendcloud does |
|---|---|
| Times out or can't be reached | Retries |
Returns 406, 408, 409 or 429 | Retries |
| Returns a 5xx | Retries |
| Returns any other 4xx | Stops, with no retry |
That means a broken route or a wrong signing key can lose updates on the first attempt. Every failed attempt is logged in the connection issue log. The docs describe no way to resend a failed delivery.
Fix it in your handler:
- Return a 5xx, such as
503, for anything temporary, like a database that's down. - Keep other 4xx responses for requests you never want again, and alert on them.
- Check the connection issue log after any incident.
- After an outage or a run of 4xx responses, read the affected parcels from Sendcloud's API and update your records.
With Event Gateway: Hookdeck accepts each event as Sendcloud sends it, stores it and delivers it to your service with automatic retries on a schedule you control. Issues alert you when deliveries fail, and you can replay any stored request after an outage.
Choosing Sendcloud events
The docs describe no way to choose events: enable the webhook on an integration and branch on action. parcel_status_changed is the event most integrations are built around.
Why it happens: Webhooks are scoped to the integration they're configured on, which leaves some gaps:
- Parcels created through another integration, such as a shop plugin, don't reach this integration's webhook.
- Return parcels only send updates if the outgoing shipment was created through the API integration.
return_createdfires for returns created through the API or the Return Portal, but not for returns created manually with the Return Form.
Fix it in your handler:
- Configure a webhook on every integration whose parcels you track, with a separate path for each so you know which key to use.
- Branch on
action, then mapparcel.status.idto your own states instead of parsingparcel.status.message. - Keep your own copy of the status IDs. The v3 parcel statuses endpoint lists a
codeand amessagewith no ID, and only the legacy v2 endpoint lists IDs. - Use
parcel.is_returnto handle return parcels separately, and find another source for returns made outside these routes.
With Event Gateway: Each integration can point at its own Hookdeck source with its own key, and all of them can feed one destination. Filters can route on action or parcel.status.id, so each service gets only what it handles.
Testing Sendcloud webhooks
Click Test API webhook in the integration's settings to send a test request, then create a parcel through the integration to see a real update.
Why you need both: The docs don't show what the test request contains. They publish schemas with field examples, but no complete body for any event, so your first real delivery is the best reference you'll have.
In your handler:
- Check your signature code against the docs' test vector, which is on Verify Sendcloud webhooks.
- Return a 2xx for an
actionyou don't recognise, so the test request doesn't look like a failure. - Record the body of your first
parcel_status_changedand build your fixtures from it.
With Event Gateway: The Hookdeck CLI forwards requests to localhost, and you can replay stored requests without waiting for another status change.
Other Sendcloud limits
A few details of the signature and payloads can still trip a receiver that handles everything above.
The timestamp isn't signed. The signature covers only the body. timestamp is inside the body, but Sendcloud documents no replay window, so a replayed request verifies. Your idempotency key is what stops it having an effect.
Date formats differ within a parcel. date_created, date_updated and date_announced use DD-MM-YYYY HH:MM:SS in UTC, while delivery_dates uses ISO 8601. Don't pass them all to one parser.
carrier.id is reserved. It's always null, so identify the carrier with carrier.code.
Redirects are followed. Sendcloud sends the same request with the same body to the new URL, so a redirect won't break your signature check. Update the Webhook url anyway, so you don't depend on it.
No published source IPs. The webhook docs list no addresses to allow at a firewall, so rely on the signature.
With Event Gateway: Create a source with the Sendcloud type, enter your integration's key, and use the source URL as the Webhook url. Hookdeck verifies the signature on each request, and every request is listed with its headers and body.
Get started with Hookdeck for free and handle Sendcloud webhooks reliably in minutes.
Keep a bad deploy from losing Sendcloud parcel updates.
Sendcloud stops at the first 401 or 404 and gives up on an outage after about 90 minutes. Event Gateway verifies the signature, accepts each update and queues it for your service, so you can retry or replay it once your service is healthy.