0

Import a Bank/Credit Card Statement

by
Published Oct 17, 2025

Import your bank/credit card feeds into your account.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Import a Bank/Credit Card Statement
7
 * Import your bank/credit card feeds into your account.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  body: {
13
    account_id: string;
14
    start_date?: string;
15
    end_date?: string;
16
    transactions: {
17
      transaction_id?: string;
18
      date: string;
19
      debit_or_credit: string;
20
      amount: number;
21
      payee?: string;
22
      description?: string;
23
      reference_number?: string;
24
    }[];
25
  },
26
) {
27
  const url = new URL(`https://www.zohoapis.com/books/v3/bankstatements`);
28
  for (const [k, v] of [["organization_id", organization_id]]) {
29
    if (v !== undefined && v !== "" && k !== undefined) {
30
      url.searchParams.append(k, v);
31
    }
32
  }
33
  const response = await fetch(url, {
34
    method: "POST",
35
    headers: {
36
      "Content-Type": "application/json",
37
      Authorization: "Zoho-oauthtoken " + auth.token,
38
    },
39
    body: JSON.stringify(body),
40
  });
41
  if (!response.ok) {
42
    const text = await response.text();
43
    throw new Error(`${response.status} ${text}`);
44
  }
45
  return await response.json();
46
}
47