0

Delete Favorite

by
Published Oct 17, 2025

Deletes a single favorite from the user's list of favorite items by type and ID.

Script smartsheet Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Smartsheet = {
3
  token: string;
4
  baseUrl: string;
5
};
6
/**
7
 * Delete Favorite
8
 * Deletes a single favorite from the user's list of favorite items by type and ID.
9
 */
10
export async function main(
11
  auth: Smartsheet,
12
  favoriteType:
13
    | "folder"
14
    | "report"
15
    | "sheet"
16
    | "sight"
17
    | "template"
18
    | "workspace",
19
  favoriteId: string,
20
  x_smar_sc_actor_id?: string,
21
) {
22
  const url = new URL(
23
    `${auth.baseUrl}/favorites/${favoriteType}/${favoriteId}`,
24
  );
25

26
  const response = await fetch(url, {
27
    method: "DELETE",
28
    headers: {
29
      ...(x_smar_sc_actor_id
30
        ? { "x-smar-sc-actor-id": x_smar_sc_actor_id }
31
        : {}),
32
      Authorization: "Bearer " + auth.token,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42