0

Update form

by
Published Oct 17, 2025

Update the details of the specified form

Script formstack Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Formstack = {
3
  token: string;
4
};
5
/**
6
 * /form/:id
7
 * Update the details of the specified form
8
 */
9
export async function main(
10
  auth: Formstack,
11
  id: string,
12
  body: {
13
    name?: string;
14
    db?: false | true;
15
    template?: string;
16
    num_columns?: number;
17
    label_position?: string;
18
    submit_button_title?: string;
19
    password?: string;
20
    use_ssl?: false | true;
21
    timezone?: string;
22
    language?: string;
23
    active?: false | true;
24
    disabled_message?: string;
25
  },
26
) {
27
  const url = new URL(`https://www.formstack.com/api/v2/form/${id}.json`);
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