If you're familiar with the detailed metrics Brevo offers for emails, you know how overwhelming it can be to try and make sense of it all. Instead of sifting through a haystack of data to find the information you need, webhooks allow you to receive the right data directly, allowing you to access the important details you need without any hassle.
What is a webhook?
Webhooks can be defined as notifications that are triggered by specific events. They are typically used to facilitate communication between multiple systems. Essentially, webhooks provide a straightforward means of receiving alerts whenever an event happens in another system.
In more technical terms, a webhook is an HTTP callback that allows multiple systems to interconnect and keep actions consistent between them. When an event occurs in a system, a POST request is sent to the given URL in real time. This HTTP POST request contains information related to that specific event, e.g. the time it occurred, the name of the event, and key identifiers.
How do webhooks work in Brevo?
At Brevo, a webhook is a URL that you can integrate into our system to receive real-time updates on events related to the sending of your marketing and transactional emails or the management of your contacts. With webhooks, you have the ability to track specific events that interest you, such as when an email has been opened or a contact has been deleted.
There are multiple types of events you can track. For example, you can receive notifications on the status of your ongoing marketing campaign and know how it's performing in real time. You can also track when your transactional messages are being sent, delivered, or opened by your recipients. Or you can also be notified about changes on your contacts.
What events are available in Brevo?
All the available events that you can track in Brevo are grouped into two categories:
When an email is: | When a contact is: |
|
|
You can find more information about marketing events and their associated data in our API documentation.
When an email is: | |
|
|
You can find more information about transactional events and their associated data in our API documentation.
Create your webhook
For our examples, we will focus on the "Opened" event from the transactional platform. Basically, whenever we send a new transactional email, we will receive a notification via our webhook indicating that the email has successfully hit the recipient's inbox.
-
Go to the Webhooks page:
- For Marketing events, go to Contacts > Settings > Webhooks or Campaigns > Settings > Webhooks.
- For Transactional events, go to Transactional > Settings > Webhooks.
- Click Add a new webhook.
- In the URL field, enter the notification URL where the event data will be pushed whenever the event is triggered.
- In the When the message is or When the contact is fields, select the events that you want to receive notifications for.
- In the Description field, enter a description for the webhook.
- Once you're done, click Save.
- Once you've created your webhook, we recommend you test it. Next to the webhook you have created, click Actions > Send a test or Test. Once the event has been triggered, you will receive a notification on the URL you specified for the webhook.
When creating a webhook from an automation, you will receive a notification every time a contact reaches the Call a webhook step in your automation.
- Go to Automations.
- Click Create an automation.
- Use a pre-defined automation or create a custom one.
- Add an entry point to your automation.
- (Optional) Add the steps that your contacts need to go through before triggering your webhook.
- Add the Call a webhook step to your automation:
- Under the last step of your automation, click +.
- Select the Call a webhook step.
- In the Enter the URL field, enter the notification URL where the event data will be pushed whenever the event is triggered.
- (Optional) To receive information about the contact that triggered the event, enable the I want to send contact properties to the webhook option.
- Click OK.
- (Optional) Add additional steps to your automation.
- Test your automation to make sure you receive the information.
- Click Activate the automation to let your contacts enter the automation.
To create a webhook from the API, you only have to make a simple call to configure the URL of the webhook you want to use. Here is an example of a call:
curl --request POST \ --url https://api.brevo.com/v3/webhooks \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "url": "http://requestb.in/173lyyx1", "description": "Webhook triggered on opened emails", "events": [ "opened" ], "type": "transactional", "domain": "example.com" } ' |
To learn more about creating webhooks from the API, check our API documentation.
Secure your webhook
Once you have created and tested your webhook, we recommend you secure it to ensure it is not accessible to other parties on the web. To secure your webhooks, you need to whitelist the following Brevo IP ranges:
-
1.179.112.0/20
-
First IP address:
1.179.112.1
-
Last IP address:
1.179.127.254
-
First IP address:
🤔 Have a question?
If you have a question, feel free to contact our support team by creating a ticket from your account. If you don't have an account yet, you can contact us here.
If you’re looking for help with a project using Brevo, we can match you with the right certified Brevo expert partner.