0

Create an Update Request

by
Published Oct 17, 2025

Creates an update request for the specified rows within the sheet.

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
 * Create an Update Request
8
 * Creates an update request for the specified rows within the sheet.
9
 */
10
export async function main(
11
  auth: Smartsheet,
12
  sheetId: string,
13
  body: {
14
    ccMe?: false | true;
15
    message?: string;
16
    sendTo?: { email?: string } | { groupId?: number }[];
17
    subject?: string;
18
  } & {
19
    id?: number;
20
    createdAt?: string | number;
21
    modifiedAt?: string | number;
22
    schedule?: {
23
      type?: "ONCE" | "DAILY" | "WEEKLY" | "MONTHLY" | "YEARLY";
24
      dayDescriptors?:
25
        | "DAY"
26
        | "WEEKDAY"
27
        | "WEEKEND"
28
        | "SUNDAY"
29
        | "MONDAY"
30
        | "TUESDAY"
31
        | "WEDNESDAY"
32
        | "THURSDAY"
33
        | "FRIDAY"
34
        | "SATURDAY"[];
35
      dayOfMonth?: number;
36
      dayOrdinal?: "FIRST" | "LAST" | "SECOND" | "THIRD" | "FOURTH";
37
      repeatEvery?: number;
38
      endAt?: ({} & string) | ({} & number);
39
      lastSentAt?: ({} & string) | ({} & number);
40
      nextSendAt?: ({} & string) | ({} & number);
41
      startAt?: ({} & string) | ({} & number);
42
    };
43
    sentBy?: { email?: string; name?: string };
44
  },
45
) {
46
  const url = new URL(
47
    `${auth.baseUrl}/sheets/${sheetId}/updaterequests`,
48
  );
49

50
  const response = await fetch(url, {
51
    method: "POST",
52
    headers: {
53
      "Content-Type": "application/json",
54
      Authorization: "Bearer " + auth.token,
55
    },
56
    body: JSON.stringify(body),
57
  });
58
  if (!response.ok) {
59
    const text = await response.text();
60
    throw new Error(`${response.status} ${text}`);
61
  }
62
  return await response.json();
63
}
64