0

Get Space

by
Published Oct 17, 2025

Returns the Space by id. • This endpoint is in **Alpha** testing. Please submit any feedback by sending an email to [email protected]. • In order to successfully call this endpoint, the specified Workspace needs to have the Spaces feature enabled. Please reach out to your customer success manager for more information.

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
 * Get Space
8
 * Returns the Space by id.
9

10
• This endpoint is in **Alpha** testing.  Please submit any feedback by sending an email to friends@segment.com.
11

12

13
• In order to successfully call this endpoint, the specified Workspace needs to have the Spaces feature enabled. Please reach out to your customer success manager for more information.
14
 */
15
export async function main(auth: Segment, spaceId: string) {
16
  const url = new URL(`${auth.baseUrl}/spaces/${spaceId}`);
17

18
  const response = await fetch(url, {
19
    method: "GET",
20
    headers: {
21
      Authorization: "Bearer " + auth.token,
22
    },
23
    body: undefined,
24
  });
25
  if (!response.ok) {
26
    const text = await response.text();
27
    throw new Error(`${response.status} ${text}`);
28
  }
29
  return await response.text();
30
}
31