0

Create a customer

by
Published Oct 17, 2025

A new customer can a be created separately as well as at the time of creation of a new subscription.

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 customer
7
 * A new customer can a be created separately as well as at the time of creation of a new subscription.
8
 */
9
export async function main(
10
  auth: Zoho,
11
  X_com_zoho_subscriptions_organizationid: string,
12
  body: {
13
    display_name: string;
14
    salutation?: string;
15
    first_name?: string;
16
    last_name?: string;
17
    email: string;
18
    tags?: { tag_id?: number; tag_option_id?: number }[];
19
    company_name?: string;
20
    phone?: string;
21
    mobile?: string;
22
    department?: string;
23
    designation?: string;
24
    website?: string;
25
    billing_address?: {
26
      attention?: string;
27
      street?: string;
28
      city?: string;
29
      state?: string;
30
      zip?: string;
31
      country?: string;
32
      state_code?: string;
33
      fax?: string;
34
    };
35
    shipping_address?: {
36
      attention?: string;
37
      street?: string;
38
      city?: string;
39
      state?: string;
40
      zip?: string;
41
      country?: string;
42
      state_code?: string;
43
      fax?: string;
44
    };
45
    payment_terms?: number;
46
    payment_terms_label?: string;
47
    currency_code?: string;
48
    ach_supported?: false | true;
49
    twitter?: string;
50
    facebook?: string;
51
    skype?: string;
52
    notes?: string;
53
    is_portal_enabled?: false | true;
54
    gst_no?: string;
55
    gst_treatment?: string;
56
    place_of_contact?: string;
57
    vat_treatment?: string;
58
    tax_reg_no?: string;
59
    tds_tax_id?: string;
60
    tax_treatment?: string;
61
    tax_regime?: string;
62
    is_tds_registered?: false | true;
63
    vat_reg_no?: string;
64
    is_taxable?: string;
65
    tax_id?: string;
66
    tax_authority_id: {};
67
    tax_authority_name: string;
68
    tax_exemption_id?: string;
69
    tax_exemption_code?: string;
70
    default_templates?: {
71
      invoice_template_id?: string;
72
      creditnote_template_id?: string;
73
    };
74
    custom_fields?: { label?: string; value?: string }[];
75
  },
76
) {
77
  const url = new URL(`https://www.zohoapis.com/billing/v1/customers`);
78

79
  const response = await fetch(url, {
80
    method: "POST",
81
    headers: {
82
      "X-com-zoho-subscriptions-organizationid":
83
        X_com_zoho_subscriptions_organizationid,
84
      "Content-Type": "application/json",
85
      Authorization: "Zoho-oauthtoken " + auth.token,
86
    },
87
    body: JSON.stringify(body),
88
  });
89
  if (!response.ok) {
90
    const text = await response.text();
91
    throw new Error(`${response.status} ${text}`);
92
  }
93
  return await response.json();
94
}
95