0

Delete tags

by
Published Oct 17, 2025

Delete a list of tags. Any views that use this tag will be deactivated. Tags currently used in macros and/or rules cannot be deleted.

Script gorgias Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Gorgias = {
3
  username: string;
4
  apiKey: string;
5
  domain: string;
6
};
7
/**
8
 * Delete tags
9
 * Delete a list of tags. Any views that use this tag will be deactivated. Tags currently used in macros and/or rules cannot be deleted.
10

11
 */
12
export async function main(auth: Gorgias, body: { ids: number[] }) {
13
  const url = new URL(`https://${auth.domain}.gorgias.com/api/tags`);
14

15
  const response = await fetch(url, {
16
    method: "DELETE",
17
    headers: {
18
      "Content-Type": "application/json",
19
      Authorization: "Basic " + btoa(`${auth.username}:${auth.apiKey}`),
20
    },
21
    body: JSON.stringify(body),
22
  });
23
  if (!response.ok) {
24
    const text = await response.text();
25
    throw new Error(`${response.status} ${text}`);
26
  }
27
  return await response.text();
28
}
29