Record a new skip for the current user

Record a new ticket skip for the current user. #### 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
 * Record a new skip for the current user
8
 * Record a new ticket skip for the current user.
9

10
#### Allowed For
11

12
* Agents
13

14
 */
15
export async function main(auth: Zendesk) {
16
  const url = new URL(`https://${auth.subdomain}.zendesk.com/api/v2/skips`);
17

18
  const response = await fetch(url, {
19
    method: "POST",
20
    headers: {
21
      Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
22
    },
23
    body: undefined,
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.json();
30
}
31