0

Create Proof Version

by
Published Oct 17, 2025

Creates a proof version. Proof Id must be for the original proof.

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 Proof Version
8
 * Creates a proof version. Proof Id must be for the original proof.
9

10
 */
11
export async function main(
12
  auth: Smartsheet,
13
  sheetId: string,
14
  proofId: string,
15
  body: {
16
    attachmentSubType?:
17
      | "DOCUMENT"
18
      | "DRAWING"
19
      | "FOLDER"
20
      | "PDF"
21
      | "PRESENTATION"
22
      | "SPREADSHEET";
23
    attachmentType?:
24
      | "BOX_COM"
25
      | "DROPBOX"
26
      | "EGNYTE"
27
      | "EVERNOTE"
28
      | "FILE"
29
      | "GOOGLE_DRIVE"
30
      | "LINK"
31
      | "ONEDRIVE"
32
      | "TRELLO";
33
    description?: string;
34
    name?: string;
35
    url?: string;
36
  },
37
) {
38
  const url = new URL(
39
    `${auth.baseUrl}/sheets/${sheetId}/proofs/${proofId}/versions`,
40
  );
41

42
  const formData = new FormData();
43
  for (const [k, v] of Object.entries(body)) {
44
    if (v !== undefined && v !== "") {
45
      formData.append(k, String(v));
46
    }
47
  }
48
  const response = await fetch(url, {
49
    method: "POST",
50
    headers: {
51
      "Content-Type": "application/json",
52
      Authorization: "Bearer " + auth.token,
53
    },
54
    body: JSON.stringify(body),
55
  });
56
  if (!response.ok) {
57
    const text = await response.text();
58
    throw new Error(`${response.status} ${text}`);
59
  }
60
  return await response.json();
61
}
62