Short answer
A webhook is a way for one system to automatically tell another that something has happened — for example, a payment has been received or an order created. Instead of your system asking every now and then "anything new?", the other system sends a message to a specified address by itself.
Example
A customer pays in the online store. The payment provider immediately sends a webhook to your system: “order 123 paid”. Your system updates the status, reserves the goods and sends the customer a confirmation — with no delay.
Webhook or API requests
- API request — your system asks the other system itself.
- Webhook — the other system notifies your system by itself.
They’re often used together: the webhook announces the event, and the API is used to fetch the full data.
What to keep in mind
- Security — check that the webhook really comes from the right source (a signature or a secret key).
- Duplicates — the same event may arrive twice, so processing must be safe against duplicates.
- Errors — if your system is unavailable, there must be a way to receive the event later.
Webhooks are very common in payment systems — see how to add online payments.