0

List all webhooks

by
Published Oct 17, 2025

Returns all defined webhooks for the requesting application. This API only returns webhooks that are applied to files or folders that are owned by the authenticated user. This means that an admin can not see webhooks created by a service account unless the admin has access to those folders, and vice versa.

Script box Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Box = {
3
  token: string;
4
};
5
/**
6
 * List all webhooks
7
 * Returns all defined webhooks for the requesting application.
8

9
This API only returns webhooks that are applied to files or folders that are
10
owned by the authenticated user. This means that an admin can not see webhooks
11
created by a service account unless the admin has access to those folders, and
12
vice versa.
13
 */
14
export async function main(
15
  auth: Box,
16
  marker: string | undefined,
17
  limit: string | undefined,
18
) {
19
  const url = new URL(`https://api.box.com/2.0/webhooks`);
20
  for (const [k, v] of [
21
    ["marker", marker],
22
    ["limit", limit],
23
  ]) {
24
    if (v !== undefined && v !== "" && k !== undefined) {
25
      url.searchParams.append(k, v);
26
    }
27
  }
28
  const response = await fetch(url, {
29
    method: "GET",
30
    headers: {
31
      Authorization: "Bearer " + auth.token,
32
    },
33
    body: undefined,
34
  });
35
  if (!response.ok) {
36
    const text = await response.text();
37
    throw new Error(`${response.status} ${text}`);
38
  }
39
  return await response.json();
40
}
41