Skip to main content
AI features require a Starter plan or above. Upgrade your plan to unlock them.
Hookdrop can generate production-ready code directly from a real webhook payload. Use this to bootstrap your integration without writing boilerplate by hand.

Generate TypeScript interface

Hookdrop inspects the shape of a captured payload and returns a TypeScript interface that matches it exactly — field names, nested objects, optional fields, and all.

From the dashboard

  1. Open the Events tab for any endpoint.
  2. Click the event you want to type.
  3. Click Generate types in the event detail panel.
Copy the generated interface directly into your project.

Via the API

curl https://hookdrop.dev/api/endpoints/<endpointId>/events/<eventId>/ai/schema \
  -H "Authorization: Bearer YOUR_API_TOKEN"
Example response
{
  "schema": "interface WebhookPayload {\n  event: string;\n  data: {\n    id: string;\n    customer: {\n      id: string;\n      email: string;\n    };\n    amount: number;\n    currency: string;\n    reference: string;\n    status: 'success' | 'failed' | 'pending';\n    paid_at: string;\n    channel: string;\n    card_last4: string;\n  };\n}"
}
Rendered, that interface looks like this:
interface WebhookPayload {
  event: string;
  data: {
    id: string;
    customer: {
      id: string;
      email: string;
    };
    amount: number;
    currency: string;
    reference: string;
    status: 'success' | 'failed' | 'pending';
    paid_at: string;
    channel: string;
    card_last4: string;
  };
}
The generated interface is based on a single event payload. If your webhook provider sends events with optional fields, capture a few different event types and merge the interfaces to get full coverage.

Generate handler code

Send a POST request with your preferred language and framework, and Hookdrop returns a complete handler function ready to paste into your project.

Supported options

OptionValues
languagetypescript, javascript, python, go
frameworkexpress, fastify, nextjs, fastapi, gin

Via the API

curl -X POST https://hookdrop.dev/api/endpoints/<endpointId>/events/<eventId>/ai/handler \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"language": "typescript", "framework": "express"}'
Request body
{
  "language": "typescript",
  "framework": "express"
}

Example responses

import { Request, Response } from 'express';

interface WebhookPayload {
  event: string;
  data: {
    id: string;
    customer: { id: string; email: string };
    amount: number;
    currency: string;
    reference: string;
    status: 'success' | 'failed' | 'pending';
    paid_at: string;
    channel: string;
    card_last4: string;
  };
}

export async function handleWebhook(req: Request, res: Response): Promise<void> {
  const payload = req.body as WebhookPayload;

  switch (payload.event) {
    case 'charge.success':
      await handleChargeSuccess(payload.data);
      break;
    default:
      console.log(`Unhandled event type: ${payload.event}`);
  }

  res.status(200).json({ received: true });
}

async function handleChargeSuccess(data: WebhookPayload['data']): Promise<void> {
  console.log(`Payment of ${data.amount / 100} ${data.currency} received from ${data.customer.email}`);
  // TODO: fulfil the order, update your database, send a confirmation email, etc.
}
Generated handler code is a starting point. Review it before deploying to production — in particular, add signature verification to confirm the webhook genuinely came from your provider.