0

Set Sheet Publish Status

by
Published Oct 17, 2025

Sets the publish status of the sheet and returns the new status, including the URLs of any enabled publishings.

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
 * Set Sheet Publish Status
8
 * Sets the publish status of the sheet and returns the new status, including the URLs of any enabled publishings.
9

10
 */
11
export async function main(
12
  auth: Smartsheet,
13
  sheetId: string,
14
  body: {
15
    icalEnabled?: false | true;
16
    readOnlyFullAccessibleBy?: "ALL" | "ORG" | "SHARED";
17
    readOnlyFullDefaultView?: "CALENDAR" | "CARD" | "GRID";
18
    readOnlyFullEnabled?: false | true;
19
    readOnlyFullShowToolbar?: false | true;
20
    readOnlyLiteEnabled?: false | true;
21
    readWriteAccessibleBy?: "ALL" | "ORG" | "SHARED";
22
    readWriteDefaultView?: "CALENDAR" | "CARD" | "GRID";
23
    readWriteEnabled?: false | true;
24
    readWriteShowToolbar?: false | true;
25
  },
26
) {
27
  const url = new URL(`${auth.baseUrl}/sheets/${sheetId}/publish`);
28

29
  const response = await fetch(url, {
30
    method: "PUT",
31
    headers: {
32
      "Content-Type": "application/json",
33
      Authorization: "Bearer " + auth.token,
34
    },
35
    body: JSON.stringify(body),
36
  });
37
  if (!response.ok) {
38
    const text = await response.text();
39
    throw new Error(`${response.status} ${text}`);
40
  }
41
  return await response.json();
42
}
43