0

Update Recurring Invoice

by
Published Oct 17, 2025

Update the recurring invoice.

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 Recurring Invoice
7
 * Update the recurring invoice.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  recurring_invoice_id: string,
12
  organization_id: string | undefined,
13
  body: {
14
    recurrence_name: string;
15
    reference_number?: string;
16
    customer_id: string;
17
    currency_id?: string;
18
    contact_persons?: string[];
19
    start_date?: string;
20
    end_date?: string;
21
    recurrence_frequency: "weeks";
22
    repeat_every?: number;
23
    place_of_supply?: string;
24
    vat_treatment?: string;
25
    gst_treatment?: string;
26
    tax_treatment?: string;
27
    is_reverse_charge_applied?: false | true;
28
    cfdi_usage?: string;
29
    allow_partial_payments?: false | true;
30
    gst_no?: string;
31
    location_id?: string;
32
    line_items?: {
33
      item_id?: string;
34
      name?: string;
35
      description?: string;
36
      rate?: number;
37
      quantity?: number;
38
      discount?: string;
39
      tags?: { tag_id?: string; tag_option_id?: string }[];
40
      tax_id?: {};
41
      tds_tax_id?: string;
42
      tax_exemption_id?: string;
43
      tax_treatment_code?: string;
44
      avatax_tax_code?: string;
45
      avatax_use_code?: string;
46
      item_total?: number;
47
      product_type?: string;
48
      hsn_or_sac?: string;
49
      sat_item_key_code?: string;
50
      unitkey_code?: string;
51
      location_id?: string;
52
      project_id?: string;
53
      header_name?: string;
54
      header_id?: string;
55
    }[];
56
    email?: string;
57
    custom_fields?: { value?: string; label?: string; data_type?: string }[];
58
    tax_id?: {};
59
    tax_authority_id?: string;
60
    payment_options?: {
61
      payment_gateways?: {
62
        configured?: false | true;
63
        additional_field1?: string;
64
        gateway_name?: string;
65
      }[];
66
    };
67
    tax_exemption_id?: string;
68
    avatax_use_code?: string;
69
    avatax_exempt_no?: string;
70
  },
71
) {
72
  const url = new URL(
73
    `https://www.zohoapis.com/books/v3/recurringinvoices/${recurring_invoice_id}`,
74
  );
75
  for (const [k, v] of [["organization_id", organization_id]]) {
76
    if (v !== undefined && v !== "" && k !== undefined) {
77
      url.searchParams.append(k, v);
78
    }
79
  }
80
  const response = await fetch(url, {
81
    method: "PUT",
82
    headers: {
83
      "Content-Type": "application/json",
84
      Authorization: "Zoho-oauthtoken " + auth.token,
85
    },
86
    body: JSON.stringify(body),
87
  });
88
  if (!response.ok) {
89
    const text = await response.text();
90
    throw new Error(`${response.status} ${text}`);
91
  }
92
  return await response.json();
93
}
94