List Audits for a Ticket

Lists the audits for a specified ticket. #### Pagination - Cursor pagination (recommended) - Offset pagination See Pagination. Returns a maximum of 100 records per page. **Note**: Audits for [Archived Tickets](https://support.zendesk.com/hc/en-us/articles/4408887617050) do not support pagination for this endpoint. #### 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 Audits for a Ticket
8
 * Lists the audits for a specified ticket.
9

10
#### Pagination
11

12
- Cursor pagination (recommended)
13
- Offset pagination
14

15
See Pagination.
16

17
Returns a maximum of 100 records per page.
18

19
**Note**: Audits for [Archived Tickets](https://support.zendesk.com/hc/en-us/articles/4408887617050) do not support pagination for this endpoint.
20

21
#### Allowed for
22

23
* Agents
24

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

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