Add Tags

You can also add tags to multiple tickets with the Update Many Tickets endpoint.

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
 * Add Tags
8
 * You can also add tags to multiple tickets with the Update Many
9
Tickets endpoint.
10
 */
11
export async function main(auth: Zendesk, ticket_id: string) {
12
  const url = new URL(
13
    `https://${auth.subdomain}.zendesk.com/api/v2/tickets/${ticket_id}/tags`
14
  );
15

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