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

# Code Generation

> Generate TypeScript interfaces and handler code from any captured event

Hookdrop can generate working code directly from a captured event — a TypeScript interface for your types, or a complete handler ready to drop into your codebase.

<Note>AI features require Starter plan or above. [Upgrade your plan](/billing/plans) to get access.</Note>

## TypeScript interface

Generate a typed TypeScript interface from the shape of any captured event payload.

```bash theme={null}
GET /api/endpoints/:id/events/:eventId/ai/schema
Authorization: Bearer YOUR_API_TOKEN
```

### Example response

```json theme={null}
{
  "schema": "interface PaystackChargeSuccessEvent {\n  event: string;\n  data: {\n    id: number;\n    status: string;\n    reference: string;\n    amount: number;\n    currency: string;\n    customer: {\n      email: string;\n      name: string;\n    };\n  };\n}"
}
```

## Handler code

Generate a complete webhook handler in your preferred language and framework. The generated handler includes HMAC signature verification, error handling, and logic based on the event type.

```bash theme={null}
POST /api/endpoints/:id/events/:eventId/ai/handler
Authorization: Bearer YOUR_API_TOKEN
Content-Type: application/json
```

### Request body

```json theme={null}
{
  "language": "typescript",
  "framework": "express"
}
```

### Example response

```json theme={null}
{
  "handler": "import { Request, Response } from 'express';\nimport crypto from 'crypto';\n\nexport function handleWebhook(req: Request, res: Response) {\n  const signature = req.headers['x-paystack-signature'] as string;\n  const hash = crypto.createHmac('sha512', process.env.PAYSTACK_SECRET!)\n    .update(JSON.stringify(req.body))\n    .digest('hex');\n\n  if (hash !== signature) {\n    return res.status(401).json({ error: 'Invalid signature' });\n  }\n\n  const event = req.body;\n\n  if (event.event === 'charge.success') {\n    // Handle successful charge\n    console.log(`Payment of ${event.data.amount} received from ${event.data.customer.email}`);\n  }\n\n  res.status(200).json({ received: true });\n}"
}
```

<Tip>Copy the generated handler directly into your codebase as a starting point. Review the signature verification secret and swap in your own environment variable names before deploying.</Tip>

## Supported languages

| Language   | Value        |
| ---------- | ------------ |
| TypeScript | `typescript` |
| JavaScript | `javascript` |
| Python     | `python`     |
| Go         | `go`         |

## Supported frameworks

| Framework | Value     |
| --------- | --------- |
| Express   | `express` |
| Fastify   | `fastify` |
| Next.js   | `nextjs`  |
| FastAPI   | `fastapi` |
| Gin       | `gin`     |
