0

Create form

by
Published Oct 17, 2025

Create a new form in your account

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
7
 * Create a new form in your account
8
 */
9
export async function main(
10
  auth: Formstack,
11
  body: {
12
    name: string;
13
    db?: false | true;
14
    template?: string;
15
    num_columns?: number;
16
    label_position?: string;
17
    submit_button_title?: string;
18
    password?: string;
19
    use_ssl?: false | true;
20
    timezone?: string;
21
    language?: string;
22
    active?: false | true;
23
    disabled_message?: string;
24
    fields?: string[];
25
    notifications?: string[];
26
    confirmation?: string[];
27
    webhooks?: string;
28
  },
29
) {
30
  const url = new URL(`https://www.formstack.com/api/v2/form.json`);
31

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