0

List recurring expenses

by
Published Oct 17, 2025

List all the Expenses 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 recurring expenses
7
 * List all the Expenses with pagination.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  recurrence_name: string | undefined,
13
  last_created_date: string | undefined,
14
  next_expense_date: string | undefined,
15
  status: string | undefined,
16
  account_id: string | undefined,
17
  account_name: string | undefined,
18
  amount: string | undefined,
19
  customer_name: string | undefined,
20
  customer_id: string | undefined,
21
  paid_through_account_id: string | undefined,
22
  filter_by: string | undefined,
23
  search_text: string | undefined,
24
  sort_column: string | undefined,
25
) {
26
  const url = new URL(`https://www.zohoapis.com/books/v3/recurringexpenses`);
27
  for (const [k, v] of [
28
    ["organization_id", organization_id],
29
    ["recurrence_name", recurrence_name],
30
    ["last_created_date", last_created_date],
31
    ["next_expense_date", next_expense_date],
32
    ["status", status],
33
    ["account_id", account_id],
34
    ["account_name", account_name],
35
    ["amount", amount],
36
    ["customer_name", customer_name],
37
    ["customer_id", customer_id],
38
    ["paid_through_account_id", paid_through_account_id],
39
    ["filter_by", filter_by],
40
    ["search_text", search_text],
41
    ["sort_column", sort_column],
42
  ]) {
43
    if (v !== undefined && v !== "" && k !== undefined) {
44
      url.searchParams.append(k, v);
45
    }
46
  }
47
  const response = await fetch(url, {
48
    method: "GET",
49
    headers: {
50
      Authorization: "Zoho-oauthtoken " + auth.token,
51
    },
52
    body: undefined,
53
  });
54
  if (!response.ok) {
55
    const text = await response.text();
56
    throw new Error(`${response.status} ${text}`);
57
  }
58
  return await response.json();
59
}
60