Webhooks
This guide explains how to handle webhooks effectively in your Upstash Workflow applications. We’ll walk through:
- setting up webhook endpoints
- verifying webhook requests
- and processing webhook events
GitHub Repository
You can find the project source code on GitHub.
Overview
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.
Setting Up Webhook Endpoints
Basic Setup
To create a webhook endpoint, use the serve
function from @upstash/workflow
:
Request Validation
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:
Handling Webhook events
Use the context.run method to process webhook events in discrete, trackable steps:
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.
You’re now ready to perform any operation in the following steps.
Was this page helpful?