Webhook Events
Learn how to handle Discord webhook events with Honocord.
Webhook events allow your app to receive notifications from Discord about events happening in your application, such as entitlement purchases, lobby messages, or app authorizations. Unlike Gateway events, webhook events are sent over HTTP and don’t require maintaining a persistent connection.
What are Webhook Events?
Webhook events are one-way HTTP notifications sent from Discord to your app when specific events occur. They differ from interactions in several key ways:
| Feature | Interactions | Webhook Events |
|---|---|---|
| Direction | User → Your App | Discord → Your App |
| Purpose | Handle user actions | Receive event notifications |
| Response Time | 3 seconds | 3 seconds (acknowledgment) |
| Examples | Slash commands, buttons | Application authorized, Entitlement created |
Note
Setting Up Webhook Events
Create a WebhookEventHandler
Choose the event type you want to handle from
ApplicationWebhookEventType:Load the handler into Honocord
Configure Discord Developer Portal
- Navigate to your app’s settings
- Go to the Webhooks page
- Enter your public URL:
https://your-domain.com/webhook - Enable Events and select the events you want to receive
- Click Save Changes
Discord will verify your endpoint by sending a PING event.
Standard vs Worker Mode
Honocord supports two modes for webhook handlers, optimized for different deployment environments.
Standard Mode (Default)
In standard mode, your handler must return a Response object. This gives you full control over the response sent to Discord.
Use standard mode when:
- Running on traditional servers (Node.js, Bun)
- You need custom response codes or bodies
- You want full control over the response
Worker Mode (Cloudflare Workers)
In worker mode, you don’t need to return anything. Honocord automatically responds with 200 OK to Discord and processes your handler asynchronously using waitUntil.
Use worker mode when:
- Deploying to Cloudflare Workers
- Processing takes longer than 3 seconds
- You want fire-and-forget processing
- You don’t need custom response codes
Warning
Available Event Types
Discord supports various webhook event types. Here are the most common:
Monetization Events
Monitor entitlement lifecycle for in-app purchases:
Authorization Events
Track when users add or remove your app:
With custom types:
Important
Lobby & Direct Message Events
For apps using the Discord Social SDK:
Complete List
All available webhook event types:
APPLICATION_AUTHORIZEDAPPLICATION_DEAUTHORIZEDENTITLEMENT_CREATEENTITLEMENT_UPDATEENTITLEMENT_DELETEQUEST_USER_ENROLLMENT(currently unavailable)LOBBY_MESSAGE_CREATELOBBY_MESSAGE_UPDATELOBBY_MESSAGE_DELETEGAME_DIRECT_MESSAGE_CREATEGAME_DIRECT_MESSAGE_UPDATEGAME_DIRECT_MESSAGE_DELETE
Accessing Event Data
Event data is available via c.var.data / c.get("data") in your handler:
The context object also provides:
c.env- Environment variables (includingDISCORD_PUBLIC_KEY)c.req- The original request objectc.set()/c.get()- Custom context variables
Security
Honocord automatically handles request verification for you:
- Signature Validation - Verifies
X-Signature-Ed25519header using yourDISCORD_PUBLIC_KEY - Timestamp Validation - Checks
X-Signature-Timestampto prevent replay attacks - PING Responses - Automatically responds to Discord’s PING verification
All you need to do is provide DISCORD_PUBLIC_KEY in your environment variables.
Warning
Standalone Usage
You can use WebhookEventHandler independently of Honocord (standard mode only):
Note
Typings
The types for WebhookEventHandler are designed to provide strong type safety,
however it gets a littlemore complex when you start adding custom bindings and variables.
If you want to use custom Bindings and Variables, you need to specify the first 4 type parameters, even if you want to use the defaults for some of them. For example:
I’m working on improving the ergonomics of this, but this is a limitation of how TypeScript infers types from constructor arguments. If you have any suggestions on improving this, please let me know!
Troubleshooting
Endpoint Not Verifying
Ensure:
- Your URL is publicly accessible
DISCORD_PUBLIC_KEYis correctly set- Your app responds within 3 seconds
- You’re returning proper status codes (if using standard mode)
Events Not Being Received
Check:
- Events are enabled in Developer Portal
- Specific event types are selected
- Your endpoint hasn’t been disabled due to too many failures
- Request signatures are being validated correctly
Events being received multiple times in a short time
This is likely due to your handler not responding in time. If using standard mode, make sure to return a response within 3 seconds. If processing takes longer and you are on Workers, switch to worker mode to avoid timeouts and retries:
If using standard mode on CF Workers, switch to worker mode: