In our recent September release we announced the release of core API endpoints for our new webhooks API feature. All of us on the API team are really excited to announce the release of our first set of webhooks topics and full API endpoints.
But some of you may be asking, “What are webhooks and why should we be excited about them?” Well, those are great questions!
Webhooks are an API framework that has been around for quite a few years now. To use Phil Leggetter’s description from ProgrammableWeb, webhooks are “an HTTP POST callback request sent to the URL of a user’s choice in response to some event occurring. They offer effective server to server communication without long running connections.”
Webhooks allow apps to receive relevant real-time events that are happening with connected clients. They are easily consumed because all you need is an HTTP endpoint that can handle a POST request. Additionally, they’re easily integrated with your existing architecture — all you need is the web server your web app is already using.
Webhooks change the direction of the API conversation
At their core, webhooks simply change the direction of the API conversation. A typical API conversation starts with the consumer calling a REST API, asking a question such as “Can you give me all of my contacts?” or “Have any contacts been created in the past hour?”
What if you are really interested in the question “Have any contacts been created in the past 5 minutes?” Without using webhooks, you could only answer that question by making an API call 12 times an hour. If it turns out that contacts are only being created once or twice a day, your app is making lots of low value API calls.
The WebHooks framework instead takes the Event Listener model we all know and love from desktop and browser development and creates a similar model for REST APIs. With WebHooks, answering the question “Have any contacts been created in the past 5 minutes?” looks like this:
- Look through the available WebHook topics for the one that will give you what you need , such as “contact.created”
- Subscribe to that topic by giving it a callback_url of the webhook handler hosted on your server
- Wait until the API server tells you something happened asynchronously when it calls your callback_url
- Act on the notification by retrieving the new contacts using the existing REST API endpoints.
- Profit from all of the just in time webhooks notifications you’re getting instead of polling for events that may not have happened!
Ok, so the last one is a little over the top, but you get the idea. For a company with the amount of API traffic Constant Contact has, this framework could end up saving us millions of low value API calls each month. I am always excited to find new ways to save our developers time, make their jobs easier, and make their integrations better! Webhooks is a great addition to our API set to help developers do this.
This month, we released Billing API webhooks. These API endpoints notify a partner when one of their customers has a billing tier increase or decrease, which would mean that their next bill is going to be different. Our goal is to look at all of the other asynchronous events that Constant Contact generates, from contacts to tracking data, and develop a full set of webhook topics that developers can use to build out amazing web and mobile applications.
Do you have an idea for Webhooks you’d like to see implemented? Share it in the comments section below!