Learn how to use Sequin to build a webhook subscription system for your users. Let your users receive webhook notifications whenever their data changes in your Postgres database.
users
: The list of users that can subscribe to webhooks.notifications
: Notifications that are sent to users. This is an example of the kinds of data you might want to send to users.webhook_subscriptions
: This table tracks the webhook subscriptions for each user. In this case, it’ll store the webhook URL and the Sequin sink ID for each subscription.pg
) to connect to the database you just configured, and Axios to interact with the Management API.
server.js
:server.js
file:/subscribe
endpoint that allows a user to create a new webhook subscription by providing a webhook URL and a user ID.
/subscribe
endpoint to create a new webhook subscription:
webhook_subscriptions
table in postgres as well.
notifications
table in your database:
message
field, you can use the following function:server.js
code to add this transform to the webhook sink automatically by adding the transform
key to the body of your create sink request:server.js
file, add a new /backfill
endpoint that makes a POST request to the Sequin Management API to start a backfill:/backfill
endpoint to start a backfill:notifications
table appear in your test webhook URL./metrics
endpoint (on port 8376) to monitor Sequin in your tooling.