0

Delete tag

by
Published Dec 20, 2024

You can delete the details of tags that are on the workspace by passing in the id.

Script intercom Verified

The script

Submitted by hugo697 Bun
Verified 536 days ago
1
//native
2
type Intercom = {
3
	apiVersion: string
4
	token: string
5
}
6
/**
7
 * Delete tag
8
 * You can delete the details of tags that are on the workspace by passing in the id.
9
 */
10
export async function main(auth: Intercom, id: string) {
11
	const url = new URL(`https://api.intercom.io/tags/${id}`)
12

13
	const response = await fetch(url, {
14
		method: 'DELETE',
15
		headers: {
16
			'Intercom-Version': auth.apiVersion,
17
			Authorization: 'Bearer ' + auth.token
18
		},
19
		body: undefined
20
	})
21
	if (!response.ok) {
22
		const text = await response.text()
23
		throw new Error(`${response.status} ${text}`)
24
	}
25
	return await response.text()
26
}
27