Skip to content

Commit 83b4cff

Browse files
docs(backend): Add import to verifyWebhook code example (#6895)
Co-authored-by: Alexis Aguilar <[email protected]>
1 parent 23b37fc commit 83b4cff

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

.changeset/calm-yaks-ring.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/backend/src/webhooks.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,27 @@ function createStandardWebhookHeaders(request: Request): Record<string, string>
6363
* See the [guide on syncing data](https://clerk.com/docs/guides/development/webhooks/syncing) for more comprehensive and framework-specific examples that you can copy and paste into your app.
6464
*
6565
* ```ts
66-
* try {
67-
* const evt = await verifyWebhook(request)
66+
* import { verifyWebhook } from '@clerk/backend/webhooks'
6867
*
69-
* // Access the event data
70-
* const { id } = evt.data
71-
* const eventType = evt.type
68+
* export async function POST(request: Request) {
69+
* try {
70+
* const evt = await verifyWebhook(request)
7271
*
73-
* // Handle specific event types
74-
* if (evt.type === 'user.created') {
75-
* console.log('New user created:', evt.data.id)
76-
* // Handle user creation
77-
* }
72+
* // Access the event data
73+
* const { id } = evt.data
74+
* const eventType = evt.type
75+
*
76+
* // Handle specific event types
77+
* if (evt.type === 'user.created') {
78+
* console.log('New user created:', evt.data.id)
79+
* // Handle user creation
80+
* }
7881
*
79-
* return new Response('Success', { status: 200 })
80-
* } catch (err) {
81-
* console.error('Webhook verification failed:', err)
82-
* return new Response('Webhook verification failed', { status: 400 })
82+
* return new Response('Success', { status: 200 })
83+
* } catch (err) {
84+
* console.error('Webhook verification failed:', err)
85+
* return new Response('Webhook verification failed', { status: 400 })
86+
* }
8387
* }
8488
* ```
8589
*/

0 commit comments

Comments
 (0)