0

List Profiles Warehouse in Space

by
Published Oct 17, 2025

Lists all Profile Warehouses for a given space id. • When called, this endpoint may generate the `Profiles Sync Warehouse Retrieved` event in the audit trail.

Script segment Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Segment = {
3
  token: string;
4
  baseUrl: string;
5
};
6
/**
7
 * List Profiles Warehouse in Space
8
 * Lists all Profile Warehouses for a given space id.
9

10

11

12
• When called, this endpoint may generate the `Profiles Sync Warehouse Retrieved` event in the audit trail.
13
      
14
 */
15
export async function main(
16
  auth: Segment,
17
  spaceId: string,
18
  pagination: string | undefined,
19
) {
20
  const url = new URL(
21
    `${auth.baseUrl}/spaces/${spaceId}/profiles-warehouses`,
22
  );
23
  for (const [k, v] of [["pagination", pagination]]) {
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.text();
40
}
41