Skip to content
KARABO MOTSEPE

Integration Patterns

Designing Reliable Webhook Integrations

By Karabo Motsepe · · 3 min read

Webhooks are one of the most useful patterns in modern integration architecture. Instead of repeatedly asking an API whether something changed, one system can notify another system when an event occurs.

Document signed
      |
      v
Webhook event
      |
      v
Integration endpoint
      |
      v
Update contract

The concept is simple. Production webhook processing is not.

Treat the webhook as a notification

A webhook usually tells you that something happened. It should not always be treated as the complete authoritative business record.

A robust pattern is:

Webhook received
      |
      v
Validate authenticity
      |
      v
Extract resource ID
      |
      v
Call source API
      |
      v
Retrieve authoritative state
      |
      v
Update destination

This is especially useful when webhook payloads are deliberately small.

Authenticate the sender

Never expose a webhook endpoint and blindly trust any POST request it receives.

Common verification methods include HMAC signatures, shared secrets, verification tokens, signed JWTs and mutual TLS.

If the provider signs the request body, verify the signature before processing the event.

Handle verification handshakes

Some platforms verify an endpoint before enabling a webhook.

The provider may send a challenge query parameter or special header that must be echoed back. Treat this as separate behaviour from normal event processing.

Respond quickly

Do not make the sender wait while the integration downloads a document, performs several API calls and updates multiple systems.

A better architecture is:

Webhook
   |
   v
Validate
   |
   v
Persist / queue event
   |
   v
Return 200
   |
   v
Process asynchronously

This reduces timeout-related retries and improves reliability.

Expect duplicates

Webhook senders commonly retry events. The same event may arrive more than once because the sender did not receive your response or because it uses at-least-once delivery.

Use a unique event ID where possible.

if event_id already processed:
    return success without repeating business action

This is idempotent processing.

Do not assume event order

Distributed systems can deliver events out of order. A completion event can arrive before an earlier informational event.

When ordering matters, use the authoritative current state or event timestamps instead of assuming network delivery order equals business order.

Retry intelligently

Transient failures such as timeouts, HTTP 429, 502, 503 and 504 are often retryable.

Validation errors, HTTP 400 and many permission failures require correction rather than blind repetition.

Use backoff rather than hammering a failing service repeatedly.

Preserve correlation information

Capture event ID, external resource ID, internal record ID, event type, timestamp and processing state.

This makes troubleshooting dramatically easier.

Separate receipt from processing

A webhook can be successfully received but fail later during downstream processing.

Track those states separately:

Webhook received: Yes
Signature valid: Yes
Processing status: Failed
Target update: Not completed

Protect against replay attacks

If an attacker captures a legitimate request, can they submit it again?

Possible controls include signature timestamps, expiry windows, nonces and event-ID uniqueness.

Log carefully

Webhook payloads can contain names, email addresses, contract data or financial information.

Prefer operational metadata such as event ID, event type, resource ID and status over indiscriminately logging the entire body.

Have a dead-letter strategy

Some events will continue failing after multiple retries. Do not simply discard them.

Move them into a failed-event state that support staff can review and replay.

Monitor webhook health

Useful metrics include events received, success rate, failure rate, duplicates, average processing time, retries and oldest unprocessed event.

A webhook endpoint can appear healthy while downstream business processing is silently failing.

Final thoughts

A webhook endpoint is not just another HTTP route. It is an event-consumption system.

Reliable webhook architecture assumes messages may arrive more than once, may arrive out of order, downstream systems may fail and attackers may call the endpoint.

Designing for those realities turns a simple webhook into a dependable enterprise integration.

See also: Integration projects