What is a Webhook? [Crash Course on Email Webhooks]
What’s a webhook? Great question! Webhooks have grown in popularity over recent years. More and more services are offering developers the ability to configure webhooks to notify applications when events occur in real-time.
There are many benefits to using webhooks. That’s why we’re going to give you a short crash course on webhooks. You’ll learn:
- What’s a webhook
- What’s an example of a webhook
- Why use a webhook
- Using webhooks to track email delivery notifications
If you already know all about webhooks, then click here for some webhook code samples.
Otherwise, let’s continue with webhooks explained below:
What’s a webhook?
As more of the web has become event driven, webhooks have grown in popularity.
In fact, webhooks have become so popular that there’s a chance you might have seen webhooks mentioned in your application’s settings at one point or another. For example, notice how Stripe, (a popular payment processor) gives developers access to webhooks through their dashboard.
So what is a webhook?
A webhook (sometimes referred to as a Reverse API, HTTP push API or web callback) is a way for different applications to communicate with each other in real-time. A webhook allows one application to deliver data to another application, without having to continuously poll a service to discover what has recently happened. It’s basically a way to be notified when an event occured.
In the example above, the developer provides a “callback URI” to the service offering the webhook. When an event occurs, the webhook provider makes an HTTP post request to your Listener/URI. You can then use the data however you want in your application. All you need to do is listen for the HTTP request to the callback URI.
What are some webhook examples?
Let’s say you have a messaging app that allows students to communicate with teachers. On top of being able to send messages through the web app, you want users to be able to read and respond to messages directly through email, making communication as easy as sending a text message. In addition to communicating through email, you also want to show “read receipts” next to each message to let users know that the message has been read.
To make it possible to show “read receipts” within your messaging app, you will use an event webhook to post JSON data to a URL that you specify anytime a user opens or clicks a link in your email. This notifies your app with a message saying, “Hey Sally just read an email from Jane”, then your application will run the appropriate processes to display the read receipt.
The above is just one basic example of using a webhook. Some additional webhook uses include:
- Stripe (or any other payment processor) telling your accounting app when your clients pay you
- Plivo (text messaging platform) routing text messages or calls to a phone number
- Shopify updating or notifying you about new orders via Slack
When it comes to email, webhooks are great for helping you track delivery and engagement metrics like opens, clicks, email delivery failed notifications, and successful delivery of emails.
Why use email webhooks?
A webhook is the ideal choice for when you need to initiate a specific process in your application based on an event that occurred in another application. And webhooks are flexible enough to allow developers to receive data directly, so they can report, analyze and respond to it, however they want.
Webhook notifications are also more efficient than API calls. For example, when using an API your application has to poll the other app for data every couple of seconds. This becomes very inefficient. A webhook on the other hand, instantly notifies your app that an event has occurred, without having to constantly check-in on the app.
Finally, webhooks are very easy to use since they are based on HTTP POST requests. Webhook scripts can be written in just about any scripting language developers prefer, including C#, PHP, Python, Node.js, Java, Golang, and more.
Using webhooks to track email delivery notifications
If you’ve built an application that delivers any type of marketing or transactional email, then it’s critical that you track each email message.
Just because your application sent a message, doesn’t mean that the email was actually delivered to the intended recipient. There are a number of potential factors that could lead to the failed delivery of your message – ranging from your sending IP being blacklisted to a poor sender reputation.
And even if your email does reach the intended recipient, there are still many things that can go wrong on the receiving mail server’s side. For example, the receiving mailbox could automatically filter your message to spam or the recipient could complain about your message. This is why it’s important to use an email delivery service that constantly monitors your mail stream.
By tracking each message sent from your application, you can quickly respond to issues, so you can maintain your sender reputation and deliverability rates.
So, how do you track messages sent from your application?
The answer — webhooks.
Email webhooks are an extremely flexible way for developers to monitor the health of their mail stream in real time. By connecting an application to an email delivery platform like SocketLabs, you can use webhooks to instantly analyze deliverability data related to failed messages, successful messages, and bounces. You can even use webhooks to track email feedback loops, so you know when a recipient hits the spam or junk button in their inbox.
To get started with webhooks, use an Email Tracking API (known as the email Notification API at SocketLabs) to receive real-time delivery status and engagement notifications with webhooks. This API makes it easy to receive instant notification of email delivery events, written in any language, without the need to write traditional plugins.
To learn more about our email Notification API visit our Developer Hub.
For webhook examples, webhook best practices, and to see how to implement webhooks, visit our email Notification API documentation.