0

Create a recurring bill

by
Published Oct 17, 2025

Create a recurring bill.

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 recurring bill
7
 * Create a recurring bill.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  organization_id: string | undefined,
12
  body: {
13
    vendor_id: string;
14
    currency_id?: string;
15
    recurrence_name: string;
16
    start_date: string;
17
    end_date?: string;
18
    source_of_supply?: string;
19
    place_of_supply?: string;
20
    destination_of_supply?: string;
21
    gst_treatment?: string;
22
    gst_no?: string;
23
    tax_treatment?: string;
24
    vat_treatment?: string;
25
    vat_reg_no?: string;
26
    is_abn_quoted?: string;
27
    abn?: string;
28
    is_reverse_charge_applied?: false | true;
29
    pricebook_id?: string;
30
    is_inclusive_tax?: false | true;
31
    location_id?: string;
32
    line_items?: {
33
      line_item_id?: string;
34
      item_id?: string;
35
      name?: string;
36
      account_id?: string;
37
      description?: string;
38
      rate?: number;
39
      hsn_or_sac?: string;
40
      reverse_charge_tax_id?: string;
41
      location_id?: string;
42
      quantity?: number;
43
      tax_id?: string;
44
      tds_tax_id?: string;
45
      tax_treatment_code?: string;
46
      tax_exemption_id?: string;
47
      tax_exemption_code?: string;
48
      item_order?: number;
49
      product_type?: string;
50
      acquisition_vat_id?: string;
51
      reverse_charge_vat_id?: string;
52
      unit?: string;
53
      tags?: { tag_id?: number; tag_option_id?: number }[];
54
      is_billable?: false | true;
55
      project_id?: string;
56
      customer_id?: string;
57
      item_custom_fields?: {
58
        custom_field_id?: number;
59
        index?: number;
60
        value?: string;
61
        label?: string;
62
      }[];
63
      serial_numbers?: string[];
64
    }[];
65
    is_tds_applied?: false | true;
66
    notes?: string;
67
    terms?: string;
68
    payment_terms?: number;
69
    payment_terms_label?: string;
70
    custom_fields?: { index?: number; value?: string }[];
71
    discount?: string;
72
    discount_account_id?: string;
73
    is_discount_before_tax?: false | true;
74
    repeat_every: string;
75
    recurrence_frequency: string;
76
  },
77
) {
78
  const url = new URL(`https://www.zohoapis.com/books/v3/recurringbills`);
79
  for (const [k, v] of [["organization_id", organization_id]]) {
80
    if (v !== undefined && v !== "" && k !== undefined) {
81
      url.searchParams.append(k, v);
82
    }
83
  }
84
  const response = await fetch(url, {
85
    method: "POST",
86
    headers: {
87
      "Content-Type": "application/json",
88
      Authorization: "Zoho-oauthtoken " + auth.token,
89
    },
90
    body: JSON.stringify(body),
91
  });
92
  if (!response.ok) {
93
    const text = await response.text();
94
    throw new Error(`${response.status} ${text}`);
95
  }
96
  return await response.json();
97
}
98