Webhooks are used to immediately notify your integration of events that take place in the Lean ecosystem. They are especially useful for events that take place on your front end through the Lean SDK or events that take place asynchronously, for example updating you about the status of a payment.
Webhooks can be handled by your integration in 2 ways:
- Synchronously:
- Your backend receives Lean webhook call
- Processes the request on their side
- Marks the webhook ID as “executed” so you don’t execute the code twice
- And finally returns the response with a 200 OK back to the Lean platform.
- Asynchronously (strongly recommended):
- Your backend receives Lean webhook call
- Acknowledges it by returning 200 OK to the Lean platform
- Then executes code that deals with the webhook content
- And finally marks the webhook ID as “executed” so they don’t execute the code twice.
To make sure that Lean webhooks are captured successfully by your backend, if the Lean platform doesn’t receive a 200 OK response within 10 seconds, we will try to resend the webhook in increasing intervals. See here for the detailed mechanism: https://docs.leantech.me/docs/webhooks#webhook-retry-policy
Therefore, we strongly advise you to implement all webhooks “ASYNCHRONOUSLY”, to avoid processing the same request several times due to delay issues in returning the 200 OK in the right time.