0

Get organization

by
Published Oct 17, 2025
Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Get organization
7
 *
8
 */
9
export async function main(
10
  auth: Zoho,
11
  X_ZOHO_SERVICE?: string,
12
  X_ZCSRF_TOKEN?: string,
13
) {
14
  const url = new URL(`https://zohoapis.com/crm/v8/org`);
15

16
  const response = await fetch(url, {
17
    method: "GET",
18
    headers: {
19
      ...(X_ZOHO_SERVICE ? { "X-ZOHO-SERVICE": X_ZOHO_SERVICE } : {}),
20
      ...(X_ZCSRF_TOKEN ? { "X-ZCSRF-TOKEN": X_ZCSRF_TOKEN } : {}),
21
      Authorization: "Zoho-oauthtoken " + 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.json();
30
}
31