0

Update Dashboard Share

by
Published Oct 17, 2025

Updates the access level of a user or group for the specified dashboard.

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
 * Update Dashboard Share
8
 * Updates the access level of a user or group for the specified dashboard.
9
 */
10
export async function main(
11
  auth: Smartsheet,
12
  sightId: string,
13
  shareId: string,
14
  accessApiLevel: string | undefined,
15
  body: {
16
    accessLevel?:
17
      | "ADMIN"
18
      | "COMMENTER"
19
      | "EDITOR"
20
      | "EDITOR_SHARE"
21
      | "OWNER"
22
      | "VIEWER";
23
  },
24
) {
25
  const url = new URL(
26
    `${auth.baseUrl}/sights/${sightId}/shares/${shareId}`,
27
  );
28
  for (const [k, v] of [["accessApiLevel", accessApiLevel]]) {
29
    if (v !== undefined && v !== "" && k !== undefined) {
30
      url.searchParams.append(k, v);
31
    }
32
  }
33
  const response = await fetch(url, {
34
    method: "PUT",
35
    headers: {
36
      "Content-Type": "application/json",
37
      Authorization: "Bearer " + auth.token,
38
    },
39
    body: JSON.stringify(body),
40
  });
41
  if (!response.ok) {
42
    const text = await response.text();
43
    throw new Error(`${response.status} ${text}`);
44
  }
45
  return await response.json();
46
}
47