0

Update webhook

by
Published Oct 17, 2025

Update the specified webhook

Script formstack Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Formstack = {
3
  token: string;
4
};
5
/**
6
 * /webhook/:id
7
 * Update the specified webhook
8
 */
9
export async function main(
10
  auth: Formstack,
11
  id: string,
12
  body: {
13
    url: string;
14
    name?: string;
15
    handshake_key?: string;
16
    content_type?: string;
17
    use_field_ids?: false | true;
18
    no_subfield_names?: false | true;
19
    include_field_type?: false | true;
20
    standardize_field_values?: false | true;
21
    logic?: {};
22
  },
23
) {
24
  const url = new URL(`https://www.formstack.com/api/v2/webhook/${id}.json`);
25

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