Skip to content
Get started

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.

ParametersExpand Collapse
body: WebhookCreateParams { url, enabled, event_types, 2 more }
url: string

URL to receive webhook POSTs. Must be an HTTP or HTTPS URL. NULL bytes not allowed.

minLength1
maxLength2048
formaturi
enabled?: boolean

Whether the webhook is active (default true)

event_types?: Array<"feedback_record.created" | "feedback_record.updated" | "feedback_record.deleted" | 3 more>

Event types this webhook subscribes to. Each value must be one of WebhookEventType. If empty, the webhook receives all event types.

Accepts one of the following:
"feedback_record.created"
"feedback_record.updated"
"feedback_record.deleted"
"webhook.created"
"webhook.updated"
"webhook.deleted"
signing_key?: string

Optional. If omitted, a key is auto-generated (whsec_...). Used to sign payloads (Standard Webhooks). When provided, max 255 characters; NULL bytes not allowed.

maxLength255
tenant_id?: string

Tenant/organization identifier. NULL bytes not allowed.

maxLength255
ReturnsExpand Collapse
WebhookCreateResponse { id, created_at, enabled, 7 more }
id: string

Webhook ID (UUID)

formatuuid
created_at: string

When the webhook was created

formatdate-time
enabled: boolean

Whether the webhook is active

signing_key: string

Key used to sign payloads (Standard Webhooks)

updated_at: string

When the webhook was last updated

formatdate-time
url: string

URL that receives webhook POSTs

disabled_at?: string | null

Read-only. When the webhook was disabled. Omitted when null. Cleared when the webhook is re-enabled via PATCH.

formatdate-time
disabled_reason?: string | null

Read-only. Set by the system when the webhook was disabled (e.g. after 410 Gone or max delivery failures). Omitted when null.

event_types?: Array<"feedback_record.created" | "feedback_record.updated" | "feedback_record.deleted" | 3 more>

Event types this webhook subscribes to (empty = all)

Accepts one of the following:
"feedback_record.created"
"feedback_record.updated"
"feedback_record.deleted"
"webhook.created"
"webhook.updated"
"webhook.deleted"
tenant_id?: string

Tenant/organization identifier

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"
}