0

Get information about the caller's organization

by
Published Oct 17, 2025

Can be used by the following roles assigned at the organization scope: - ORG_ADMIN - ORG_MEMBER

Script cockroachdb Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Cockroachdb = {
3
  token: string;
4
};
5
/**
6
 * Get information about the caller's organization
7
 * Can be used by the following roles assigned at the organization scope:
8
- ORG_ADMIN
9
- ORG_MEMBER
10

11
 */
12
export async function main(auth: Cockroachdb) {
13
  const url = new URL(`https://cockroachlabs.cloud/api/v1/organization`);
14

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