

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 5
click for more info
Not enough gems
Cost: 6 gems
1: Webhooks
incomplete
2: Webhooks Review
incomplete
3: API Keys
incomplete
This lesson's interactive features are locked, please to keep using them
A webhook is just an event that's sent to your server by an external service. There are just a couple of things to keep in mind when building a webhook handler:
The third-party system will probably retry requests multiple times, so your handler should be idempotent.
Be extra careful to never "acknowledge" a webhook request unless you processed it successfully. By sending a 2XX code, you're telling the third-party system that you processed the request successfully, and they'll stop retrying it.
When you're writing a server, you typically get to define the API. However, when you're integrating a webhook from a service like Stripe, you'll probably need to adhere to their API: they'll tell you what shape the events will be sent in.
Nope! A websocket is a persistent connection between a client and a server. Websockets are typically used for real-time communication, like chat apps. Webhooks are a one-way communication from a third-party service to your server.
We'll talk about websockets in a future course.
Click to hide video