Skip to content
CheckcraftDownload
Practical workflow

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.

Checkcraft ·

Get help with your first test →

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.

API call diagram: method and URL, headers, body, status and response body, logs and database

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

WebhookAPI requestLong polling
Who startsThe serviceYouYou
When data arrivesRight at the eventWhen you askWhen it appears, while the request hangs
What you needA public addressNothingNothing
RiskMissed events when down, repeatsExtra requestsLong connections
Layers of an API call check: status, headers, body, calculations, logs, database

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.json

Save 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

  1. It answers 2xx fast and does heavy work after responding.
  2. It verifies the signature and rejects requests without one.
  3. Resending the same event does not create a second record.
  4. An unknown event type does not crash it.
  5. 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.

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.

Next step

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 run

No 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.

Ask a person

Get help with your first test

Tell us what you want to test or where you got stuck. We can help you start Checkcraft, choose an example and understand your first run. You can ask before downloading.

The Telegram group is public: do not post passwords, tokens or confidential work data. A description of your task is enough to start.

You can also email us support@checkcraft.ru

No account required. We will reply by email. This is a support request, not a newsletter subscription.