What is a webhook and how does it work?
A webhook is an automated HTTP request that one system sends to another the moment an event occurs. Instead of your application repeatedly asking a service whether anything has changed, the service pushes a notification to a URL you provide as soon as something happens: a payment succeeds, a user signs up, a file finishes uploading.
To see why that matters, consider the alternative. You have two systems that need to talk to each other, and System A has data that System B cares about. With polling, System B asks System A “anything new?” every few seconds. This works, but it is wasteful. Most of the time, the answer is “no, nothing new,” and you have burned an API call for nothing. If you poll too frequently, you waste resources. If you poll too infrequently, you miss time-sensitive updates.
Webhooks flip this model around. Instead of System B constantly asking System A for updates, System A pushes updates to System B the moment something happens. System B provides a URL (the webhook endpoint), and System A sends an HTTP POST request to that URL whenever there is new data.

Webhooks vs. APIs
With a traditional API, communication starts with the client: your application sends a request to another system and waits for a response. Webhooks reverse that direction. The server sends the request, pushing data to you as soon as an event occurs, with nothing on your side needed to trigger it.

The two are complements, not competitors. Most integrations use both: an API for reading and writing data on demand, and webhooks for finding out when that data changes. For a side-by-side comparison, including where webhooks fall short, see webhook vs API.
How webhooks work in practice
When you integrate with a service that supports webhooks, you typically register an endpoint URL with that service. This is your callback URL, sometimes called the webhook URL, the place where you want to receive notifications. When an event occurs (a payment succeeds, a user signs up, a file is uploaded), the service constructs an HTTP request containing information about that event and sends it to your endpoint.
Your server receives this request like any other incoming HTTP request. You parse the payload, validate that it actually came from the expected sender, and then do whatever your application needs to do with that information. Finally, you return a 200 OK response to acknowledge receipt.
The service on the other end typically expects a quick response. If your endpoint takes too long to respond, or returns an error status code, the sender treats the delivery as failed. What happens next depends on the sender, which is what the next section is about.