Why your webhook handler must be idempotent
Due to network conditions, Leafy Energy may occasionally deliver the same event more than once. Your handler must therefore be idempotent: processing an event twice must not trigger the action twice.
Using the event ID
- Each event has a unique
id. - Store processed event IDs in a datastore (for example Redis or a database).
- Ignore events whose ID has already been processed.
Example strategy
- Receive webhook.
- Check whether
event.idexists in a “processed-events” table. - If not, handle the event and mark it as processed.
In demo sessions you can deliberately send duplicates to demonstrate how to build robust integrations.
Comments
0 comments
Please sign in to leave a comment.