0

Update Workspace Share

by
Published Oct 17, 2025

Updates the access level of a user or group for the specified workspace. **_This operation is only available to system administrators._**

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 Workspace Share
8
 * Updates the access level of a user or group for the specified workspace.
9

10
**_This operation is only available to system administrators._**
11

12
 */
13
export async function main(
14
  auth: Smartsheet,
15
  workspaceId: string,
16
  shareId: string,
17
  accessApiLevel: string | undefined,
18
  body: {
19
    accessLevel?:
20
      | "ADMIN"
21
      | "COMMENTER"
22
      | "EDITOR"
23
      | "EDITOR_SHARE"
24
      | "OWNER"
25
      | "VIEWER";
26
  },
27
) {
28
  const url = new URL(
29
    `${auth.baseUrl}/workspaces/${workspaceId}/shares/${shareId}`,
30
  );
31
  for (const [k, v] of [["accessApiLevel", accessApiLevel]]) {
32
    if (v !== undefined && v !== "" && k !== undefined) {
33
      url.searchParams.append(k, v);
34
    }
35
  }
36
  const response = await fetch(url, {
37
    method: "PUT",
38
    headers: {
39
      "Content-Type": "application/json",
40
      Authorization: "Bearer " + auth.token,
41
    },
42
    body: JSON.stringify(body),
43
  });
44
  if (!response.ok) {
45
    const text = await response.text();
46
    throw new Error(`${response.status} ${text}`);
47
  }
48
  return await response.json();
49
}
50