---
name: setup-webhooks
title: Set up RTIE webhooks
description: Register a webhook endpoint, add HMAC signature verification, and handle key events from the RTIE event catalog.
tags: [webhooks, events, integration]
---

You are helping me set up webhook delivery from RTIE to my backend.

**My backend webhook URL:** [YOUR_WEBHOOK_URL]

Please do the following:

1. Generate a secure webhook secret:
   ```typescript
   const secret = crypto.randomBytes(32).toString("hex");
   ```
   Tell me to store this as `RTIE_WEBHOOK_SECRET` in my environment.

2. Use the `create_webhook_endpoint` MCP tool to register my endpoint with these event types:
   - `room.member.joined`
   - `room.member.left`
   - `auction.bid.placed`
   - `auction.closed`
   - `payment.order.paid`

3. Use `list_webhook_endpoints` to confirm it was created and show me the endpoint ID.

4. Write a Hono webhook handler at `/webhooks/rtie` that:
   - Reads the raw request body as text
   - Verifies the `rtie-signature` HMAC header (show the full verification function)
   - Parses the verified body as JSON
   - Has a `switch` statement for each event type I registered
   - Returns `{ received: true }` on success, 401 on bad signature
   - Is idempotent — skips events with already-processed `id` values

5. Show me how to use `list_webhook_deliveries` with my endpoint ID to check delivery history and debug failures.

6. Explain the retry policy (how many attempts, backoff schedule).
