Loading...
Loading...
Clerk webhooks for real-time events and data syncing. Listen for user creation, updates, deletion, and organization events. Build event-driven features like database sync, notifications, integrations.
npx skill4agent add clerk/skills clerk-webhooksPrerequisite: Webhooks are asynchronous. Use for background tasks (sync, notifications), not synchronous flows.
| Task | Link |
|---|---|
| Overview | https://clerk.com/docs/guides/development/webhooks/overview |
| Sync to database | https://clerk.com/docs/guides/development/webhooks/syncing |
| Debugging | https://clerk.com/docs/guides/development/webhooks/debugging |
| Event catalog | https://dashboard.clerk.com/~/webhooks (Event Catalog tab) |
app/api/webhooks/route.tsverifyWebhook(req)@clerk/nextjs/webhooksCLERK_WEBHOOK_SIGNING_SECRETuser.createduser.updateduser.deletedorganization.createdorganization.updatedorganization.deletedorganizationDomain.createdorganizationDomain.updatedorganizationDomain.deletedorganizationInvitation.createdorganizationInvitation.acceptedorganizationInvitation.revokedorganizationMembership.createdorganizationMembership.updatedorganizationMembership.deletedrole.createdrole.updatedrole.deletedpermission.createdpermission.updatedpermission.deletedsession.createdsession.updatedsession.endedsession.removedsession.revokedsession.pendingemail.createdsms.createdinvitation.createdinvitation.acceptedinvitation.revokedwaitlistEntry.createdwaitlistEntry.updatedclerkMiddleware()/api/webhooks(.*)import { verifyWebhook } from '@clerk/nextjs/webhooks'
const evt = await verifyWebhook(req) // Pass request directlyif (evt.type === 'user.created') {
// TypeScript knows evt.data structure
}user.createduser.updateduser.deletedawait queue.enqueue('process-webhook', evt)
return new Response('Received', { status: 200 })| Symptom | Cause | Fix |
|---|---|---|
| Verification fails | Wrong import or usage | Use |
| Route not found (404) | Wrong path | Use |
| Not authorized (401) | Route is protected | Make route public |
| No data in DB | Async job pending | Wait/check logs |
| Duplicate entries | Only handling | Also handle |
| Timeouts | Handler too slow | Queue async work |
localhost:3000