0

List integrations

by
Published Oct 17, 2025

List integrations matching the given parameters, paginated.

Script gorgias Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Gorgias = {
3
  username: string;
4
  apiKey: string;
5
  domain: string;
6
};
7
/**
8
 * List integrations
9
 * List integrations matching the given parameters, paginated.
10
 */
11
export async function main(
12
  auth: Gorgias,
13
  cursor: string | undefined,
14
  _type:
15
    | "email"
16
    | "gmail"
17
    | "outlook"
18
    | "aircall"
19
    | "self_service"
20
    | "smooch_inside"
21
    | "smooch"
22
    | "facebook"
23
    | "gorgias_chat"
24
    | "phone"
25
    | "sms"
26
    | "twitter"
27
    | "yotpo"
28
    | "http"
29
    | "shopify"
30
    | "recharge"
31
    | "smile"
32
    | "magento2"
33
    | "zendesk"
34
    | "klaviyo"
35
    | undefined,
36
  page: string | undefined,
37
  per_page: string | undefined,
38
  limit: string | undefined,
39
  order_by: "created_datetime:asc" | "created_datetime:desc" | undefined,
40
) {
41
  const url = new URL(`https://${auth.domain}.gorgias.com/api/integrations`);
42
  for (const [k, v] of [
43
    ["cursor", cursor],
44
    ["type", _type],
45
    ["page", page],
46
    ["per_page", per_page],
47
    ["limit", limit],
48
    ["order_by", order_by],
49
  ]) {
50
    if (v !== undefined && v !== "" && k !== undefined) {
51
      url.searchParams.append(k, v);
52
    }
53
  }
54
  const response = await fetch(url, {
55
    method: "GET",
56
    headers: {
57
      Authorization: "Basic " + btoa(`${auth.username}:${auth.apiKey}`),
58
    },
59
    body: undefined,
60
  });
61
  if (!response.ok) {
62
    const text = await response.text();
63
    throw new Error(`${response.status} ${text}`);
64
  }
65
  return await response.json();
66
}
67