Workflow & Automation Utilities

Test a Webhook Without a Server

How to test a webhook without a server: create a temporary URL, watch requests arrive, read headers, body, JSON and form views, and know the limits of the test URL.

PerkTonic Team5 min read
Cover of the guide "Test a Webhook Without a Server"

Before you write the endpoint that receives a webhook, you need to know exactly what the service sends: the method, the headers and the body. A webhook test URL generator gives you a temporary address that records every request it receives. In the Webhook Test URL (Request Catcher), you create a URL, give it to the service and look at the requests as they arrive, with no server of your own.

Create URL and paste it into the service

  1. Open the Webhook Test URL (Request Catcher).
  2. Press Create URL.
  3. Copy the URL.
  4. Paste it into the webhook settings of the service, for example the payment provider or the form tool.
  5. Trigger an event in the service, such as a test payment or a form submission.

You can have up to 5 URLs at a time, for example one for each service or one for each environment, so that the requests are not mixed. Before you press Create URL, the page shows an example URL with three example requests, so that you can look at the tool first.

The URL works for any method. The service sends a POST in most cases, and the tool records other methods as well. Do not use real secrets or personal data in tests. Anyone who knows the URL can see the requests that it received, so treat it like a temporary secret and use test data from the sandbox of the service.

Watch requests arrive

Keep the page open while the service sends. New requests appear in the list at once. The page is updated live, and if the live connection is not available, for example behind a restrictive network, it falls back to checking for new requests at short intervals.

Each request in the list shows the time, the method and a summary of the content. Click one to open the details.

Many services have a button that sends a test event. Use it, then compare it with a real event: the payload of a test is sometimes simpler than the one of a live event, and your endpoint must handle the real one.

Read headers, body and JSON view

The details of a request show the query parameters, the headers and the body, and a button Copy as cURL builds the matching curl command.

Headers: the metadata of the request. Look for the content type, which says how the body is written, and for any signature header. Services that sign their webhooks send a header with a signature that your endpoint has to verify, and you need to see its exact name and format. The list of headers shows them as sent. The meaning of methods and headers is explained in the MDN pages on HTTP request methods and HTTP headers.

Headers list of a captured request in the Webhook Test URL tool with the signature header marked
The headers list shows the signature header as the service sent it.

Body: the content of the request, in the raw form. This is the text that your endpoint will receive. Keep it unchanged for signature checks, because a signature is calculated over the raw body, and a formatted copy will not match.

The body has buttons for its views: JSON, Raw and Hex for a JSON body, and Form, Raw and Hex for a form body. The first view is chosen to fit the content type: a JSON body is shown as a structure that you can read, and a form body is shown as fields.

Webhook Test URL showing a POST with an order.paid JSON body in the JSON view
The POST with the order.paid event is shown in the JSON view.

In the example, the service sends a POST with a JSON body that says the order was paid: a type of order.paid and a data object with the order ID A-10442. In the JSON view, you see the keys and values, and you can plan the code that reads data.order_id.

A form post works differently. When a form tool sends name=Ada+Lovelace&email=ada%40example.com, the tool decodes the values in the form view: the name is Ada Lovelace, and the email is ada@example.com. Without that, you would have to decode the plus sign and the percent sequence yourself.

Form view of a captured request in the Webhook Test URL tool with the decoded name and email
A form post is shown as decoded fields in the form view.

For a long or deeply nested JSON body, the Webhook Payload Formatter formats it. For the fields of a payload of a specific provider, read the documentation of that provider next to the captured request.

How long the URL lives

A test URL is temporary. It lives for 60 minutes. You can extend it, and you can do that 3 times. When the time is up, the URL stops working, and requests that are sent to it afterwards are not recorded.

Plan your test for that time. If a service retries a failed webhook with a long delay, the retry can arrive after the URL has expired. To test retries, open Custom response under the requests and set the status code, the content type and the body that the URL answers with, for example a 503.

Copy what you need before the URL expires: the headers that you want to keep, and a sample of each body.

Limits

The tool keeps 50 requests for a URL, so a service that sends many events fills it quickly, and older ones drop out. It accepts up to 60 requests per minute, which is enough for tests and not meant for load. A request body is cut at 256 KB.

The tool records requests. It is not a place to run your logic. When you know what the service sends, write your endpoint, and use a captured request to test it. To send a captured request to your local server, press Copy as cURL and run the command in your terminal with your local address, or use Replay to a URL, which works for GET and HEAD requests. The cURL to Python Converter turns a cURL command into code.

Try it

Open the Webhook Test URL (Request Catcher), press Create URL and paste the address into the webhook settings of your service. Trigger an event, and read the headers, the body and the JSON or form view of the request that arrives.

Was this guide helpful?
Share

Comments