Clerk Webhook Integration
Clerk webhooks (called Svix webhooks) allow you to receive real-time notifications about events in your Clerk application, such as user sign-ups, profile updates, organization changes, and session events.Quick Start
- Get your Unhook URL:
https://unhook.sh/wh_YOUR_ID - Configure in Clerk Dashboard: dashboard.clerk.com/webhooks
- Start receiving events locally:
unhook listen
Configuration Steps
1. Access Clerk Webhook Settings
Navigate to the Clerk Dashboard:- Direct Link: dashboard.clerk.com/webhooks
- Or go to Dashboard → Configure → Webhooks
2. Create a New Endpoint
- Click “Add Endpoint”
- Enter your Unhook URL:
- Give your endpoint a descriptive name (e.g., “Development Webhooks”)
3. Select Events to Listen For
Choose the events relevant to your application:User Events
user.created- New user sign-upuser.updated- User profile updateduser.deleted- User account deletedemail.created- Email address addedphoneNumber.created- Phone number addedexternalAccount.created- Social login connectedexternalAccount.deleted- Social login disconnected
Session Events
session.created- User signed insession.ended- User signed outsession.removed- Session revokedsession.revoked- Session invalidated
Organization Events
organization.created- New organization createdorganization.updated- Organization settings changedorganization.deleted- Organization removedorganizationMembership.created- Member addedorganizationMembership.updated- Member role changedorganizationMembership.deleted- Member removedorganizationInvitation.created- Invitation sentorganizationInvitation.accepted- Invitation acceptedorganizationInvitation.revoked- Invitation cancelled
Multi-factor Authentication Events
user.twoFactorEnabled- 2FA enableduser.twoFactorDisabled- 2FA disabledsmsVerification.created- SMS verification sentemailVerification.created- Email verification sent
4. Configure Webhook Settings
After selecting events:- Enable the endpoint with the toggle switch
- Copy the Signing Secret - you’ll need this to verify webhooks
- Click “Create” to save
Webhook Verification
Clerk uses Svix to sign webhooks. To verify signatures:- After creating the endpoint, copy the Signing Secret
- It will look like:
whsec_MfKQ9r8GKYqrTwjUPD8ILPZIo2LaLaSw - Add it to your environment variables:
Testing Webhooks
Using Clerk Dashboard
- Go to your webhook endpoint in the Dashboard
- Click on the endpoint
- Navigate to the “Testing” tab
- Select an event type
- Click “Send Example”
Using Clerk CLI
Event Payload Examples
User Created
Session Created
Organization Membership Created
Best Practices
1. Verify Webhook Signatures
Always verify that webhooks are coming from Clerk using Svix:2. Handle Event Types Safely
Use TypeScript types for better type safety:3. Implement Idempotency
Prevent duplicate processing using the event ID:4. Queue Heavy Operations
Don’t block the webhook response:Common Issues
Signature Verification Failures
- Ensure you’re using the correct signing secret
- Make sure to use the raw request body (not parsed)
- Check that no middleware is modifying the request
Missing Events
- Verify all required events are selected in the dashboard
- Check that your endpoint is enabled
- Ensure your Unhook URL is correct
Delayed Events
- Some events may have a slight delay (e.g.,
user.deleted) - Implement proper retry logic for critical operations
- Use Clerk’s API to verify current state if needed
Environment Variables
Required environment variables for Clerk webhooks:Useful Links
- Clerk Webhook Documentation: clerk.com/docs/webhooks/overview
- Svix Webhook Verification: clerk.com/docs/webhooks/verify
- Event Types Reference: clerk.com/docs/webhooks/events
- Clerk Dashboard: dashboard.clerk.com
- Clerk Support: clerk.com/support
Support
Need help with Clerk webhooks?- Join our Discord community
- Check Clerk’s documentation
- Email us at support@unhook.sh