0

List all public integrations along with private ones trusted by the specific org.

by
Published Oct 17, 2025
Script gitbook Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Gitbook = {
3
  token: string;
4
};
5
/**
6
 * List all public integrations along with private ones trusted by the specific org.
7
 *
8
 */
9
export async function main(
10
  auth: Gitbook,
11
  organizationId: string,
12
  page: string | undefined,
13
  limit: string | undefined,
14
  search: string | undefined,
15
  category:
16
    | "analytics"
17
    | "collaboration"
18
    | "content"
19
    | "gitsync"
20
    | "marketing"
21
    | "visitor-auth"
22
    | "other"
23
    | undefined,
24
  blockDomain: string | undefined,
25
  blocks: string | undefined,
26
  contentSources: string | undefined,
27
  owner: string | undefined,
28
  scope:
29
    | "space:views:read"
30
    | "space:content:read"
31
    | "space:content:write"
32
    | "space:metadata:read"
33
    | "space:metadata:write"
34
    | "space:script:inject"
35
    | "space:script:cookies"
36
    | "space:git:sync"
37
    | "space:visitor:auth"
38
    | "site:metadata:read"
39
    | "site:views:read"
40
    | "site:script:inject"
41
    | "site:script:cookies"
42
    | "site:visitor:auth"
43
    | "site:adaptive:read"
44
    | "site:adaptive:write"
45
    | "openapi:read"
46
    | "openapi:write"
47
    | "conversations:ingest"
48
    | undefined,
49
  target: "all" | "site" | "space" | "organization" | undefined,
50
) {
51
  const url = new URL(`https://api.gitbook.com/v1/orgs/${organizationId}/integrations`);
52
  for (const [k, v] of [
53
    ["page", page],
54
    ["limit", limit],
55
    ["search", search],
56
    ["category", category],
57
    ["blockDomain", blockDomain],
58
    ["blocks", blocks],
59
    ["contentSources", contentSources],
60
    ["owner", owner],
61
    ["scope", scope],
62
    ["target", target],
63
  ]) {
64
    if (v !== undefined && v !== "" && k !== undefined) {
65
      url.searchParams.append(k, v);
66
    }
67
  }
68
  const response = await fetch(url, {
69
    method: "GET",
70
    headers: {
71
      Authorization: "Bearer " + auth.token,
72
    },
73
    body: undefined,
74
  });
75
  if (!response.ok) {
76
    const text = await response.text();
77
    throw new Error(`${response.status} ${text}`);
78
  }
79
  return await response.json();
80
}
81