List Account Attributes

Returns a list of attributes for the account. #### Sideloads The following sideloads are supported: | Name | Will sideload | ---------------- | ------------- | attribute_values | The attribute values available on the account #### Allowed For * Agents and admins

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 Account Attributes
8
 * Returns a list of attributes for the account.
9

10
#### Sideloads
11

12
The following sideloads are supported:
13

14
| Name             | Will sideload
15
| ---------------- | -------------
16
| attribute_values | The attribute values available on the account
17

18
#### Allowed For
19

20
* Agents and admins
21

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

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