Show Trigger Revision

Fetches a revision associated with a trigger. Trigger revision history is only available on Enterprise plans. #### Allowed For * Agents #### Sideloads The following sideloads are supported: | Name | Will sideload | ----- | ------------- | users | The user that authored each revision

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 Trigger Revision
8
 * Fetches a revision associated with a trigger. Trigger revision history is only available on Enterprise plans.
9

10
#### Allowed For
11

12
 * Agents
13

14
#### Sideloads
15

16
The following sideloads are supported:
17

18
| Name  | Will sideload
19
| ----- | -------------
20
| users | The user that authored each revision
21

22
 */
23
export async function main(
24
  auth: Zendesk,
25
  trigger_id: string,
26
  trigger_revision_id: string
27
) {
28
  const url = new URL(
29
    `https://${auth.subdomain}.zendesk.com/api/v2/triggers/${trigger_id}/revisions/${trigger_revision_id}`
30
  );
31

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