Create a webhook
client.webhooks.create(WebhookCreateParams { url, enabled, event_types, 2 more } body, RequestOptionsoptions?): WebhookCreateResponse { id, created_at, enabled, 7 more }
POST/v1/webhooks
Creates a new webhook endpoint. When events occur (e.g. feedback_record.created), the Hub POSTs a signed payload to the webhook URL. If signing_key is omitted, a key is auto-generated (Standard Webhooks format, whsec_...). See WebhookDeliveryPayload for the payload structure sent to your URL.
Parameters
Returns
Create a webhook
import FormbricksHub from '@formbricks/hub';
const client = new FormbricksHub({
apiKey: process.env['HUB_API_KEY'], // This is the default and can be omitted
});
const webhook = await client.webhooks.create({
url: 'https://example.com/hub-events',
enabled: true,
event_types: ['feedback_record.created', 'feedback_record.updated', 'feedback_record.deleted'],
});
console.log(webhook.id);{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"created_at": "2019-12-27T18:11:19.117Z",
"enabled": true,
"signing_key": "signing_key",
"updated_at": "2019-12-27T18:11:19.117Z",
"url": "url",
"disabled_at": "2019-12-27T18:11:19.117Z",
"disabled_reason": "disabled_reason",
"event_types": [
"feedback_record.created"
],
"tenant_id": "tenant_id"
}Returns Examples
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"created_at": "2019-12-27T18:11:19.117Z",
"enabled": true,
"signing_key": "signing_key",
"updated_at": "2019-12-27T18:11:19.117Z",
"url": "url",
"disabled_at": "2019-12-27T18:11:19.117Z",
"disabled_reason": "disabled_reason",
"event_types": [
"feedback_record.created"
],
"tenant_id": "tenant_id"
}