0

Update bank account

by
Published Oct 17, 2025

Modify the account that was created.

Script zoho Verified

The script

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