# Webhook

> A way for one service to call your app the moment something happens.

- Level: Intermediate
- Topics: Software
- URL: https://tidbit.legios.com.ar/webhook/
- In Spanish: [Webhook](https://tidbit.legios.com.ar/es/webhook/)

A **webhook** is a message one system sends to another automatically when an event happens. You give a service a URL of yours, and when the event occurs (a payment succeeds, someone pushes code to GitHub, a form is submitted) the service makes an HTTP `POST` request to that URL with the details, usually as JSON.

It is an API call in the opposite direction. With a normal API your app asks: "any new payments?" To find out quickly it would have to ask every few seconds, which is called **polling** and wastes effort when the answer is almost always "no". With a webhook your app says once: "call me here when it happens", and then just listens.

Since anyone on the internet could send a request to that URL, well-designed webhooks are **signed**: the sender attaches a code computed with a shared secret, and your app checks it before trusting the message. Senders also retry when your app does not answer, so the same event may arrive twice, and good receivers are prepared to ignore duplicates. Tools like Zapier are built largely on webhooks, connecting one service's events to another's actions.

## An analogy

Polling is calling the restaurant every five minutes to ask if your table is ready. A webhook is leaving your number so they text you when it is.

## Keep in mind

- The service calls you when an event happens; you do not have to ask.
- It is just an HTTP POST to a URL you registered.
- Check the signature, because anyone can send requests to a public URL.
- Events can arrive twice or late, so handle duplicates.

## Go deeper

- [About webhooks (GitHub docs)](https://docs.github.com/en/webhooks/about-webhooks)
- [Webhook on Wikipedia](https://en.wikipedia.org/wiki/Webhook)

## Related terms

- [URL](https://tidbit.legios.com.ar/url/): The full address of something on the web: protocol, site and path.
- [GitHub](https://tidbit.legios.com.ar/github/): A website where teams store their code with Git and work on it together.
- [HTTP](https://tidbit.legios.com.ar/http/): The request-and-response language browsers and websites speak.
- [JSON](https://tidbit.legios.com.ar/json/): The plain-text format programs use to hand each other structured data.
- [API](https://tidbit.legios.com.ar/api/): The menu of things one program lets another program ask for.
- [Internet](https://tidbit.legios.com.ar/internet/): A worldwide network of networks that lets any connected device reach any other.
