0
Delete Webhook
One script reply has been approved by the moderators Verified

Delete a webhook automation

Created by hugo697 25 days ago Viewed 10 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 25 days ago
1
type Convertkit = {
2
	apiSecret: string
3
}
4

5
export async function main(resource: Convertkit, ruleId: string) {
6
	const endpoint = `https://api.convertkit.com/v3/automations/hooks/${ruleId}`
7

8
	const body = {
9
		api_secret: resource.apiSecret
10
	}
11

12
	const response = await fetch(endpoint, {
13
		method: 'DELETE',
14
		headers: {
15
			'Content-Type': 'application/json'
16
		},
17
		body: JSON.stringify(body)
18
	})
19

20
	if (!response.ok) {
21
		throw new Error(`HTTP error! status: ${response.status}`)
22
	}
23

24
	const data = await response.json()
25
	return data
26
}
27