UNPKG

@clerk/backend

Version:

Clerk Backend SDK - REST Client for Backend API & JWT verification utilities

50 lines 1.77 kB
import type { WebhookEvent } from './api/resources/Webhooks'; /** * @inline */ export type VerifyWebhookOptions = { /** * The signing secret for the webhook. It's recommended to use the [`CLERK_WEBHOOK_SIGNING_SECRET` environment variable](https://clerk.com/docs/guides/development/clerk-environment-variables#webhooks) instead. */ signingSecret?: string; }; export * from './api/resources/Webhooks'; /** * Verifies the authenticity of a webhook request using Standard Webhooks. Returns a promise that resolves to the verified webhook event data. * * @param request - The request object. * @param options - Optional configuration object. * * @displayFunctionSignature * @hideReturns * * @example * 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. * * ```ts * import { verifyWebhook } from '@clerk/backend/webhooks' * * export async function POST(request: Request) { * try { * const evt = await verifyWebhook(request) * * // Access the event data * const { id } = evt.data * const eventType = evt.type * * // Handle specific event types * if (evt.type === 'user.created') { * console.log('New user created:', evt.data.id) * // Handle user creation * } * * return new Response('Success', { status: 200 }) * } catch (err) { * console.error('Webhook verification failed:', err) * return new Response('Webhook verification failed', { status: 400 }) * } * } * ``` */ export declare function verifyWebhook(request: Request, options?: VerifyWebhookOptions): Promise<WebhookEvent>; //# sourceMappingURL=webhooks.d.ts.map