0

Update notification email

by
Published Oct 17, 2025

Update the specified notification email

Script formstack Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Formstack = {
3
  token: string;
4
};
5
/**
6
 * /notification/:id
7
 * Update the specified notification email
8
 */
9
export async function main(
10
  auth: Formstack,
11
  id: string,
12
  body: {
13
    name?: string;
14
    from_type: string;
15
    from_value: string;
16
    recipients: string;
17
    subject: string;
18
    type: string;
19
    hide_empty?: false | true;
20
    show_section?: false | true;
21
    message?: string;
22
    attach_limit?: number;
23
    format?: string;
24
    logic?: {};
25
  },
26
) {
27
  const url = new URL(
28
    `https://www.formstack.com/api/v2/notification/${id}.json`,
29
  );
30

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