0

List chart of accounts

by
Published Oct 17, 2025

List all chart of accounts along with pagination.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * List chart of accounts
7
 * List all chart of accounts along with pagination.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  showbalance: string | undefined,
13
  filter_by: string | undefined,
14
  sort_column: string | undefined,
15
  last_modified_time: string | undefined,
16
) {
17
  const url = new URL(`https://www.zohoapis.com/books/v3/chartofaccounts`);
18
  for (const [k, v] of [
19
    ["organization_id", organization_id],
20
    ["showbalance", showbalance],
21
    ["filter_by", filter_by],
22
    ["sort_column", sort_column],
23
    ["last_modified_time", last_modified_time],
24
  ]) {
25
    if (v !== undefined && v !== "" && k !== undefined) {
26
      url.searchParams.append(k, v);
27
    }
28
  }
29
  const response = await fetch(url, {
30
    method: "GET",
31
    headers: {
32
      Authorization: "Zoho-oauthtoken " + auth.token,
33
    },
34
    body: undefined,
35
  });
36
  if (!response.ok) {
37
    const text = await response.text();
38
    throw new Error(`${response.status} ${text}`);
39
  }
40
  return await response.json();
41
}
42