Using webhooks for modifications in a list
With a webhook, Laposta sends a message to your server as soon as something changes in a list. This allows you to keep your own database in sync without having to continuously query Laposta for updates.
When do you use a webhook?
You use a webhook for modifications that take place in Laposta: someone signs up via a subscribe form, updates their details in the preference centre, or unsubscribes via the unsubscribe link. For modifications that originate from your own system, take a look at synchronising subscribers.
You can configure a webhook for three events:
Configuring a webhook
Build a URL that can receive messages
Create an address on your own server that accepts a POST request with JSON. Respond quickly with a 200 status code and process the message in the background afterwards.
Things to keep in mind
- Process the message in the background, after you have responded to the request. If it takes too long on your end, the call will time out and you will not be sure whether you have received everything.
- Expect duplicate messages. When in doubt, Laposta will resend a message. Make sure your system can process the same message twice without creating a duplicate subscriber, for example.
- Temporarily disable a webhook instead of deleting it. If you are going to perform maintenance on your server, set
blockedtotrueusing Edit webhook. This preserves the registration and the secret. - Modifications via the API also trigger the webhook. If you update a subscriber yourself via the API, the
modifiedwebhook will also fire. Take this into account in your own code, otherwise you will immediately send the same modification straight back to Laposta.