NewWacht Bench is live — AI-assisted development for Wacht

createWebhookEndpoint()

Creates a webhook endpoint for one app slug. The SDK injects app_slug into the backend request payload from the method argument.

Usage

The following example shows a basic usage of the backend client from @wacht/nextjs/server.

import { wachtClient } from '@wacht/nextjs/server';export async function createWebhookEndpoint(appSlug: string) {  const client = await wachtClient();  return client.webhooks.createWebhookEndpoint(appSlug, {    url: 'https://example.com/webhooks/wacht',    subscriptions: [      { event_name: 'user.created' },      { event_name: 'user.updated' },    ],    max_retries: 5,    timeout_seconds: 15,  });}

Signature

function createWebhookEndpoint(  appSlug: string,  request: CreateWebhookEndpointRequest,): Promise<WebhookEndpoint>

CreateWebhookEndpointRequest

appSlug?: string | undefined;
Slug of the webhook app that will own the endpoint.
url?: string | undefined;
Destination URL for webhook deliveries.
subscriptions?: EventSubscription[] | undefined;
Event subscription list for this endpoint.
event_name?: string | undefined;
Event name to subscribe this endpoint to.
filter_rules?: Record<string, unknown> | null | undefined;
Optional filtering rules evaluated before delivery.
changed?: string[] | undefined;
Example rule: only deliver when specific fields changed.
headers?: Record<string, string> | undefined;
Optional static headers added to webhook delivery requests.
x-source?: string | undefined;
Example static header key/value sent with each delivery.
description?: string | undefined;
Optional endpoint description.
max_retries?: number | undefined;
Optional retry limit override.
timeout_seconds?: number | undefined;
Optional request timeout override in seconds.
rate_limit_config?: RateLimitConfig | null | undefined;
Optional per-endpoint rate limit configuration.
enabled?: boolean | undefined;
Enable endpoint-level delivery throttling.
requests_per_minute?: number | undefined;
Maximum deliveries per minute for this endpoint.

Behavior

  • Creates a new resource and returns the created object from the backend.
  • Validate required fields before calling to avoid predictable request failures.

Examples

Create a basic endpoint

import { wachtClient } from '@wacht/nextjs/server';export async function createEndpoint(appSlug: string) {  const client = await wachtClient();  return client.webhooks.createWebhookEndpoint(appSlug, {    url: 'https://example.com/webhooks/wacht',    subscriptions: [{ event_name: 'user.created' }],  });}

Create endpoint with filters and custom headers

import { wachtClient } from '@wacht/nextjs/server';export async function createFilteredEndpoint(appSlug: string) {  const client = await wachtClient();  return client.webhooks.createWebhookEndpoint(appSlug, {    url: 'https://example.com/webhooks/wacht-critical',    headers: {      'x-source': 'wacht',    },    subscriptions: [      {        event_name: 'user.updated',        filter_rules: { changed: ['email'] },      },    ],  });}

On this page