Testing webhooks locally lets you inspect real request shapes, verify signatures, reproduce failed deliveries, and confirm idempotent behavior before an integration reaches production. This guide presents a repeatable local webhook testing workflow: expose a development endpoint, capture payloads safely, replay fixtures, test retries and duplicates, and maintain checkpoints as providers and event schemas change.
Overview
A webhook is an HTTP request sent by one system when an event occurs in another system. Common examples include a completed payment, a new order, a changed subscription, a processed message, or an updated support ticket. Local development becomes difficult because the sender usually cannot reach localhost directly, while the receiving application may need HTTPS, a specific path, authentication headers, or a provider-generated signing secret.
A reliable local workflow has four separate concerns:
- Reachability: route a temporary public URL to your local application through a development tunnel or an equivalent relay.
- Inspection: record the method, path, headers, raw body, response status, and timing of each request.
- Replay: resend a captured request or a sanitized fixture without waiting for the external system to emit the event again.
- Behavior: verify signature checks, validation, retries, duplicate handling, and downstream side effects.
Keep these concerns distinct. A request can be reachable but rejected because its signature was calculated from the wrong body. A payload can be valid but produce duplicate records because the application does not enforce idempotency. Separating the stages makes webhook debugging faster and gives you a useful test record for future changes.
What to track
1. The local endpoint and tunnel
Choose one stable local route for development, such as POST /webhooks/provider. Start your application with request logging enabled, then create a temporary tunnel from the public callback URL to the port where the application listens. Register the complete public URL with the provider, including the path.
Record the following in a small development note or environment-specific configuration:
- Local port and route.
- Public tunnel URL and whether it changes between sessions.
- Whether the provider requires HTTPS.
- Development signing secret or test credential identifier.
- Selected event types and the provider's retry behavior.
Do not place production secrets in a tunnel configuration, a committed fixture, or a shared debugging tool. For a broader review of handling API keys, JWTs, and OAuth credentials, see the secrets management and rotation playbook.
2. The complete request envelope
Payload inspection should capture more than formatted JSON. Save a sanitized record containing:
- HTTP method, URL path, query parameters, and response status.
- All relevant headers, especially event identifiers, timestamps, content type, and signature headers.
- The exact raw request body before parsing or reformatting.
- Receipt time, processing duration, and application result.
- Whether the request was accepted, rejected, retried, or recognized as a duplicate.
The raw body matters because many signature schemes are calculated over the original bytes. Parsing JSON and serializing it again can change whitespace, escaping, or property order. Use a JSON formatter or validator for readability, but retain the original body for verification and replay. The encoding and debugging toolkit is useful when you need to inspect JSON, URL encoding, or token-related values without changing the source data.
3. Fixtures for normal and abnormal events
Create a small fixture set rather than relying on one successful example. At minimum, include:
- A valid event with the smallest realistic payload.
- A valid event containing optional fields and nested objects.
- A malformed or incomplete payload.
- An event with an unknown version or event type.
- A duplicate delivery using the same event identifier.
- A request with an invalid, expired, or missing signature.
Remove customer data, access tokens, payment details, and unnecessary personal information before storing fixtures. Give each fixture a descriptive filename, such as order-created.v1.json or signature-invalid.json, and document the expected HTTP response and side effects.
4. The idempotency record
Track the event identifier used to prevent duplicate processing. Your test should send the same request twice and confirm that the first request performs the intended action while the second produces no additional side effect. Depending on the application, the duplicate may return the same success response or a clearly handled duplicate response; the important result is that an order, email, invoice, or database transition is not performed twice.
Also test two different event identifiers that refer to the same business object. Event-level deduplication alone may not protect against two legitimate but conflicting updates. Your application may need both an event-key check and a domain-level state transition rule.
Cadence and checkpoints
Webhook tests should be revisited whenever an integration changes, but a recurring review helps prevent old fixtures from becoming misleading. Use the following checkpoints as a practical maintenance schedule.
At the start of an integration
- Confirm the local route accepts the required method and content type.
- Expose the route through a development tunnel and update the provider callback URL.
- Send one provider-generated event and save a sanitized request capture.
- Verify the raw-body signature check before adding business logic.
- Replay the request locally and compare the result with the original delivery.
After every event or schema change
Update fixtures for new fields, renamed properties, event versions, and changed signature headers. Run contract checks against the expected payload shape. If the webhook feeds an API or shared service, compare your fixture with the relevant OpenAPI contract and validation workflow using the OpenAPI validation guide.
Monthly or quarterly
Review the capture and replay process on a monthly or quarterly cadence, depending on how often the integration changes. Check that tunnel commands still work for the team's supported environments, the provider dashboard instructions are accurate, and local HTTPS behavior has not changed. Remove stale secrets and redact any fixture that contains data no longer needed for testing.
Run the full regression set at least once during the review: valid delivery, malformed body, invalid signature, duplicate event, delayed retry, unknown event type, and downstream failure. Record the expected status code and whether a retry should occur. This turns a one-time debugging setup into a maintainable developer tool workflow.
How to interpret changes
A failed local webhook test is easier to diagnose when you classify the failure before changing code.
- No request arrives: check the tunnel process, public URL, local port, callback path, and provider delivery history. A successful provider-side enqueue does not necessarily mean your application received the request.
- The route returns a client error: inspect content type, required headers, schema validation, and the exact request path. Compare the captured body with the fixture, not only with a reformatted preview.
- Signature validation fails: verify the correct secret, timestamp tolerance, signature format, encoding, and raw-body handling. Do not disable verification merely to make local testing pass.
- The provider retries: determine whether your endpoint returned an error, timed out, or acknowledged the request too late. Test the retry sequence with the same event identifier.
- Side effects happen twice: inspect the idempotency key, database constraint, transaction boundary, and worker behavior. A request log alone cannot prove that downstream processing is safe.
- Only production fails: compare environment variables, network policy, certificate requirements, clock differences, proxy behavior, and deployment routing. Local success validates application logic but does not reproduce every production condition.
When troubleshooting, preserve one failing capture and one known-good capture. A diff of headers, raw bodies, response timing, and environment configuration often reveals the difference more quickly than repeated manual retries. For related browser-to-API issues, the CORS troubleshooting guide can help separate webhook server behavior from frontend request problems.
When to revisit
Revisit this workflow immediately when you add an event type, change a callback route, rotate a signing secret, upgrade a webhook client, alter schema validation, or modify the code that creates side effects. Repeat the review after changing queues, database transactions, authentication middleware, reverse proxies, or deployment networking.
Use a monthly or quarterly checkpoint even when no visible integration work is planned. Look for missing fixtures, stale provider instructions, expired development credentials, changed event versions, and untested retry paths. A short scheduled review is especially valuable for payment, commerce, messaging, and SaaS integrations where a delivery may occur long after the original feature was implemented.
End each review with a concrete checklist:
- Start the application and local tunnel from a clean environment.
- Send one real test event and save a redacted capture.
- Replay the capture from the command line or your chosen webhook replay tool.
- Run valid, invalid-signature, malformed, retry, and duplicate fixtures.
- Confirm expected response codes and verify that side effects occur once.
- Update fixture names, schema notes, tunnel instructions, and the review date.
For a broader comparison of REST, GraphQL, and webhook testing approaches, see API testing tools compared. The goal is not to keep a tunnel running permanently; it is to maintain a dependable way to receive, inspect, replay, and explain webhook behavior before production delivery makes the problem harder to reproduce.