Understanding Webhooks

What are webhooks? What are they used for? How can you test webooks? Answers to those questions and more in Mailgun's glossary for webhooks.

Manual Data Transfer is Frustrating

When you're building your business or application, proper data transfer is a hassle without an automated process. Manually checking data logs, engagements, and other basic information for new data across different applications takes time out of the day that could be spent creating a new tool or feature for your application.

Instead, it's much easier to create a series of webhooks that accomplish this data transfer for you. Just create a few new webhooks for your application, and you're all set. No matter your use case, webhooks are a possible solution any business should consider to help improve their overall data flow.

Manage email bounces.
A graphic illustration showing analytics on a computer screen.

What is a Webhook?

A webhook is an automated message that is sent to an outside app when an event occurs. To be more technical, a webhook is an HTTP callback or an HTTP POST request caused by an event notification. This HTTP request is then registered as a webhook URL and used to store data in a JSON format. At that point, you can direct the webhook to point the information however you like.

For example, in order for Mailgun to create a POST of your event notifications, you'd need to provide a callback URL within the webhooks tab of your control panel. The specific events in the email space most senders like to track include opens, clicks, unsubscribe, spam complaints, failures, and deliveries. Regardless of the type of event, that data is typically passed to a frontend analytics or marketing provider to make the data more digestible for other teams. Webhooks facilitate that data transfer without someone having to go in and pull the data manually.

Testing Webhooks

While it is tempting to set up a webhook right away and start reaping the benefits, it's important to remember to test ahead of time so you don't run into issues later on. Many webhook solutions and providers have some form of temporary URL solution to help you test and debug your webhooks. At Mailgun, we provide our own Mailgun Postbin for senders to generate new URLs, but other solutions like requestbin are also an option available to you.

Illustration showing API code for email sending.
An upward trend on a screen.

Getting Started with Webhooks

If this is your first introduction to webhooks, it's worth getting your bearings a little bit more before ramping up. Github has an excellent overview that goes over the general set up and implementation of webhooks - and we highly recommend giving it a read. However, different applications will have distinct rundowns of how to set up webhooks with their specific instance, so it's good to check their documentation on how to get started.

While you can find some webhook implementation information in our documentation, our developer community has created great walkthroughs to help you get started with Mailgun's Webhooks if you need a little extra guidance.