Chapter 9. Webhooks
Before talking about webhooks, we need to explain the callback concept. In real life, you might experience a callback when calling a friend who is currently busy, and they promise to call you back. For APIs, a callback is an application’s interface (e.g., an HTTP endpoint) that is used to receive messages (calls).
The communication flow in callback APIs goes like this: a destination service that wishes to be notified registers its callback within the source service responsible for producing events. In callback APIs, every message sent by the source service is expected to be acknowledged by the destination service through a response.
Figure 9-1 shows the architecture of callback APIs.
Figure 9-1. Callback architecture
A webhook is an HTTP request triggered by an event in the source service and sent to a callback URL defined in the destination service. The webhook payload data contains information about the event. The destination service then processes the data and responds to the event’s occurrence.
In this chapter, you’ll be introduced to webhooks, their origins, classification, and trade-offs. Completing this chapter will help you determine whether webhooks are the right choice for your use case. Besides conceptual knowledge, you’ll gain practical skills to implement, secure, and document webhook APIs.
What Are Webhooks?
Webhooks go by many names, such as ...