List Deleted Users

Returns deleted users, including permanently deleted users. If the results contains permanently deleted users, the users' properties that normally contain personal data, such as `email` and `phone`, are null. The `name` property is "Permanently Deleted User". #### 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 Deleted Users
8
 * Returns deleted users, including permanently deleted users.
9

10
If the results contains permanently deleted users, the users' properties
11
that normally contain personal data, such as `email` and `phone`,
12
are null. The `name` property is "Permanently Deleted User".
13

14
#### Pagination
15

16
* Cursor pagination (recommended)
17
* Offset pagination
18

19
See Pagination.
20

21
Returns a maximum of 100 records per page.
22

23
#### Allowed For
24

25
* Agents
26

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

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