List Tags

Lists up to the 20,000 most popular tags in the last 60 days, in decreasing popularity. #### Pagination * Cursor pagination (recommended) * Offset pagination See Pagination. Returns a maximum of 100 records per page. #### Allowed For * Agents

Script zendesk Verified

by hugo697 ยท 11/7/2023

The script

Submitted by hugo697 Typescript (fetch-only)
Verified 377 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * List Tags
8
 * Lists up to the 20,000 most popular tags in the last 60 days, in decreasing popularity.
9

10
#### Pagination
11

12
* Cursor pagination (recommended)
13
* Offset pagination
14

15
See Pagination.
16

17
Returns a maximum of 100 records per page.
18

19
#### Allowed For
20

21
* Agents
22

23
 */
24
export async function main(auth: Zendesk) {
25
  const url = new URL(`https://${auth.subdomain}.zendesk.com/api/v2/tags`);
26

27
  const response = await fetch(url, {
28
    method: "GET",
29
    headers: {
30
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
31
    },
32
    body: undefined,
33
  });
34
  if (!response.ok) {
35
    const text = await response.text();
36
    throw new Error(`${response.status} ${text}`);
37
  }
38
  return await response.json();
39
}
40