Webhook
A mechanism where a service sends an HTTP request to your system when an event occurs. The opposite of API, where you make the request.
API vs Webhook
| API | Webhook | |
|---|---|---|
| Who initiates | You | Service |
| When | On request | Upon event |
| Example | "Give me a list of emails" | "A new email has arrived" |
Why in AI projects
- Telegram bots: new messages come through webhook;
- CI/CD: GitHub sends webhook upon push — triggers deployment;
- payments and forms: notifications about events.
How it works
flowchart LR
A[Service] -->|event| B[Your webhook URL]
B --> C[Handler]
C --> D[Response]
You register a URL, and the service calls it with a POST request containing event data.