A roof report webhook receiver that never loses a delivery: retries, duplicates and failures
RoofStruct retries a webhook five times over about 15 hours. How to build a receiver that answers fast, ignores duplicates, handles events out of order and recovers what failed.
A RoofStruct webhook receiver that never loses a report does four things: it verifies the signature, answers 2xx within 10 seconds, deduplicates on webhook-id, and does the real work from a queue. RoofStruct handles the rest. A failed delivery is retried five times over about 15 hours, and anything still undelivered shows as Failed with a Retry button under Recent Deliveries.
What RoofStruct promises, and what it doesn't
| Behaviour | Detail |
|---|---|
| Delivery | At least once. The same event can arrive more than once |
| Order | Not guaranteed. A status change can arrive after the delivery that followed it |
| Timeout | 10 seconds per attempt |
| Success | Any 2xx status |
| Redirects | Not followed; a 3xx counts as a failure |
| Retries | After 1 minute, 5 minutes, 30 minutes, 2 hours and 12 hours |
| Give up | The delivery shows Failed |
| Switch-off | After 10 deliveries in a row fail every retry, the webhook turns off |
Every retry sends the same body with the same webhook-id, and a fresh timestamp and signature.
The shape of a good receiver
POST /roofstruct-webhook
1. verify signature -> 401 if bad
2. seen webhook-id before? -> 200, do nothing
3. store the raw event + id -> durable (database row, queue message)
4. return 204
worker, later:
5. process the event -> CRM update, PDF download, notification
Step 1 is covered in verifying RoofStruct webhook signatures. Steps 1 to 4 take milliseconds. Everything slow happens in step 5, where a failure is yours to retry, not RoofStruct's.
Deduplicate on webhook-id
Keep a table of handled webhook-id values with a unique constraint. Insert first; if the insert conflicts, it's a duplicate, so answer 200 and stop. Keep the IDs for at least a few days, longer than the 15-hour retry window.
On the CRM side, make the work idempotent too: update the job matched by report reference rather than inserting a new record.
Handle events out of order
report.status_changed and report.delivered for the same order can arrive in either order after a retry. Two rules keep state right:
- Never move a report backwards. If your record already says delivered, ignore a later in-progress message.
- Use the event's
created_at(in the envelope) to decide which of two messages is newer, not the order they arrived in.
Or skip state tracking: when any event arrives, fetch the report from the API and store what it says now.
When your endpoint is down
Nothing is lost for the first 15 hours or so; retries cover a restart, a deploy or a bad night. Past that:
- Open Settings › Integrations and look at Recent Deliveries. Each row shows the event, endpoint, attempts and result: Delivered, Retrying or Failed.
- Fix the endpoint. If the webhook switched itself off ("Switched off after repeated failures"), click Turn On first: Send Test only works on a webhook that's on.
- Click Send Test to confirm it answers.
- Click Retry on each Failed delivery.
For anything older than the last 50 deliveries, use the API: list reports with updated_since set to when the outage began, and process what you missed.
Status codes that mean something
- 2xx: delivered. Return it as soon as the event is stored.
- 410 Gone: treated like any other failure, so the delivery is retried. To stop deliveries, use Turn Off or Delete on the webhook in Settings. After 10 deliveries in a row fail every retry, RoofStruct switches the webhook off for you.
- Anything else (4xx, 5xx, timeout, redirect): a failure, retried on the schedule above.
A receiver that returns 400 for an event type it doesn't handle will collect failures and eventually switch itself off. Return 2xx and ignore what you don't need.
Where you trip
- Doing the CRM write before answering. A slow CRM call makes RoofStruct time out and retry, and now you have a duplicate as well.
- Treating
webhook.testas real. Send Test sends awebhook.testevent. Answer 2xx and skip it. - An
httpURL or a trailing-slash redirect. Give the exact finalhttps://URL; redirects count as failures. - Deduplicating on report ID. A report legitimately sends several events. Deduplicate on
webhook-id.
Developer docs: Retries, Verify signatures and Webhooks in the RoofStruct API reference.