Skip to content

Webhooks

Test webhooks from services like Stripe, GitHub, and Slack on your local machine.

Why Use Trapdoor for Webhooks?

Webhook providers (Stripe, GitHub, etc.) need a public URL to send events to. During development, your localhost isn't accessible from the internet. Trapdoor creates a public URL that forwards requests to your local server.

Quick Setup

  1. Start your local webhook handler:
bash
# Your app listening on port 3000
node server.js
  1. Open a trapdoor:
bash
trapdoor -port 3000 -name webhooks
  1. Use the URL in your webhook provider:
https://webhooks.trapdoor.sh/webhook

Service-Specific Guides

Stripe

  1. Go to Stripe Dashboard
  2. Click "Add endpoint"
  3. Enter your Trapdoor URL: https://myapp.trapdoor.sh/stripe/webhook
  4. Select events to listen for
  5. Copy the webhook secret to your app
javascript
// Express.js example
app.post('/stripe/webhook', (req, res) => {
  const event = req.body;
  console.log('Received Stripe event:', event.type);
  res.sendStatus(200);
});

GitHub

  1. Go to your repo → Settings → Webhooks
  2. Click "Add webhook"
  3. Payload URL: https://myapp.trapdoor.sh/github/webhook
  4. Content type: application/json
  5. Select events
javascript
app.post('/github/webhook', (req, res) => {
  const event = req.headers['x-github-event'];
  console.log('Received GitHub event:', event);
  res.sendStatus(200);
});

Slack

  1. Go to Slack API
  2. Create an app → Event Subscriptions
  3. Request URL: https://myapp.trapdoor.sh/slack/events
  4. Subscribe to events

Tips

  • Use a custom subdomain (-name) so your URL stays the same
  • Keep the tunnel running while testing
  • Check your terminal for incoming requests