List Job Statuses
One script reply has been approved by the moderators Verified

Shows the statuses for background jobs. Statuses are sorted first by completion date and then by creation date in descending order.

Allowed For:

  • Agents

Pagination

  • Cursor pagination

See Pagination.

Returns a maximum of 100 records per page sorted by completed_at desc, created_at desc. Does not allow any other sort order.

Created by hugo697 844 days ago
Submitted by hugo697 Typescript (fetch-only)
Verified 298 days ago
1
type Zendesk = {
2
  username: string;
3
  password: string;
4
  subdomain: string;
5
};
6
/**
7
 * List Job Statuses
8
 * Shows the statuses for background jobs. Statuses are sorted first by completion date and then by creation date in descending order.
9

10
#### Allowed For:
11

12
* Agents
13

14
#### Pagination
15

16
* Cursor pagination
17

18
See Pagination.
19

20
Returns a maximum of 100 records per page sorted by `completed_at desc, created_at desc`. Does not allow any other sort order.
21

22
 */
23
export async function main(auth: Zendesk) {
24
  const url = new URL(
25
    `https://${auth.subdomain}.zendesk.com/api/v2/job_statuses`
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