Webhook: A mechanism where one system sends an HTTP POST notification to another when a specific event occurs — an "HTTP callback". GitHub uses webhooks to notify CI systems when code is pushed. A webhook is an HTTP request one system sends to another when something happens. A payment provider calls your application when a payment succeeds; GitHub calls your CI server when code is pushed. It is a callback over the internet.
Webhooks replace polling. Instead of asking every minute whether anything changed, you are told the moment it does.
What should you keep in mind with Webhook?
Handling them well takes care. Verify the signature, so you know the request really comes from the provider. Respond quickly and do the actual work in a queued job, because providers time out and retry. Expect duplicates and out-of-order delivery, and make processing idempotent, for example by storing event IDs you have already handled. Log incoming webhooks, so you can replay or investigate them later.
Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.
Use when code runs things at the same time - threads, async/await, queues and workers, parallel requests, cron jobs, webhooks that retry - or when a bug only happens "sometimes" or under load. Covers race conditions, deadlocks, mutexes/locks, atomic operations, idempotency, message queues and backpressure, with Laravel and database examples.
Use when an HTTP request returns an unexpected status code (4xx or 5xx, or a redirect loop), when a user pastes an error like "419 Page Expired", "422 Unprocessable Content", "502 Bad Gateway" or "CORS error", or when debugging API calls between a frontend and a Laravel/PHP or Node backend. Finds the cause from the status code, headers and logs before changing code.