Webhooks allow external services to notify your application when events occur. For example, you can use webhooks to receive notifications when a new order is placed in your e-commerce store, a new user signs up, or a new message is sent in your chat application.
Upstash Workflow provides a simple way to receive these events and trigger workflows based on the incoming data autonomously.
Always validate incoming webhook requests to ensure they’re legitimate. This way, no one other than the original webhook source can trigger your workflow. Here’s an example using Clerk webhooks with Svix:
export const { POST } = serve<string>(async (context) => { const payloadString = context.requestPayload; const headerPayload = context.headers; let event: WebhookEvent; try { event = await validateRequest(payloadString, headerPayload); } catch { return } // Next steps based on the event})
After validating the webhook and extracting the initial user data, you’ll often need to perform additional operations like creating customer records, sending welcome emails etc.