//native
type Smartsheet = {
token: string;
baseUrl: string;
};
/**
* Create Webhook
* Creates a new Webhook.
A webhook is not enabled by default when it is created.
Once you've created a webhook, you can enable it by using the Update Webhook operation to set **enabled** to **true**.
When a row is deleted on a sheet, even if you are using a **subscope** to monitor columns only
and the cell in that column for that row is empty, you will receive a "row.deleted" event.
*/
export async function main(
auth: Smartsheet,
body: {
callbackUrl?: string;
events?: string[];
name?: string;
version?: number;
} & {},
) {
const url = new URL(`${auth.baseUrl}/webhooks`);
const response = await fetch(url, {
method: "POST",
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