0

List email data sources

by
Published Oct 17, 2025
Script salesflare Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Salesflare = {
3
  apiKey: string;
4
};
5
/**
6
 * List email data sources
7
 *
8
 */
9
export async function main(
10
  auth: Salesflare,
11
  includeTeamDataSources: string | undefined,
12
) {
13
  const url = new URL(`https://api.salesflare.com/datasources/email`);
14
  for (const [k, v] of [["includeTeamDataSources", includeTeamDataSources]]) {
15
    if (v !== undefined && v !== "" && k !== undefined) {
16
      url.searchParams.append(k, v);
17
    }
18
  }
19
  const response = await fetch(url, {
20
    method: "GET",
21
    headers: {
22
      Authorization: "Bearer " + auth.apiKey,
23
    },
24
    body: undefined,
25
  });
26
  if (!response.ok) {
27
    const text = await response.text();
28
    throw new Error(`${response.status} ${text}`);
29
  }
30
  return await response.text();
31
}
32