0

Edit a webhook

by
Published Oct 17, 2025

Edit a webhook subscription.

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Edit a webhook
4
 * Edit a webhook subscription.
5
 */
6
export async function main(auth: RT.Deel, id: string, body: Body) {
7
	const url = new URL(`https://api.letsdeel.com/rest/v2/webhooks/${id}`)
8

9
	const response = await fetch(url, {
10
		method: 'PATCH',
11
		headers: {
12
			'Content-Type': 'application/json',
13
			Authorization: 'Bearer ' + auth.apiKey
14
		},
15
		body: JSON.stringify(body)
16
	})
17
	if (!response.ok) {
18
		const text = await response.text()
19
		throw new Error(`${response.status} ${text}`)
20
	}
21
	return await response.json()
22
}
23

24
/* eslint-disable */
25
/**
26
 * This file was automatically generated by json-schema-to-typescript.
27
 * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
28
 * and run json-schema-to-typescript to regenerate this file.
29
 */
30

31
export interface Body {
32
	/**
33
	 * Webhook subscription name.
34
	 */
35
	name: string
36
	/**
37
	 * Webhook subscription description.
38
	 */
39
	description: string
40
	/**
41
	 * Status of webhook.
42
	 */
43
	status: 'enabled' | 'disabled'
44
	/**
45
	 * Endpoint to receive webhook.
46
	 */
47
	url: string
48
	/**
49
	 * The webhook's signing key, used to generate webhook signatures.
50
	 */
51
	signing_key: string
52
	/**
53
	 * Deel API version. Currently Deel accepts v1 or v2 version.
54
	 */
55
	api_version?: string
56
	/**
57
	 * The list of events to enable for this subscription.
58
	 */
59
	events: string[]
60
	[k: string]: unknown
61
}
62