> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fungies.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Test Webhooks

> Test your webhook integration locally before deploying to production.

Before deploying your webhook handler to production, you'll want to verify it works correctly. This guide covers two approaches: using webhook.site for quick testing, and ngrok for testing your actual code.

## Option 1: Quick Test with webhook.site

[webhook.site](https://webhook.site/) is a free tool that gives you a temporary URL to receive and inspect webhook payloads. It's perfect for understanding the event structure before writing any code.

<Steps>
  <Step title="Get a test URL">
    Go to [webhook.site](https://webhook.site/) and copy your unique URL
  </Step>

  <Step title="Create a webhook in Fungies">
    Navigate to [Fungies Dashboard](https://app.fungies.io) → **Developers** → **Webhooks** → **Create a webhook**

    <img src="https://mintcdn.com/fungiesinc/CGeJwGZUdcm-W7aH/assets/webhook-create-form.png?fit=max&auto=format&n=CGeJwGZUdcm-W7aH&q=85&s=1355d93f694f21996e2f0712ad76f42e" alt="Create a webhook" width="590" height="377" data-path="assets/webhook-create-form.png" />
  </Step>

  <Step title="Send a test event">
    Open your webhook and click the **Test** button. Select an event type and click **Send**.

    <img src="https://mintcdn.com/fungiesinc/CGeJwGZUdcm-W7aH/assets/webhook-test-modal.png?fit=max&auto=format&n=CGeJwGZUdcm-W7aH&q=85&s=8280d1fb2c65c2c6d577b9da426a3c92" alt="Test webhook modal" width="1053" height="501" data-path="assets/webhook-test-modal.png" />
  </Step>

  <Step title="Inspect the payload">
    Check webhook.site to see the full event payload and headers.

    <img src="https://mintcdn.com/fungiesinc/CGeJwGZUdcm-W7aH/assets/webhook-site-request.png?fit=max&auto=format&n=CGeJwGZUdcm-W7aH&q=85&s=e310c7cd5267be166b13530d35d5b53b" alt="webhook.site request" width="685" height="531" data-path="assets/webhook-site-request.png" />
  </Step>
</Steps>

<Info>
  Test events include `"testMode": true` in the payload and don't affect any real data in your account.
</Info>

## Option 2: Test Your Code with ngrok

[ngrok](https://ngrok.com) creates a secure tunnel from the internet to your local machine. This lets you test your actual webhook handler code with real Fungies events.

### Install ngrok

```bash theme={null}
# macOS (Homebrew)
brew install ngrok

# Or download from https://ngrok.com/download
```

### Start the Tunnel

Run your local server, then create a tunnel to it:

```bash theme={null}
# Start your local server (example: running on port 3000)
npm run dev

# In another terminal, create the tunnel
ngrok http 3000
```

You'll see output like this:

```bash theme={null}
Session Status                online
Forwarding                    https://abc123.ngrok.io -> localhost:3000
```

### Register Your Tunnel URL

1. Copy the `https://...ngrok.io` URL
2. Go to [Fungies Dashboard](https://app.fungies.io) → **Developers** → **Webhooks**
3. Create a webhook with your ngrok URL + your endpoint path (e.g., `https://abc123.ngrok.io/webhooks/fungies`)

### Send Test Events

Use the **Test** button in the Dashboard to send events to your local server. Check your terminal logs to see the events being received and processed.

<Tip>
  ngrok provides a local web interface at `http://localhost:4040` where you can inspect all requests and replay them for debugging.
</Tip>

## Testing Best Practices

### Use a Separate Webhook for Testing

Create a dedicated webhook endpoint for development to avoid mixing test events with production data.

### Verify Your Error Handling

Test how your handler responds to:

* Invalid payloads
* Missing required fields
* Duplicate events (same event ID sent twice)
* Network timeouts

### Log Everything During Development

```javascript theme={null}
app.post('/webhooks/fungies', (req, res) => {
  console.log('Received webhook:', {
    headers: req.headers,
    body: JSON.stringify(req.body, null, 2)
  });
  
  // ... your handler logic
  
  res.status(200).send('OK');
});
```

## Checklist Before Going Live

<Check>Endpoint returns `2xx` within 30 seconds</Check>
<Check>Signature verification is implemented and working</Check>
<Check>Handler is idempotent (handles duplicate events)</Check>
<Check>Errors are logged for debugging</Check>
<Check>Endpoint uses HTTPS</Check>

## Next Steps

<CardGroup cols={2}>
  <Card title="Webhook Overview" icon="webhook" href="/developers/webhooks/overview">
    Review webhook concepts and delivery guarantees
  </Card>

  <Card title="Event Reference" icon="bolt" href="/core-resources/event">
    See all available event types and their payloads
  </Card>
</CardGroup>
