0

Find a specific tag

by
Published Dec 20, 2024

You can fetch the details of tags that are on the workspace by their id. This will return a tag object.

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
 * Find a specific tag
8
 * You can fetch the details of tags that are on the workspace by their id.
9
This will return a tag object.
10

11
 */
12
export async function main(auth: Intercom, id: string) {
13
	const url = new URL(`https://api.intercom.io/tags/${id}`)
14

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