Skip to content

Built for people who want to own their automations. Join the waitlist for an invite.

Package listing

@kody/cal-com

src/create-webhook.js

19 lines · 977 B · JavaScript
import { createWebhook } from './cal-com.js'

/**
 * Create a Cal.com webhook subscription.
 * Requires `dryRun: true` to preview or `confirm: true` to write.
 * @param {Object} input
 * @param {string} input.subscriberUrl Callback URL Cal.com should POST to.
 * @param {string[]} [input.triggers] Event triggers to subscribe to.
 * @param {boolean} [input.dryRun] Return the request preview without creating a webhook.
 * @param {boolean} [input.confirm] Required for the live write.
 * @returns {Promise<Record<string, unknown>>} Created webhook payload or dry-run preview.
 * @example
 * import createWebhook from 'kody:@kody/cal-com/create-webhook'
 * const preview = await createWebhook({ subscriberUrl: 'https://example.com/hooks/cal', triggers: ['BOOKING_CREATED'], dryRun: true })
 * // => { dryRun: true, method: 'POST', path: '/v2/webhooks', body: { ... } }
 */
export default async function createWebhookEntrypoint(input = {}) {
	return await createWebhook(input)
}