0

Update a recurring bill

by
Published Oct 17, 2025

Update a recurring bill. To delete a line item just remove it from the line_items list.

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