//native
type Formstack = {
token: string;
};
/**
* /webhook/:id
* Update the specified webhook
*/
export async function main(
auth: Formstack,
id: string,
body: {
url: string;
name?: string;
handshake_key?: string;
content_type?: string;
use_field_ids?: false | true;
no_subfield_names?: false | true;
include_field_type?: false | true;
standardize_field_values?: false | true;
logic?: {};
},
) {
const url = new URL(`https://www.formstack.com/api/v2/webhook/${id}.json`);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago