Skip to main content
Question

custom webhook events fired in async manner


Forum|alt.badge.img+1

We have a custom webhook being fired when. a user subscribes and also when a user unsubscribes. But, the webhook events are fired in an aync manner and the user activity is not reliable.
eg. user subscribed and then unsubscribed as per below screen print, but the backend system received the unsubscribed event first and then the subscribed event, hence creating data inconsistency in the backend system.
how can we ensure the sequence of webhook events?
 

 

Did this topic or the replies in the thread help you find an answer to your question?

4 replies

Forum|alt.badge.img+1
  • Author
  • Contributor I
  • 0 replies
  • February 17, 2025

is there any way of getiing the webhook_id for the Webhook.


MANSIR2094
Problem Solver IV
Forum|alt.badge.img+15
  • Problem Solver IV
  • 235 replies
  • February 17, 2025

Hello ​@manju , thank you for reaching out...…

Webhook events are asynchronous by nature, so their order isn’t guaranteed. To ensure correct sequencing, implement an event queue with timestamps or unique event IDs. Store events temporarily and process them in the correct order before updating your backend. If your system supports it, use Klaviyo's event_id or timestamp to manage event processing.

 

For retrieving webhook_id, check Klaviyo’s webhook payload or API documentation for available metadata. If implementation is complex, feel free to reach out for tailored guidance

.

 


retention
Partner - Platinum
Forum|alt.badge.img+62
  • 2025 Champion
  • 942 replies
  • February 17, 2025

@manju - I’m obviously not sure about your specific use case.  But perhaps you can get the webhook, then lookup the associated metric event (given profile_ID and metric_ID) for the proper timestamp?  That way you are using the Klaviyo timestamp and not the runtime webhook time and so they should be in the order that Klaviyo knows about those metric events.

 


hani
Problem Solver I
Forum|alt.badge.img
  • 2025 Champion
  • 11 replies
  • February 17, 2025

Webhook events are asynchronous, so you cannot guarantee they will come in the order received.

I would either recommend:

  1. Implementing a system where you hold all the events and then pre-process them to ensure consistency or;
  2. At each event, you can query Klaviyo for the events to get the timestamp, to know wether or not to process the event.