0

Create a bank account

by
Published Oct 17, 2025

Create a bank account or a credit card account for your organization.

Script zoho Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Zoho = {
3
  token: string;
4
};
5
/**
6
 * Create a bank account
7
 * Create a bank account or a credit card account for your organization.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  body: {
13
    account_name: string;
14
    account_type: string;
15
    account_number?: string;
16
    account_code?: string;
17
    currency_id?: string;
18
    currency_code?: string;
19
    description?: string;
20
    bank_name?: string;
21
    routing_number?: string;
22
    is_primary_account?: false | true;
23
    is_paypal_account?: false | true;
24
    paypal_type?: string;
25
    paypal_email_address?: string;
26
  },
27
) {
28
  const url = new URL(`https://www.zohoapis.com/books/v3/bankaccounts`);
29
  for (const [k, v] of [["organization_id", organization_id]]) {
30
    if (v !== undefined && v !== "" && k !== undefined) {
31
      url.searchParams.append(k, v);
32
    }
33
  }
34
  const response = await fetch(url, {
35
    method: "POST",
36
    headers: {
37
      "Content-Type": "application/json",
38
      Authorization: "Zoho-oauthtoken " + auth.token,
39
    },
40
    body: JSON.stringify(body),
41
  });
42
  if (!response.ok) {
43
    const text = await response.text();
44
    throw new Error(`${response.status} ${text}`);
45
  }
46
  return await response.json();
47
}
48