Webhooks
Outbound Webhooks
Send webhooks to your users using Svix.
@repo/webhooks sends outbound webhooks through Svix.
Outbound webhooks are enabled by the presence of the SVIX_TOKEN environment variable.
How it works
The package calls the Svix API statelessly. The authenticated user's organization ID is used as the Svix application UID, and Svix creates that application when the first message is sent.
Usage
Send a webhook
Use the send function from @repo/webhooks:
import { webhooks } from '@repo/webhooks';
await webhooks.send('invoice.created', {
data: {
id: 'inv_1234567890',
},
});Add webhook endpoints
Svix hosts a consumer application portal where users add endpoints and manage their subscriptions. Access is a short-lived magic-link session, which can be embedded in an iframe.
getAppPortal returns that URL:
import { webhooks } from '@repo/webhooks';
const { url } = await webhooks.getAppPortal();
return (
<iframe src={url} style="width: 100%; height: 100%; border: none;" allow="clipboard-write" loading="lazy" />
);The app app renders this at /webhooks.