List Identities

Returns a list of identities for the given user. Use the first endpoint if authenticating as an agent. Use the second if authenticating as an end user. End users can only list email and phone number identities. #### Pagination * Cursor pagination (recommended) * Offset pagination See Pagination. Returns a maximum of 100 records per page. #### Allowed For * Agents * Verified end users

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 Identities
8
 * Returns a list of identities for the given user.
9

10
Use the first endpoint if authenticating as an agent. Use the second if authenticating as an end user. End users can only list email and phone number identities.
11

12
#### Pagination
13

14
* Cursor pagination (recommended)
15
* Offset pagination
16

17
See Pagination.
18

19
Returns a maximum of 100 records per page.
20

21
#### Allowed For
22

23
* Agents
24
* Verified end users
25

26
 */
27
export async function main(auth: Zendesk, user_id: string) {
28
  const url = new URL(
29
    `https://${auth.subdomain}.zendesk.com/api/v2/users/${user_id}/identities`
30
  );
31

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