Show Identity

Shows the identity with the given id for a given user. Use the first endpoint if authenticating as an agent. Use the second if authenticating as an end user. End users can only view email or phone number identity. #### 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
 * Show Identity
8
 * Shows the identity with the given id for a 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 view email or phone number identity.
11

12
#### Allowed For
13

14
* Agents
15
* Verified end users
16

17
 */
18
export async function main(
19
  auth: Zendesk,
20
  user_id: string,
21
  user_identity_id: string
22
) {
23
  const url = new URL(
24
    `https://${auth.subdomain}.zendesk.com/api/v2/users/${user_id}/identities/${user_identity_id}`
25
  );
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