Webhook: what it is, how it works and how to test it
Checkcraft is a desktop app for checking APIs and logs without code, with a free edition. Download, no sign-up →
A webhook is when a service itself sends an HTTP request to your address as soon as an event happens: a payment passed, an order was created, a message arrived. Instead of polling the API you get notified. Below is how it works, how to test receiving it and what usually breaks.
How a webhook works
You register an address, usually HTTPS, in the service. On an event the service sends a POST with a JSON body to it and waits for a 2xx. With no answer or an error most services retry several times with pauses. So the handler must answer fast and handle repeats calmly.
How to test receiving
First see exactly what the service sends: temporarily point it at a request bin or a local server and trigger the event. Then replay the same request with curl against your handler and check the response, the database record and behavior when the same event is resent.

Signature and security
Anyone may find a webhook address, so services sign requests with a secret: a header carries the body signature. The handler must compute it and reject the request on mismatch. Without that check anyone can send a fake payment event.
Webhook, API and long polling
| Webhook | API request | Long polling | |
|---|---|---|---|
| Who starts | The service | You | You |
| When data arrives | Right at the event | When you ask | When it appears, while the request hangs |
| What you need | A public address | Nothing | Nothing |
| Risk | Missed events when down, repeats | Extra requests | Long connections |

Replaying a webhook
# воспроизвести webhook на свой обработчик
curl -X POST http://localhost:8080/webhooks/payments \
-H "Content-Type: application/json" \
-H "X-Signature: sha256=..." \
--data @payment-succeeded.json
# повторная отправка того же события: ответ 200, второй записи в базе нет
curl -X POST http://localhost:8080/webhooks/payments \
-H "Content-Type: application/json" \
--data @payment-succeeded.jsonSave a real event body to a file and run the handler on it: you can test receiving without waiting for a real payment or order.
What to check in the handler
- It answers 2xx fast and does heavy work after responding.
- It verifies the signature and rejects requests without one.
- Resending the same event does not create a second record.
- An unknown event type does not crash it.
- A handler error is logged with the event id.
For local development, mock the service that sends events: local API mock.
More on curl
Section overview and all guides: curl command cheat sheet: flags and examples for APIs.
- curl GET request: parameters, response headers and status code
- cURL examples: GET and POST requests with JSON on Linux, Windows and PowerShell
- Headers in curl: Content-Type application/json, Accept and multiple -H
- curl with authorization: Bearer token, Basic, API key and headers
- curl errors: codes 6, 7, 22, 28, 35, 60 and how to fix them
Frequently asked questions
What is a webhook?
An HTTP request a service sends to your address on an event instead of you polling its API.
Webhook vs long polling?
A webhook posts to your public address; long polling keeps your request open until data appears.
How do I test a webhook?
Capture what the service sends, replay it with curl against your handler and check the response, the record and a resend.
Repeat this on your own API
Checkcraft is a desktop app that saves API response checks without code and shows what did not match. Start with a sample, then use your own sanitized data. Free runs on Windows and Linux with no time limit.
Download FreeDownload and first runNo sign-up or email needed, the archive is ready in a couple of minutes. See the edition limits.
Start with the linked example and compare its result with your own test requirement.