0

Create a tax authority [US and CA Edition only]

by
Published Oct 17, 2025

Create a tax authority.

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 tax authority [US and CA Edition only]
7
 * Create a tax authority.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  body: {
13
    tax_authority_name: string;
14
    description?: string;
15
    registration_number?: string;
16
    registration_number_label?: string;
17
  },
18
) {
19
  const url = new URL(
20
    `https://www.zohoapis.com/inventory/v1/settings/taxauthorities`,
21
  );
22
  for (const [k, v] of [["organization_id", organization_id]]) {
23
    if (v !== undefined && v !== "" && k !== undefined) {
24
      url.searchParams.append(k, v);
25
    }
26
  }
27
  const response = await fetch(url, {
28
    method: "POST",
29
    headers: {
30
      "Content-Type": "application/json",
31
      Authorization: "Zoho-oauthtoken " + auth.token,
32
    },
33
    body: JSON.stringify(body),
34
  });
35
  if (!response.ok) {
36
    const text = await response.text();
37
    throw new Error(`${response.status} ${text}`);
38
  }
39
  return await response.json();
40
}
41