0

Create Webhook

by
Published Oct 17, 2025

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.

Script smartsheet Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Smartsheet = {
3
  token: string;
4
  baseUrl: string;
5
};
6
/**
7
 * Create Webhook
8
 * Creates a new Webhook.
9

10
A webhook is not enabled by default when it is created.
11
Once you've created a webhook, you can enable it by using the Update Webhook operation to set **enabled** to **true**.
12

13
When a row is deleted on a sheet, even if you are using a **subscope** to monitor columns only
14
and the cell in that column for that row is empty, you will receive a "row.deleted" event.
15

16
 */
17
export async function main(
18
  auth: Smartsheet,
19
  body: {
20
    callbackUrl?: string;
21
    events?: string[];
22
    name?: string;
23
    version?: number;
24
  } & {},
25
) {
26
  const url = new URL(`${auth.baseUrl}/webhooks`);
27

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