0
List Ticket Skips
One script reply has been approved by the moderators Verified

Archived tickets are not included in the response. See About archived tickets in the Support Help Center.

Pagination

  • Cursor pagination (recommended)
  • Offset pagination

See Pagination.

Returns a maximum of 100 records per page.

Allowed For

  • Agents with "View only" or higher reports permissions in Support. These permissions are distinct from Explore permissions.
  • Agents retrieving their own skips
Created by hugo697 605 days ago Viewed 22443 times
0
Submitted by hugo697 Typescript (fetch-only)
Verified 605 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * List Ticket Skips
8
 * Archived tickets are not included in the response. See
9
[About archived tickets](https://support.zendesk.com/hc/en-us/articles/203657756) in
10
the Support Help Center.
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
* Agents with "View only" or higher reports permissions in Support.
23
  These permissions are distinct from Explore permissions.
24
* Agents retrieving their own skips
25

26
 */
27
export async function main(
28
  auth: Zendesk,
29
  user_id: string,
30
  sort_order: string | undefined
31
) {
32
  const url = new URL(
33
    `https://${auth.subdomain}.zendesk.com/api/v2/users/${user_id}/skips`
34
  );
35
  for (const [k, v] of [["sort_order", sort_order]]) {
36
    if (v !== undefined && v !== "") {
37
      url.searchParams.append(k, v);
38
    }
39
  }
40
  const response = await fetch(url, {
41
    method: "GET",
42
    headers: {
43
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
44
    },
45
    body: undefined,
46
  });
47
  if (!response.ok) {
48
    const text = await response.text();
49
    throw new Error(`${response.status} ${text}`);
50
  }
51
  return await response.json();
52
}
53