# Testing Webhooks

## Overview

To test webhooks, set up a listener, create a webhook subscription, and use our API to generate the webhook, which can be viewed by the listener. You can quickly get started by using a webhook listener service like webhook.site.

This guide explains how to effectively test your webhook setup, including using third-party tools and Peach's built-in testing features.

## Methods for Testing Webhooks

### 1. Using Third-Party Webhook Testing Services

Third-party webhook testing services are useful For initial setup and debugging. These services provide temporary endpoints so you can inspect incoming webhook payloads without needing to set up your own server.

Common testing options include:

- [Webhook.site](https://webhook.site/)
- [RequestBin](https://requestbin.com/)
- [Beeceptor](https://beeceptor.com/)


**Steps**

1. Visit one of the webhook testing services mentioned above.
2. Copy the unique URL provided by the service.
3. Use this URL as your webhook endpoint when creating or updating a webhook subscription in Peach.
4. Trigger events in your Peach sandbox environment.
5. Observe the incoming webhook payloads on the testing service's interface.


This method allows you to quickly verify the content and structure of Peach's webhook payloads without writing any code.

### 2. Using Peach's Static Payload Test API

Peach provides an API endpoint to send a static test payload to your webhook URL. This is useful for verifying your endpoint's ability to receive and process webhooks. Use the TestWebhook endpoint and replace `{webhookSubscriptionId}` with the ID of the webhook subscription you want to test.

This API call will send a predefined test payload to your webhook URL. The response includes the HTTP status code and body returned by your endpoint

**Request**


```bash
curl --request POST \
  --url https://sandboxapi.peach.finance/api/webhooks/whk_1234567890abcdef/ping \
  --header 'Authorization: Bearer YOUR_API_KEY'
```

**Response**


```json
{
  "status": 0,
  "message": "Test webhook sent successfully",
  "data": {
    "statusCode": 200,
    "responseBody": "Webhook received"
  }
}
```

This API call will send a predefined test payload to your webhook URL. The response includes the HTTP status code and body returned by your endpoint.

## Best Practices for Webhook Testing

* **Verify Signatures**: Always implement and test signature verification to ensure the authenticity of incoming webhooks.
* **Handle Retries**: Test your endpoint's ability to handle repeated deliveries of the same event.
* **Implement Logging**: Log incoming webhooks for debugging and auditing purposes.
* **Test Error Scenarios**: Simulate various error conditions (e.g., server downtime, slow responses) to ensure your system handles failures gracefully.