0

List all collections

by
Published Dec 20, 2024

You can fetch a list of all collections by making a GET request to `https://api.intercom.io/help_center/collections`. Collections will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.

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
 * List all collections
8
 * You can fetch a list of all collections by making a GET request to `https://api.intercom.io/help_center/collections`.
9

10
Collections will be returned in descending order on the `updated_at` attribute. This means if you need to iterate through results then we'll show the most recently updated collections first.
11

12
 */
13
export async function main(auth: Intercom) {
14
	const url = new URL(`https://api.intercom.io/help_center/collections`)
15

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