0

List Proof Versions

by
Published Oct 17, 2025

Gets a list of all versions of the given proofId in order from newest to oldest.

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
 * List Proof Versions
8
 * Gets a list of all versions of the given proofId in order from newest to oldest.
9

10
 */
11
export async function main(
12
  auth: Smartsheet,
13
  sheetId: string,
14
  proofId: string,
15
  page: string | undefined,
16
  pageSize: string | undefined,
17
  includeAll: string | undefined,
18
) {
19
  const url = new URL(
20
    `${auth.baseUrl}/sheets/${sheetId}/proofs/${proofId}/versions`,
21
  );
22
  for (const [k, v] of [
23
    ["page", page],
24
    ["pageSize", pageSize],
25
    ["includeAll", includeAll],
26
  ]) {
27
    if (v !== undefined && v !== "" && k !== undefined) {
28
      url.searchParams.append(k, v);
29
    }
30
  }
31
  const response = await fetch(url, {
32
    method: "GET",
33
    headers: {
34
      Authorization: "Bearer " + auth.token,
35
    },
36
    body: undefined,
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.json();
43
}
44